Sign inSign up

pilotak/lirc-watcher

By pilotak

•Updated over 5 years ago

Listens to LIRC daemon and sends it to MQTT

Image
1

2.4K

pilotak/lirc-watcher repository overview

⁠LIRC watcher

Docker Build Docker Pulls Docker Size

Docker container that listens to LIRC daemon (running on the host) and sends received codes over MQTT with added benefit of short and long putton press.

LIRC must be install on the host system. Following examples have been tested below but should work on other platforms with adjustments too.

Built by Github Actions⁠

⁠Debian Buster

Please follow steps in wiki Install-on-Debian-Buster⁠

⁠Debian Stretch

Please follow steps in wiki Install-on-Debian-Stretch⁠

⁠Ubuntu 18.04

Please follow steps in wiki Install-on-Ubuntu-18.04⁠

⁠Recording codes

Test receiver

sudo systemctl stop lircd.service
mode2 --driver default --device /dev/lirc0

Output should look similar to this:

space 4195
pulse 551
space 1621
pulse 501
space 529
pulse 572
space 1553
pulse 547
space 524
pulse 551
space 525
pulse 549

If everything is ok, execute following and follow the commands in the script. Adjust name of the file should you wish.

sudo irrecord --driver default --device /dev/lirc0 ~/pioneer.lircd.conf

You will end it up with file ~/pioneer.lircd.conf.

begin remote

  name  pioneer
  bits           32
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       8544  4180
  one           578  1545
  zero          578   497
  ptrail        575
  gap          91166
  min_repeat      3
  toggle_bit_mask 0xF0F08080
  frequency    38000

      begin codes
          KEY_POWER                0xA55A38C7
          KEY_MUTE                 0xA55A48B7
          KEY_VOLUMEUP             0xA55A50AF
          KEY_VOLUMEDOWN           0xA55AD02F
      end codes

end remote

Let's move this config over to LIRC daemon.

sudo mv ~/pioneer.lircd.conf /etc/lirc/lircd.conf.d/
sudo systemctl start lircd.service

Test receiver again, if you see the names of your keys when button pressed, that's a win-win.

irw

⁠Docker-compose

Now just start the docker container, alter the config to your needs and you ready to rock.

version: "3"
services:
  lirc:
    container_name: lirc
    restart: always
    image: pilotak/lirc-watcher
    environment:
      - MQTT_BROKER=192.168.0.10
      - MQTT_USER=admin
      - MQTT_PASSWORD=my-secret-pw
    volumes:
      - /var/run/lirc/lircd:/var/run/lirc/lircd
⁠Environmental variables

Bellow are all available variables

VariableDescriptionDefault value
LONG_PRESSHow many messages is received to be considered as long press12
READ_TIMEOUTHow long to wait to process new data seconds0.2
PAYLOAD_LONG_PRESSPayload on long press"long"
PAYLOAD_SHORT_CLICKPayload on short press"short"
MQTT_BROKERBroker addresslocalhost
MQTT_USERMQTT userNone
MQTT_PASSWORDMQTT passwordNone
MQTT_PORTMQTT broker port1883
MQTT_IDMQTT client id"lirc-watcher"
MQTT_PREFIXMQTT topic prefix"lirc"
⁠MQTT topics

When button is pressed you will receive message in format MQTT_PREFIX/REMOTE_NAME/KEY_NAME with payload short / long ie. lirc/pioneer/KEY_POWER

Tag summary

Content type

Image

Digest

Size

18.6 MB

Last updated

over 5 years ago

docker pull pilotak/lirc-watcher