I’m very new to openhab and I don’t have a lot of experience with programming in general. I picked openHAB to be able to run a simple RF-python script from my RPI. It works very well on a system level but not inside of openhab. I’ve read through the documentation and spent several days trying to wrap my head around both the execbinding and the executeCommandLine within rules. I made a simple rule trying just to run it and see if the command is getting executed at all but no luck there. Things I’ve checked:
Running the command on system level as openhab user. (Works)
added the command in the whitelist
added NOPASSWD for openhab user
Made a sh script running the python scripts instead of running it directly.
Here is my simple rule for checking if the command even gets through:
This will send the string " executeCommandLine( etc." to an Item named HYLLA.
What type of Item is that, what are you expecting it to do with that text string?
I think there is a bit of muddle here.
You can pre-configure Exec binding things and channels to call scripts, passing parameters derived from Item state as needed. You’d use those by linking channel to Item and, say, commanding the Item ON.,
Or, within the body of a scripted rule, the part where you can add stuff up or make log messages etc., you can ad-hoc use the action executeCommandLine() to call an external script, passing any parameters you can build.
Whitelisting is not required here.
Alright, then I guess I’ve been going in the wrong direction a little bit. I started with the exec binding at first which seemed more appropriate for my needs. Didn’t get that that up and running either though…:
I tried adding a run channel to that exec:command:HYLLA_ON:run. Then I set up cell in a test page that sends an on command to that item. The Item gets the command and changes to an ON - state but nothing at all happens with the command.
You configured it to run every 60 secs, you didn’t need to command anything.
If it was successful, you should see your Item linked to the run channel change state each minute. You’d need to look in your events.log for that, because its probably all over in few milliseconds and you won’t see that on a UI.
If you expected some result returned, you’d need tolink a String type Item to the output channel. Always worth doing anyway, as that’s where error messages will end up.
As you want to run a bash shell script I would suggest to insert a command that creates some output like date and time. Redirect it to a file so that at every execution a new entry is appended:
date >> /tmp/debug.txt
You may add the path to the date executable in front of it to make sure that it is always found.
In case the debug.txt file is never updated your bash is not executed.
Your bash file is located under the user openhabian. Check if the openhab user which OH service runs under has read and execute permission ( although execute should not be required as you execute the batch command ).