[SOLVED] Problems with implementing lirc to control IR-devices

Do you think the mistake is in the rule?

lirc.apply("harman_kardon", "KEY_POWER", logName)

This makes sense but I thing the main problem has to do with the lirc server, which does not react with the command

echo “SEND_ONCE harman-kardon KEY_F4” | nc localhost 8765

Which Version of Lirc you use on the Raspberry … since Version (I think) 0.9 the config change … I run in the same Problems by using a Tutorial from Google … there was almost the old config.

This is my Config Script: (Perhaps this helps you to fix you Problems)

#Lirc Konfiguration
echo "lirc_dev" >> /etc/modules
echo "lirc_rpi gpio_out_pin=17 gpio_in_pin=18" >> /etc/modules
echo "dtoverlay=lirc-rpi,gpio_out_pin=17,gpio_in_pin=18" >> /boot/config.txt

>/etc/lirc/hardware.conf
cat <<EOF > /etc/lirc/hardware.conf
# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
#LIRCD_ARGS=""

#LIRCD_ARGS="--uinput"
LIRCD_ARGS="-uinput --listen"

#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD=false

#Don't start irexec, even if a good config file seems to exist.
#START_IREXEC=false

#Try to load appropriate kernel modules
LOAD_MODULES=true

# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="default"
# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"

# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""
EOF

>/etc/lirc/lircd.conf
cat <<EOF > /etc/lirc/lircd.conf
# Populated config files can be found at http://sf.net/p/lirc-remotes. The
# irdb-get(1) and lirc-setup(1) tools can be used to search and download
# config files.
#
# From 0.9.2 config files could just be dropped as-is in the lircd.conf.d
# directory and be included by this file.

include "lircd.conf.d/*.conf"
EOF


>/etc/lirc/lirc_options.conf
cat <<EOF > /etc/lirc/lirc_options.conf
# These are the default options to lircd, if installed as
# /etc/lirc/lirc_options.conf. See the lircd(8) and lircmd(8)
# manpages for info on the different options.
#
# Some tools including mode2 and irw uses values such as
# driver, device, plugindir and loglevel as fallback values
# in not defined elsewhere.

[lircd]
nodaemon        = False
driver          = default
device          = /dev/lirc0
output          = /var/run/lirc/lircd
pidfile         = /var/run/lirc/lircd.pid
plugindir       = /usr/lib/arm-linux-gnueabihf/lirc/plugins
permission      = 666
allow-simulate  = No
repeat-max      = 600
#effective-user =
#listen         = [address:]port
#connect        = host[:port]
#loglevel       = 6
#uinput         = ...
#release        = ...
#logfile        = ...

[lircmd]
uinput          = False
nodaemon        = False

# [modinit]
# code = /usr/sbin/modprobe lirc_serial
# code1 = /usr/bin/setfacl -m g:lirc:rw /dev/uinput
# code2 = ...


# [lircd-uinput]
# release-timeout = 200
EOF

>/etc/lirc/lircd.conf.d/remotes.conf
cat <<EOF > /etc/lirc/lircd.conf.d/remotes.conf
begin remote

  name  AppleTV
  bits            8
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9083  4430
  one           604  1620
  zero          604   519
  ptrail        604
  repeat       9084  2195
  pre_data_bits   16
  pre_data       0x77E1
  post_data_bits  8
  post_data      0x9A
  gap          108064
  toggle_bit_mask 0x0

      begin codes
          KEY_DOWN                 0xB0
          KEY_UP                   0xD0
          KEY_LEFT                 0x10
          KEY_RIGHT                0xE0
          KEY_OK                   0xBA 0x20
          KEY_MENU                 0x40
          KEY_PLAYPAUSE            0x7A 0x20
      end codes

end remote
EOF

Hey Kevin and thank you for your answer.

I’m running the latest version of lirc.

I edit my Answer. check my config Files :slight_smile:

Post your /etc/lirc/lircd.conf file… I think there is your Problem :slight_smile:

Here is my Way of integrate lirc and other Commands of the Raspberry to Openhab :slight_smile:

begin remote

  name  harman-kardon
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9002  4495
  one           565  1672
  zero          565   551
  ptrail        560
  repeat       9002  2255
  pre_data_bits   16
  pre_data       0x10E
  gap          107861
  toggle_bit_mask 0x0

      begin codes
          KEY_POWER                0x03FC
          KEY_POWER2               0xF906
          KEY_VOLUMEUP             0xE31C
          KEY_VOLUMEDOWN           0x13EC
          KEY_F                    0x03FC
          KEY_F1                   0x4FB0
          KEY_F2                   0xCF30
          KEY_F3                   0x3FC0
          KEY_F4                   0xF708
      end codes

end remote

There ist the Problem :slight_smile: this is the Old lirc Config … :wink:

Change the /etc/lirc/lircd.conf to

