I wanted to control my Air Conditioner via LIRC and then connect it to OpenHAB, I had several problems since my AC is quite new so the information it sends is quite complex to interpret with irsend. Looking for an alternative I found http://abyz.me.uk/rpi/pigpio/examples.html#Python_irrp_py
where there is a script called " IR Record and Playback" that works first recording the control and then playing the same command. I run my AC with this program, so I decided to implement it to my openhab.
First I created a script called “auto24on.sh” that executed python
#!/bin/sh
./irrp.py -p -g23 -f Auto24 on
Where
./irrp.py, It's the script that allows me to turn on and off my AC
23, the GPIO
Auto24, the code that contain on and off sequence that allows me to turn on the air in this case.
Then in openhab
Demo.items
Switch Habitacion_Aire "Aire Acondicionado"
Demo.rules
rule "Aire On"
when
Item Habitacion_Aire received command ON
then
val String results = executeCommandLine("/etc/openhab2/scripts/auto24on.sh", 5000)
logInfo("Exec2", results)
end
rule "Aire On1"
when
Item Habitacion_Aire received command ON
then
executeCommandLine("/etc/openhab2/scripts/auto24on.sh")
end
I created two rules, one to execute the command and the other to see the error with more detail, with what I got…
I think that openHAB executed the script. When I look at your example where you ran it successfully from the command line it doesn’t give any output either. Hence, openHAB logs an empty line.
The following is actually a better solution:
#!/bin/sh
cd /etc/openhab2/scripts
./irrp.py -p -g23 -f Auto24 on
The /etc/openhab/scripts directory is actually not meant for normal shell scripts. It is meant for scripts written using the rules DSL if I’m not mistaken.
Well… “the cure is worse than the disease”…
I had created 2 rules, one to see the result of the execution of the rule and another the rule that only executed the script. It seems that the rules overlapped and there was the problem. I just left the script execution rule and it works.
rule "Aire On"
when
Item Habitacion_Aire received command ON
then
executeCommandLine("/etc/openhab2/scripts/auto24on.sh")
end