Kodi Community Forum

Full Version: Noobs(ish) guide to configure LIRC with your TV-remote
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I just spend some hours to configure my system to get my Philips remote to work with xbmc through lirc, and when I was on it i manage to setup the IR blaster to control the surround system. I did this because my mce-remotes batteries died, and I was to lacy to buy new.
I know this may be the worst written guide ever, but I'm going to rewrite it with better step when I have time!
(I'm running xbmcbuntu)

Philips remote
Image

Sony remote
Image

Mce-transceiver
Image

IR-cables to the mce, used for ir-blast (plugged into the mce-transceiver)
Image

If you have some tips to do some better configs please comment!

Soo
First of all I tested alla buttons on the Philips remote to se which didn't "do anything" when i was on the HDMI channel. This to know which I could use to control xbmc.

Then started record my Philips-tv-remote, and Sony-Surround-remote (IF you don't want to ir-blast don't do anything that i show with the Sony-Remote).
used parts of this guide, with some small configurations: http://alexba.in/blog/2013/01/06/setting...spberrypi/
Either take a keyboard to your xbmcbuntu pc and press "CTRL+ALT+F1" or use ssh (I recommend ssh)

On all code be root/sudo
Code:
sudo -s
#enter password

Code:
# Make a backup of the original lircd.conf file
sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd_original.conf

# Stop lirc to free up /dev/lirc0
sudo /etc/init.d/lirc stop

# Create a new remote control configuration file (One for philips) RECORD ALL YOUR BUTTONS (you'll need it later)
irrecord -d /dev/lirc0 ~/lircd.conf

# Create a new remote control configuration file (One for sony) (SKIP IF NO IR-BLASTER)
irrecord -d /dev/lirc0 ~/sony.conf

#then i put both remotes in the ~/lircd.conf  (SKIP IF NO IR-BLASTER)
nano ~/lircd.conf

#copy the sony.conf lines into this also  (SKIP IF NO IR-BLASTER)

#and renamed the name,
#from:
name /home.....
#to:
name Philips
#and the same for sony (see below)

# Copy over your new configuration file
sudo cp ~/lircd.conf /etc/lirc/lircd.conf
NOTE: Sometimes when you do the irrecord it's dosen't work, so i re-did it until it worked (READ THE INSTRUCTIONS GIVEN)

My /etc/lircd.conf file
Code:
begin remote

  name  Philips
  bits            8
  flags RC6|CONST_LENGTH
  eps            30
  aeps          100

  header       2737   853
  one           469   409
  zero          469   409
  pre_data_bits   13
  pre_data       0xEFF
  gap          106679
  toggle_bit_mask 0x10000
  rc6_mask    0x10000

      begin codes
          KEY_STOP                 0xCE
          KEY_PAUSE                0xCF
          KEY_REWIND               0xD4
          KEY_PLAY                 0xD3
          KEY_FORWARD              0xD7
          KEY_FIND                 0x33
          KEY_UP                   0xA7
          KEY_OK                   0xA3
          KEY_DOWN                 0xA6
          KEY_LEFT                 0xA5
          KEY_RIGHT                0xA4
          KEY_CHANNELDOWN          0xB2
          KEY_CHANNELUP            0xB3
          KEY_EXIT                 0x0EFFF5
          KEY_VOLUMEUP             0xEF
          KEY_VOLUMEDOWN           0xEE
          KEY_MUTE                 0xF2
          KEY_1                    0xFE
          KEY_2                    0xFD
          KEY_3                    0xFC
          KEY_4                    0xFB
          KEY_5                    0xFA
          KEY_6                    0xF9
          KEY_7                    0xF8
          KEY_8                    0xF7
          KEY_9                    0xF6
          KEY_0                    0xFF
          KEY_SUBTITLE             0xB4
          KEY_TEXT                 0xC3
          KEY_BLUE                 0x0EFF8F
          KEY_SWITCHVIDEOMODE      0x0EFFC7
          KEY_GREEN                0x91
          KEY_RED                  0x92
          KEY_YELLOW               0x90
          KEY_HOME                 0xAB
          KEY_A                    0x6F
          KEY_O                    0xBF
      end codes

end remote

begin remote

  name  Sony
  bits            7
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       2406   570
  one          1210   580
  zero          612   580
  post_data_bits  8
  post_data      0xA
  gap          44575
  min_repeat      2
#  suppress_repeat 2
#  uncomment to suppress unwanted repeats
  toggle_bit_mask 0x0

      begin codes
          KEY_POWER                0x54
          KEY_MUTE                 0x14
          KEY_VOLUMEUP             0x24
          KEY_VOLUMEDOWN           0x64
      end codes

end remote

Then to get it working with xbmc you have to config Lircmap.xml and remote.xml

DO NOT PUT BUTTONS IN THE Lircmap.xml FILE THAT DO SOMETHING TO THE TV AS "SOURCE, OPTIONS. etc"
first Lircmap.xml, put this in your file, and remove/add keys you prefer.
Code:
nano ~/.xbmc/userdate/Lircmap.xml
Code:
<lircmap>
  <remote device="Philips">
    <play>KEY_PLAY</play>
    <pause>KEY_PAUSE</pause>
    <stop>KEY_STOP</stop>
    <forward>KEY_FORWARD</forward>
    <reverse>KEY_REWIND</reverse>
    <left>KEY_LEFT</left>
    <right>KEY_RIGHT</right>
    <up>KEY_UP</up>
    <down>KEY_DOWN</down>
    <select>KEY_OK</select>
    <back>KEY_EXIT</back>
    <one>KEY_1</one>
    <two>KEY_2</two>
    <three>KEY_3</three>
    <four>KEY_4</four>
    <five>KEY_5</five>
    <six>KEY_6</six>
    <seven>KEY_7</seven>
    <eight>KEY_8</eight>
    <nine>KEY_9</nine>
    <zero>KEY_0</zero>
    <subtitle>KEY_SUBTITLE</subtitle>
    <obc1>KEY_FIND</obc1>
    <obc2>KEY_TEXT</obc2>
  </remote>
</lircmap>

then remote.xml
Code:
nano ~/.xbmc/userdata/keymaps/remote.xml
Code:
<keymap>
<global>
  <remote>
   <obc1>RunScript(script.xbmc.subtitles)</obc1>
   <obc2>Info</obc2>
</remote>
</global>
</keymap>

I didn't have so many keys to use, so this is it.
I rebooted and it worked. But i realized a big problem, it went crazy when i changed source to my playstation or watched ordinary tv. Next post

So I copied my files and made some scripts to make it turn off all buttons aside from one (in my case the Blue, which didn't do anything on my channel HDMI1)

Code:
cp /etc/lirc/lircd.conf /etc/lirc/lircdon.conf
cp /etc/lirc/lircd.conf /etc/lirc/lircdoff.conf
And commented out all the BUTTONS (not the other parts) aside from the blue on /etc/lirc/lircoff.conf
Code:
nano /etc/lirc/lircoff.conf

My lircdoff.conf
Code:
# Please make this file available to others
# by sending it to <[email protected]>
#
# this config file was automatically generated
# using lirc-0.9.0(default) on Thu Dec 19 18:37:46 2013
#
# contributed by
#
# brand:                       /home/white/lircd.conf
# model no. of remote control:
# devices being controlled by this remote:
#

begin remote

  name  Philips
  bits            8
  flags RC6|CONST_LENGTH
  eps            30
  aeps          100

  header       2737   853
  one           469   409
  zero          469   409
  pre_data_bits   13
  pre_data       0xEFF
  gap          106679
  toggle_bit_mask 0x10000
  rc6_mask    0x10000

      begin codes
#          KEY_STOP                 0xCE
#          KEY_PAUSE                0xCF
#          KEY_REWIND               0xD4
#          KEY_PLAY                 0xD3
#          KEY_FORWARD              0xD7
#          KEY_FIND                 0x33
#          KEY_UP                   0xA7
#          KEY_OK                   0xA3
#          KEY_DOWN                 0xA6
#          KEY_LEFT                 0xA5
#          KEY_RIGHT                0xA4
#          KEY_CHANNELDOWN          0xB2
#          KEY_CHANNELUP            0xB3
#          KEY_EXIT                 0x0EFFF5
#          KEY_VOLUMEUP             0xEF
#          KEY_VOLUMEDOWN           0xEE
#          KEY_MUTE                 0xF2
#          KEY_1                    0xFE
#          KEY_2                    0xFD
#          KEY_3                    0xFC
#          KEY_4                    0xFB
#          KEY_5                    0xFA
#          KEY_6                    0xF9
#          KEY_7                    0xF8
#          KEY_8                    0xF7
#          KEY_9                    0xF6
#          KEY_0                    0xFF
#          KEY_SUBTITLE             0xB4
#          KEY_TEXT                 0xC3
          KEY_BLUE                 0x0EFF8F
#          KEY_SWITCHVIDEOMODE      0x0EFFC7
#          KEY_GREEN                0x91
#          KEY_RED                  0x92
#          KEY_YELLOW               0x90
#          KEY_HOME                 0xAB
#          KEY_A                    0x6F
#          KEY_O                    0xBF
      end codes

end remote

begin remote

  name  Sony
  bits            7
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       2406   570
  one          1210   580
  zero          612   580
  post_data_bits  8
  post_data      0xA
  gap          44575
  min_repeat      2
#  suppress_repeat 2
#  uncomment to suppress unwanted repeats
  toggle_bit_mask 0x0

      begin codes
#          KEY_POWER                0x54
#          KEY_MUTE                 0x14
#          KEY_VOLUMEUP             0x24
#          KEY_VOLUMEDOWN           0x64
      end codes

end remote

My scripts to control this (change USER, to your computers user)
Code:
nano /home/USER/Scripts/remote.sh

Put this in it, change USERHTTP, PASSWORD, IP and PORT to your HTTP info (ie: admin:[email protected]:8080)
(change USER, to your computers user)
Code:
#!/bin/sh
scriptdir="/home/USER/Scripts/"
killall -9 irexec

if [ $2 -eq 1 ]
then
rm -rf /etc/lirc/lircd.conf
cp /etc/lirc/lircdon.conf /etc/lirc/lircd.conf
else
rm -rf /etc/lirc/lircd.conf
cp /etc/lirc/lircdoff.conf /etc/lirc/lircd.conf
fi
sudo /etc/init.d/lirc restart
irexec -d /home/white/.lircrc

cd $scriptdir"tmp/"
wget -q "http://USERHTTP:PASSWORD@IP:PORT/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22method%22:%22GUI.ShowNotification%22,%22params%22:{%22title%22:%22Lirc%22
,%22message%22:%22$1%22,%22displaytime%22:10000},%22id%22:%221%22}"

