So, I’ve made some progress tinkering with running OH on a Raspberry Pi. I’ll move it on to a virtual machine later, once I develop my plan, but in the meantime I’m struggling with EXEC.
I’ve read many posts, but haven’t been able to find a beginner guide and want to confirm my understanding. The add-on is installed from apt-get, along with the rest of the software.
I have a basic script in /etc/openhab/configurations/scripts/test.sh the contents of which are 'echo "123"'
with ls -l reporting: -rwxrwxrwx 1 openhab openhab 23 Jan 28 16:34 test.sh
I have an item that reads: Number Exectest "Exx [%d]" { exec="<[/etc/openhab/configurations/scripts/test.sh:10000:REGEX((.*?))]" }
and a sitemap that contains Text item=Exectest]
should I expect my sitemap to have a text item that reads ‘123’?
Where should I see errors? I nothing jumps out at me in /var/log/openhab/openhab.log
Usually by the time I type my post, I solve my own problem but that hasn’t happened so far…
I am not an expert on the Exec binding by any means but my advice is to use
val results = executeCommandLine("/etc/openhab/configruations/scripts/test.sh", 5000)
logInfo("Test", results)
in a rule while trying to debug Exec. This is the only way I’ve found to see the error that your script is producing and seeing what the script is producing can save hours of experimentation trying to figure out what, if anything the script is doing.
Once it works in a rule you can usually transfer the script back to an Exec bound Item, though I have personally left it in a rule so I can get a log of the results every time it runs which saves me some steps when trying to debug any problems that pop up.
One thing I will caution you about is there is some unexpected behavior in the way OH starts up. It runs a script that changes the permissions on all the files OH owns which will strip the execution permission off of your test.sh script. See this thread for details. An issue was created to fix this and I posted a work around in the mean time.