Hello, I am trying to send a I2c command via the OpenHab2 to the raspberry pi. My target is press the switch ON and the command to send a relay on (python code) is executed.
RULE:
rule: “Powe on”
when
Item zone1 received command
then
if(zone1.stat==ON){
First please use the code fences when posting code
Second, try debugging:
rule: “Powe on”
when
Item zone1 received command
then
if (zone1.stat == ON) {
var String str = executeCommandLine("python /etc/openhab2/scripts/relay1config.py")
logInfo("DEBUG", str)
}
end
You need to specify a timeout as a second argument to executeCommandLine if you want to get a result back, otherwise it just executes the command and move on to the next line.
var String str = executeCommandLine("python /etc/openhab2/scripts/relay1config.py", 5000)
Did you try to execute the script as user openhab from the commandline?
Does the user Openhab have all necessary rights to acces I2C or GPIO what ever your skript tries to access?
In the following post all this things are explained in detail. It usees the Exec binding but all this is also relevent for executeCommandLine.