cd ../
rm -rf $scriptdir"tmp/"*

make it executable (CHANGE USER)
Code:
chmod u+x /home/USER/Scripts/remote.sh

Then to use this script
Code:
nano ~/.lircrc

Put this in it (where it says button choose all keys that do something to your tv, as source (my KEY_SWITCHVIDEOMODE) etc.)
after adress to the script I have "Remote On", shows in xbmc notifications. And "1" makes the script activate all keys (uses lircdon.conf), "0" deactivates all keys aside from KEY_BLUE (uses lircdoff.conf)

This keys are very important that you DON'T have in ~/.xbmc/userdata/Lircmap.xml
(change USER, to your computers user)
Code:
begin
prog = irexec
button = KEY_BLUE
config = /home/USER/Scripts/remote.sh "Remote On" "1"
end

begin
prog = irexec
button = KEY_YELLOW
config = /home/USER/Scripts/remote.sh "Remote Off" "0"
end

begin
prog = irexec
button = KEY_GREEN
config = /home/USER/Scripts/remote.sh "Remote Off" "0"
end

begin
prog = irexec
button = KEY_RED
config = /home/USER/Scripts/remote.sh "Remote Off" "0"
end

begin
prog = irexec
button = KEY_SWITCHVIDEOMODE
config = /home/USER/Scripts/remote.sh "Remote Off" "0"
end

