alexbain / lirc_web

Control LIRC from the web using NodeJS and lirc_node
125 stars 60 forks source link

lirc_web not finding a custom remote #63

Closed TSM-EVO closed 6 years ago

TSM-EVO commented 6 years ago

Hi @alexbain , thanks to your work over the years I've been able to use lircd to control my Daikin A/C unit with my RPi2.

I've recently re-setup my HomeAssistant in a docker container, which means that sending a simple command from HASS is not so simple.

I have raspbian stretch installed, and lirc is working. The command irsend SEND_ONCE DAIKIN KEY_POWER turns my A/C on.

$ irsend list DAIKIN ""

0000000000000001 KEY_POWER
0000000000000002 KEY_POWER2

npm -v 6.1.0 and node -v v10.6.0

I installed lirc_web with npm, didn't need sudo, and I can load the web interface at myip:3000. On that page there are three 'buttons's that say could not connect to socket No such file or directory open socket /run/lirc/lircd1: No such file or directory

I have the config file at ~/.lirc_web_config.json and it looks like this now:

{     
"server" : {
    "port" : 3000,
    "ssl" : false,
    "ssl_cert" : "/home/pi/lirc_web/server.cert",
    "ssl_key" : "/home/pi/lirc_web/server.key",
    "ssl_port" : 3001
  },
  "socket": "/run/lirc/lircd"
}

Changing the socket: changes what shows on the page. With the default "socket" the errors showed, with this string, nothing shows. I tried lots of strings here, I tried this one because systemctl status lircd.socket returns

lircd.socket
Loaded: loaded (/lib/systemd/system/lircd.socket; enabled; vendor preset: enabled)
Active: active (running) since Thu 2018-07-19 02:43:19 UTC; 7h ago
Listen: /run/lirc/lircd (Stream)

systemctl status lircd.service returns

● lircd.service - Flexible IR remote input/output application support
   Loaded: loaded (/lib/systemd/system/lircd.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2018-07-19 02:49:01 UTC; 7h ago
     Docs: man:lircd(8)
           http://lirc.org/html/configure.html
 Main PID: 1596 (lircd)
      CPU: 2.625s
   CGroup: /system.slice/lircd.service
           └─1596 /usr/sbin/lircd --nodaemon

Jul 19 10:34:56 raspberrypi lircd[1596]: lircd-0.9.4c[1596]: Info: removed client
Jul 19 10:34:56 raspberrypi lircd-0.9.4c[1596]: Info: removed client
Jul 19 10:35:12 raspberrypi lircd[1596]: lircd-0.9.4c[1596]: Notice: accepted new client on /var/run/lirc/lircd
Jul 19 10:35:12 raspberrypi lircd-0.9.4c[1596]: Notice: accepted new client on /var/run/lirc/lircd
Jul 19 10:35:12 raspberrypi lircd[1596]: lircd-0.9.4c[1596]: Info: removed client
Jul 19 10:35:12 raspberrypi lircd-0.9.4c[1596]: Info: removed client
Jul 19 10:35:24 raspberrypi lircd[1596]: lircd-0.9.4c[1596]: Notice: accepted new client on /var/run/lirc/lircd
Jul 19 10:35:24 raspberrypi lircd-0.9.4c[1596]: Notice: accepted new client on /var/run/lirc/lircd
Jul 19 10:35:24 raspberrypi lircd[1596]: lircd-0.9.4c[1596]: Info: removed client
Jul 19 10:35:24 raspberrypi lircd-0.9.4c[1596]: Info: removed client
 ls -l /dev/lirc0
crw-rw---- 1 root video 244, 0 Jul 19 04:04 /dev/lirc0

But one thing I noticed is

lirc_rpi               16384  2
lirc_dev               16384  1 lirc_rpi

I noticed there's no rc_core. That may be because I don't have the IR receiver hooked up or configured at this stage, one I read the codes from my remote I no longer needed it.

I also have this

:~ $ irexec
irexec: could not open config files /home/pi/.lircrc and /etc/lirc/lircrc
irexec: No such file or directory
Cannot parse config file

But since I can control my device with irsend I'm not sure if this is related.

Request:

Can you suggest what I can do to troubleshoot next? Should I try installing lirc_web differently? Or is my config wrong somehow?

I also want to ping @flochtililoch because I can see he also seems to be utilizing lirc_web in a similar way and seems to have a good understanding of the program.

My end goal is to use a Home Assistant switch to send KEY_POWER and KEY_POWER2 to my 'host' using the API and their restful switch component. Once I can figure out why my control won't show up in lirc_web, I think I should be pretty close to getting it functional.

Thank you again for your help

flochtililoch commented 6 years ago

Hi @TSM-EVO,

It looks like you're running LIRC 0.9.4 - I think lirc-web isn't fully compatible with this version of LIRC (I haven't verified though, but see these notes on Home Assistant LIRC component). If you need to use lirc-web, you might want to downgrade LIRC to 0.9.0.

Since your end goal is to send IR commands using HA, do you actually need lirc-web, or can you get away with only configuring the LIRC component within HA?

TSM-EVO commented 6 years ago

@flochtililoch Thanks for the prompt response!

My understanding is that the lirc component in HA can't send irsend commands, which is what I'm trying to do. Because I've now setup my HA with docker, I can't send commands directly to my "host" which is running lirc.

I've tried using key pairs to have the HA docker container send ssh to the host machine but failed to get that working, too.

It would be nice to have lirc_web working so that I could eventually separate my HA device from my lirc device.

I'll try downgrading lirc to 0.9.0. Thanks!

TSM-EVO commented 6 years ago

Downgrading to 0.9.0 worked.

$ lircd -v
lircd 0.9.0-pre1

my remote shows up in lirc_web and the buttons function.

Thanks!

flochtililoch commented 6 years ago

Great! I wrote a little while back another JavaScript module (lirc-state-api, works on the top of lirc_node like lirc_web) that exposes a REST API to manipulate remotes, while keeping states of the remote controlled devices in memory. This might be useful for your use case, particularly if you want your HA switch to retain/show the last state set. I’m still using it today to control all my IR devices and it work mostly well except for a few edge cases. In case you’re interested give it a shot/let me know if you need help to set it up (there are RPi docker images in my docker hub)

TSM-EVO commented 6 years ago

I'll certainly check it out, I can see why it'd be helpful. For my use case, though, knowing the state of my IR device is not critical, but if I were to extend functionality it'd be on the list of things I'd want.