>/etc/lirc/lircd.conf
# Populated config files can be found at http://sf.net/p/lirc-remotes. The
# irdb-get(1) and lirc-setup(1) tools can be used to search and download
# config files.
#
# From 0.9.2 config files could just be dropped as-is in the lircd.conf.d
# directory and be included by this file.

include "lircd.conf.d/*.conf"

and the /etc/lirc/lircd.conf.d/remotes.conf to

begin remote

  name  harman-kardon
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9002  4495
  one           565  1672
  zero          565   551
  ptrail        560
  repeat       9002  2255
  pre_data_bits   16
  pre_data       0x10E
  gap          107861
  toggle_bit_mask 0x0

      begin codes
          KEY_POWER                0x03FC
          KEY_POWER2               0xF906
          KEY_VOLUMEUP             0xE31C
          KEY_VOLUMEDOWN           0x13EC
          KEY_F                    0x03FC
          KEY_F1                   0x4FB0
          KEY_F2                   0xCF30
          KEY_F3                   0x3FC0
          KEY_F4                   0xF708
      end codes

end remote

Reboot the Pi or restart the lirc Service!

ok, that was fast, shall I easily replace my /etc/lirc/lircd.conf with

>/etc/lirc/lircd.conf
# Populated config files can be found at http://sf.net/p/lirc-remotes. The
# irdb-get(1) and lirc-setup(1) tools can be used to search and download
# config files.
#
# From 0.9.2 config files could just be dropped as-is in the lircd.conf.d
# directory and be included by this file.

include "lircd.conf.d/*.conf"

?

Yes … and the Remote Data add to /etc/lirc/lircd.conf.d/remotes.conf

isn’t the server sending out fine though if your use irsend? Sounds like its not listening on 8765 to me. give this a go though, backing up any changes jic.

Ok what I did is following:

I removed my /etc/lirc/lircd.conf and made a new one with this content:

>/etc/lirc/lircd.conf
# Populated config files can be found at http://sf.net/p/lirc-remotes. The
# irdb-get(1) and lirc-setup(1) tools can be used to search and download
# config files.
#
# From 0.9.2 config files could just be dropped as-is in the lircd.conf.d
# directory and be included by this file.

include "lircd.conf.d/*.conf"

Then, I made a new directory ( I created it, because there was no directory) " /etc/lirc/lircd.conf.d" and made a new file remotes.conf:

begin remote

  name  harman-kardon
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9002  4495
  one           565  1672
  zero          565   551
  ptrail        560
  repeat       9002  2255
  pre_data_bits   16
  pre_data       0x10E
  gap          107861
  toggle_bit_mask 0x0

      begin codes
          KEY_POWER                0x03FC
          KEY_POWER2               0xF906
          KEY_VOLUMEUP             0xE31C
          KEY_VOLUMEDOWN           0x13EC
          KEY_F                    0x03FC
          KEY_F1                   0x4FB0
          KEY_F2                   0xCF30
          KEY_F3                   0x3FC0
          KEY_F4                   0xF708
      end codes

end remote

Then, I entered into the shell: sudo /etc/init.d/lirc stop and after that sudo /etc/init.d/lirc start.
Then, I tried: echo “SEND_ONCE harman-kardon KEY_POWER” | nc localhost 8765

Nothing happens :frowning:

And unfortunately, irsend SEND_ONCE harman-kardon KEY_POWER2 don’t work anymore now.

Yeah i would revert those changes. and start lirc again, test using the irsend to ensure lirc is able to send the correct ir codes.

The issues has to be with the way its started. Lets get the netcat command working first. Rule out anything openhab at this point. Just get lirc working on the network.

Is it running local to openhab and where your testing from?

Sorry, what do you mean exactly ?

i mean is lirc and openhab running on the same pi?

Oh, yeah, they do.

ok, now the command irsend SEND_ONCE harman-kardon KEY_POWER2 works again - I reverted all the changes.

The echo "SEND_ONCE … " does not work anyway…

Ok, run this command and post your results

netstat -lptn

Edit - should see something like this

tcp        0      0 0.0.0.0:8765            0.0.0.0:*               LISTEN

That makes sense. Somewhere there the problem must be. I think I haven’t typed in the port explicit, can I do this any where ?

tcp        0      0 0.0.0.0:9001            0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      -               
tcp6       0      0 :::139                  :::*                    LISTEN      -               
tcp6       0      0 :::5007                 :::*                    LISTEN      -               
tcp6       0      0 :::8080                 :::*                    LISTEN      -               
tcp6       0      0 :::22                   :::*                    LISTEN      -               
tcp6       0      0 127.0.0.1:36537         :::*                    LISTEN      -               
tcp6       0      0 :::8443                 :::*                    LISTEN      -               
tcp6       0      0 :::445                  :::*                    LISTEN      -               
tcp6       0      0 :::9124                 :::*                    LISTEN      -               
tcp6       0      0 127.0.0.1:8101          :::*                    LISTEN      -