How to use any IR Remote with Kodi

Controlling Kodi with a IR remote controll was always a pain in the ass. Here is a way i solved it lately:

You need a IR receiver (TSOP nnnn)... see below.

NOTE: i use a special Kodi distro called OSMC It's Raspbian based and gives you the freedom of apt-get and has a great backup and update feature. (if you used ELEC based distros you know what i'm talking about...)

So, for now, after i got a TV without CEC for a dime and my cheap china copy of the xBoxOne remote stopped working i tried to use the one i use with the TV. It seems there are plenty of unused buttons in HDMI mode.




Put your SD card into a reader at your PC/MAC and add this line to the config.txt file to enable LIRC:

trying sudo nano /boot/config-user.txt

dtoverlay=gpio-ir,gpio_pin=18

Put the card back to the PI, boot and connect tom it by SSH.

Does LIRC gets data from your remote? Try it with:

mode2 -d /dev/lirc0

Get actual inputs with:

$ sudo mode2 --driver default --device /dev/lirc0

Get all available KEY_codes to match them later:

$ irrecord --list-namespace

Now stop lircd, delete the lircd.conf and create a new one by recording the keys from the TV remote:

$ sudo killall lircd
$ rm lircd.conf
$ irrecord -d /dev/lirc0 ~/lircd.conf

Done? Fine! Now copy the created file to the location Kodi expects it:

sudo cp lircd.conf /etc/lirc/lircd.conf

Later on, to refine your setup, just delete the local lircd.conf like described above, rerecord buttons you want to try/fix. Then edit the file at /etc/lirc/lircd.conf. 'Overrecording' seems not to work. You have always start with no .conf file. :/

Pinout to connect the TSOP receiver

ir_empfaenger_tsop4838_steckplatine




My lircd.conf (work in progress)

as you can see: the readings of irrecord is kind'a strange. Sometimes 8 bit, sometimes 16 and i also got 2 times 16 bit commands for a single key. Unreliable as hell but trial'n'error and copy'n'paste will maybe solve it. At least... it works... kind of...

# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.0(default) on Mon Jul 22 22:24:51 2019
#
# contributed by 
#
# brand:                       /home/osmc/lircd.conf
# model no. of remote control: 
# devices being controlled by this remote:
#

begin remote

  name  /home/osmc/lircd.conf
  bits            8
  flags RC6|CONST_LENGTH
  eps            30
  aeps          100

  header       2707   909
  one           435   444
  zero          435   444
  pre_data_bits   13
  pre_data       0xEFF
  gap          107370
  toggle_bit_mask 0x10000
  rc6_mask    0x10000

begin remote

  name  /home/osmc/lircd.conf
  bits            8
  flags RC6|CONST_LENGTH
  eps            30
  aeps          100

  header       2707   909
  one           435   444
  zero          435   444
  pre_data_bits   13
  pre_data       0xEFF
  gap          107370
  toggle_bit_mask 0x10000
  rc6_mask    0x10000

      begin codes
          KEY_OK                   0xA3
          KEY_C                    0x33
          KEY_INFO                 0xFE
          KEY_BACK                 0xB3
          KEY_PLAY                 0xD3
          KEY_STOP                 0xCE
          KEY_PAUSE                0xCF
          KEY_UP                   0x1FA7
          KEY_DOWN                 0x1FA6
          KEY_LEFT                 0x1FA5
          KEY_RIGHT                0x1FA4
          KEY_ZOOM                 0xFF
          KEY_ESC                  0x1FF5
      end codes

end remote

NOTE:
Q: "why you don't tell the type of TV and remote so i can copy and paste the config."
A: Because it doesn't matter: every time you record the IR remote the config will be sooo different. Sometimes it does not work at all untill you reboot cry and try again ("there is no... but i know there must be one"... i like this error message).
So... rinse and repeat untill your setup works.

start/stop lircd:

$ sudo systemctl stop lircd_helper@lirc0
$ sudo systemctl start lircd_helper@lirc0

I found this usefull: https://github.com/patricktokeeffe/lirc-philips-sru3004wm17
Most of the keys work great with my Philips remote.

begin remote

  name  philips-sru3004wm17
  bits           13
  flags RC6|CONST_LENGTH
  eps            30
  aeps          100

  header       2673   866
  one           466   425
  zero          466   425
  pre_data_bits   24
  pre_data       0x1BFF83
  gap          105771
  min_repeat      1
#  suppress_repeat 1
#  uncomment to suppress unwanted repeats
  toggle_bit_mask 0x8000
  rc6_mask    0x100000000

      begin codes
          KEY_POWER                0x1BF3 # POWER
          KEY_1                    0x1BFE # 1
          KEY_2                    0x1BFD # 2
          KEY_3                    0x1BFC # 3
          KEY_4                    0x1BFB # 4
          KEY_5                    0x1BFA # 5
          KEY_6                    0x1BF9 # 6
          KEY_7                    0x1BF8 # 7
          KEY_8                    0x1BF7 # 8
          KEY_9                    0x1BF6 # 9
          KEY_BACK                 0x1BDA # (-)
          KEY_0                    0x1BFF # 0
          KEY_ENTER                0x1BF4 # ENTER
          KEY_HOME                 0x1BD9 # GUIDE
          KEY_MENU                 0x1BDB # MENU
          KEY_INFO                 0x1BF0 # INFO
          KEY_ESC                  0x1BDC # QUIT
          KEY_VOLUMEUP             0x1BEF # VOL +
          KEY_VOLUMEDOWN           0x1BEE # VOL -
          KEY_UP                   0x1BE1 # | (donut button top)
          KEY_DOWN                 0x1BE0 # | (donut button btm)
          KEY_LEFT                 0x1BDF # -- (donut button left)
          KEY_RIGHT                0x1BDE # -- (donut button right)
          KEY_OK                   0x1BDD # OK
          KEY_CHANNELUP            0x1BED # CH +
          KEY_CHANNELDOWN          0x1BEC # CH -
          KEY_MUTE                 0x1BF1 # MUTE
          KEY_C                    0x1BB4 # PIP
          KEY_SEARCH               0x1BE3 # SWAP
          KEY_AGAIN                0x1BDC # REPEAT [PREV. CHAN]
          KEY_SUBTITLE             0x1BB2 # CC [SUBTITLE]
          KEY_MODE                 0x1BD8 # ARC ("Aspect Ratio Control")
          KEY_INPUT                0x1BB7 # TV/VCR [INPUT]
          KEY_SLEEP                0x1BF2 # SLEEP
          KEY_REWIND               0x1BEA # << [SCAN -]
          KEY_PLAY                 0x1BE9 # |> [PLAY]
          KEY_FASTFORWARD          0x1BEB # >> [SCAN +]
          KEY_RECORD               0x1BE8 # O [REC]
          KEY_STOP                 0x1BE6 # [_] [STOP]
          KEY_PAUSE                0x1BE7 # || [PAUSE]
      end codes

end remote

Happy remote controlling!