I’m trying to control lirc from openHab which sits on a separate raspberry pi. Remote access is configured and working. So I can either use a TCP binding (cannot get this to work) or a executecommandline.
As I had no success with the TCP binding, I’m trying to control it though a rule.
In my rule I have the following.
var result = executeCommandLine(“echo SEND_ONCE technika32 KEY_POWER | nc 192.168.1.11 8765”)
logInfo(“TVStandby”, result)
The log shows result as “null”
If i run that same command from ssh logged into the openhab raspberry pi, it works and lirc returns…
BEGIN
SEND_ONCE technika32 KEY_POWER
SUCCESS
END
Can anyone tell me what I’m doing wrong in openhab which means this isn’t working. I have another rule which executescommandline just fine.
Can you get these commands to run from the command line yourself? If so the problem may be a permission problem as OH runs as the openhab user instead of your user. The openhab user as limited permissions and frequently this is the source of problems.
Yes I can get the commands to run fine under my user.
im not sure how i would go about troubleshooting if its permissions. It doesn’t require sudo, so I don’t think that’s it and even if it was I already have the openhab allowed to sudo without a password, which is working fine in my other rule.
I’m at a loose end.
I have two options, netcat as per this post, or get the tcp binding to work.
Interesting. I can’t say that I’ve tried to use a pipe from within openhab. It should work though.
At think point I would either just write the command as a shell script and call that from OH and move on to more interesting problems. Short of that I would just flail around trying random stuff like escaping the pipe or quoting the string sna commands in different ways hoping something works.
Thank you so much for your help today. I’ve finally got it cracked. This rule will turn the power on to the tv and then send an ir code to take it out of standby. Turning off, just kills the power.
rule “h_GF_Living_TV ON/OFF”
when
Item h_GF_Living_TV changed
then
lock.lock()
try {
if(h_GF_Living_TV.state == OFF )
{
logInfo(“TV OFF”, “TV OFF: Begin”)
logInfo(“TV OFF”, “TV OFF: Power off Sockets”)
var result = executeCommandLine(“sudo /home/pi/scripts/433Scripts/StatusRCT08.sh 401419 1 OFF”, 5000)
logInfo(“TV OFF”, "TV OFF: " + result)
logInfo(“TV OFF”, “TV OFF: End”)
}
if(h_GF_Living_TV.state == ON )
{
logInfo("TV ON", "TV ON: Begin")
logInfo("TV ON", "TV ON: Power on Sockets")
var result1 = executeCommandLine("sudo /home/pi/scripts/433Scripts/StatusRCT08.sh 401419 1 ON", 5000)
logInfo("TV ON", "TV ON: " + result1)
Thread::sleep(5000)
logInfo("TV ON", "TV ON: Send KEY_POWER")
var result2 = executeCommandLine("/home/pi/scripts/LircScripts/Lirc.sh technika32 KEY_POWER", 5000)
logInfo("TV ON", "TV ON: " + result2)
logInfo("TV ON", "TV ON: End")
}
You need the Exec binding addon. See the wiki page for details on how to set up and configure everything.
It might be worth while starting with the demo and play with that to learn how everything works.
At a high level you need:
install the exec addon (see the Exec Binding wiki page)
I recommend at least starting by creating a rule and using executeCommandLine rather than Items directly bound to the command until you get it to work. To do this create an unbound Item that triggers a rule and call executeCommandLine within that rule.
is your lirc working after installing openhab.i first intalld openhab and now when i am trying to install lirc again its not working properly although it was working properly before