I could use some help. Ive been fiddling with trying to get OpenHAB2 working for the last few weeks on and off between just getting the linux distribution working and trying to figure out how OpenHAB2 works. Ive made some progress but am currently stuck at the exec function in two ways. One I may be able to figure out asI have found info related to it, but I can’t really try it yet until the other problem is fixed first. I am currently running openHAB 2.1.0 with the 2.1.0 exec binding.
About 99% of the things I want to run at the moment through OpenHAB will be done using the exec binding. Namely a SSH shutdown of a computer, as well as sending CEC signals through the pi to turn on my TV via libcec (As well as other various commands, most of which I have, though I am missing 1 or 2 that I can’t seem to find documentation on, but appear to be possible). I got libcec installed and functioning and have made scripts for each command as the formatting doesn’t play nice with the exec binding. I also have a functioning SSH command and publickey setup so the shutdown command can be sent with a single line without the need for the user to type in a password or such.
So I shall start with problem number 1. At the moment I have the things and items setup and are linked to the sitemap. I will include the code snippets below. The problem is at current, the exec commands run every 30 seconds regardless of whether the user has touched them. I am unsure as to why this is the case. I have only found one other user in the forum with this issue, and they found a workaround, but i’d rather find out if possible WHY this is happening to begin with and fix the issue directly. Below are the code snippers for my things and items. Most are currently commented out on the TV section as I have yet to write the scripts for them and was only testing with the TV On and SSH Shutdown commands.
Things
//This is the Things file
//HDTV
//Thing exec:command:TVON [command="echo "on" 0.0.0.0 | cec-client -s -d 1"]
//Thing exec:command:TVOFF [command="echo "standby" 0.0.0.0 | cec-client -s -d 1"]
//Thing exec:command:HDMI1 [command="echo "tx 4F:82:10:00" | cec-client -s -d 1"]
//Thing exec:command:HDMI2 [command="echo "tx 4F:82:20:00" | cec-client -s -d 1"]
//Thing exec:command:HDMI3 [command="echo "tx 4F:82:30:00" | cec-client -s -d 1"]
//Thing exec:command:HDMI4 [command="echo "tx 4F:82:40:00" | cec-client -s -d 1"]
//Thing exec:command:VOLUP [command="echo "tx 4F:82:10:00" | cec-client -s -d 1"]
//Thing exec:command:VOLDOWN [command="echo "voldown" | cec-client -s -d 1"]
Thing exec:command:TVON [command="/Scripts/TVON.sh", timeout=5, autorun=false]
//SSH Command
Thing exec:command:SHUTDOWN [command="ssh -p 2222 -l admin -i /home/pi/.ssh/PrivateKey.ppk 192.168.2.102 shutdown.exe /s /t 0", timeout=5, autorun=false]
Items
//This is the Items File
Switch MediaPC "Media-PC" (Status, Network) { wol="192.168.2.255#BC-AE-C5-E3-40-0C" }
//HDTV
Switch TVON "TV On" { channel="exec:command:TVON:run" }
//SSH Shutdown
Switch SHUTDOWN "Shutdown Media-PC" { channel="exec:command:SHUTDOWN:run" }
//Demo items
Switch DEMOSW "Demo Switch"
I will also include the output from Karaf
18:13:00.938 [INFO ] [marthome.event.ItemStateChangedEvent] - TVON changed from OFF to ON
18:13:01.132 [INFO ] [marthome.event.ItemStateChangedEvent] - TVON changed from ON to OFF
18:14:01.135 [INFO ] [marthome.event.ItemStateChangedEvent] - TVON changed from OFF to ON
18:14:01.331 [INFO ] [marthome.event.ItemStateChangedEvent] - TVON changed from ON to OFF
18:15:01.370 [INFO ] [marthome.event.ItemStateChangedEvent] - TVON changed from OFF to ON
18:15:01.583 [INFO ] [marthome.event.ItemStateChangedEvent] - TVON changed from ON to OFF
18:16:01.630 [INFO ] [marthome.event.ItemStateChangedEvent] - TVON changed from OFF to ON
18:16:01.778 [INFO ] [marthome.event.ItemStateChangedEvent] - TVON changed from ON to OFF
18:17:01.875 [INFO ] [marthome.event.ItemStateChangedEvent] - TVON changed from OFF to ON
18:17:02.091 [INFO ] [marthome.event.ItemStateChangedEvent] - TVON changed from ON to OFF
If anything else is needed, please let me know.
As for issue 2, aside from the fact the scripts run every 30 seconds, they actually do not work either. I have gotten them to a point where theres at least no more errors being spat out in the log files when I run them. With a friends help I was able to at least output a log file on the command being run which returns the error “failed to open vchiq instance”. I have found some info on this issue, so I might already have a fix for this in mind, but i’d like to hear what anyone has to say about this issue. I don’t plan to fix it until the constant script running issue is fixed first since it would cause my TV to turn on constantly if it’s fixed first.
As for my particular installation if thats important, I started from a clean Raspbian image (Running on a Raspberry Pi Zero W) and use the apt based install and have also made extensive documentation on the process since I had to redo this install a ton of times at first. So if any of that would be useful in solving the issues, I can provide that as well. I have a limited knowledge of linux however so keep that in mind (To note I am not a total noob, but I am primarily a high lever windows user and touch linux maybe once every few years if that. I do have friends who are very adept in linux though who have helped me through various issues in the setup. So please bare with me as I may or may not know what your speaking of if you get technical.).