begin
prog = irexec
button = KEY_HOME
config = /home/USER/Scripts/remote.sh "Remote Off" "0"
end

begin
prog = irexec
button = KEY_A
config = /home/USER/Scripts/remote.sh "Remote Off" "0"
end

begin
prog = irexec
button = KEY_O
config = /home/USER/Scripts/remote.sh "Remote Off" "0"
end

Now all you have to do is make irexec autostart
Code:
nano /etc/init.d/startirexec.sh

Put this in it (change USER, to your computers user)
Code:
#! /bin/sh
sleep 10
killall -9 irexec
sleep 5
irexec -d /home/USER/.lircrc
exit 0

Then run
Code:
update-rc.d startirexec.sh default
to make it autostart.

If my bad explaining worked, it should run after a reboot. When you press a button that make the tv do something as "Source" lirc turns off, when you hit "Blue" it starts again.

In the next post I'll describe the ir-blast.
IR-blasting

add this code to ~/.lircrc
(CHANGE USER)
Code:
begin
prog = irexec
button = KEY_CHANNELUP
config = /home/USER/Scripts/sound.sh "UP" "KEY_VOLUMEUP"
end

begin
prog = irexec
button = KEY_CHANNELDOWN
config = /home/USER/Scripts/sound.sh "DOWN" "KEY_VOLUMEDOWN"
end

begin
prog = irexec
button = KEY_MUTE
config = /home/USER/Scripts/sound.sh "MUTE" "KEY_MUTE"
end

Make a new script
Code:
nano ~/Scripts/sound.sh
Put this in
(AS BEFORE CHANGE USER ETC.) The remote name in "irsend SEND_ONCE sony $2", should be your surround control name.
Code:
#!/bin/sh
scriptdir="/home/USER/Scripts/"

irsend SEND_ONCE sony $2
cd $scriptdir"tmp/"

wget -q "http://USERHTTP:PASSWORD@IP:PORT/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22method%22:%22GUI.ShowNotification%22,%22params%22:{%22title%22:%22Volume%22
,%22message%22:%22$1%22,%22displaytime%22:3000},%22id%22:%221%22}"

cd ../
rm -rf $scriptdir"tmp/"*

make it executable
Code:
chmod u+x ~/Scripts/sound.sh

Reboot!
it should do it, gl Big Grin