it seems I’m stuck at the moment and I need a nudge in the right direction. I’ve found some similar topics here, but they seem to be quite complicated. Is there really no way as easy as this in openhab2?
Switch gF_Living_Ambient “Ambient Light” (gF_Living, gLights, gPower) { exec=">[ON:sudo send 10101 1 1] >[OFF:sudo send 10101 1 0]" }
Hm, it seems I’m still missing something.
Executing the script in bash works, but somehow not from openhab.
I added the user openhab to the groups sudo and gpio for testing, but no luck.
Additionally, i added these lines for to visudo:
Could you maybe test/answer two more things for me?
Does it work when you send the command in the item definition as runuser?
And how did you install the exec addon? PaperUI?
I’m having a nice restful evening tonight, but I’m not at home so can’t tell if it turns it on as the run user, but I can remote into my server and it doesn’t error.
Thanks for your help. I removed the openhab user from the gpio and sudo groups - and voila - my original command was working. But for good measure I adjusted it to yours, sending the command several times just to be sure.
Thank you so much for your help, I guess it would have been a sleepless night.
I’m having the same problem where I can switch a socket on but not off. From what I’ve read it’s easier to set up in exec binding 1.9, is 1.9 compatible with openhab2? If so where can I get exec binding 1.9 I can’t seem to find it.
Hi Rob,
your post from feb, but I would have a question.
I did the setup for the 433 MHz devices as shown in the link from your post. I am getting an error when executing the .sh script in the shell. The error message is
./switchOff.sh: line 2: 5067 Segmentation fault /opt/rc-switch/rcswitch-pi/send 11011 $1 0
My script looks like this:
#!/bin/bash
for run in {1..5}
do
/opt/rc-switch/rcswitch-pi/send 11011 $1 0
done
I also added my user openhabian to the sudo visudo groups as following:
# User privilege specification
openhabian ALL=NOPASSWD: /opt/rc-switch/switch*
which is the correct folder for the .sh script. By terminal it is possible for me to switch the light on or of. But not by openHab. Exec Binding is installed by Paper UI and I assume when it it possible to execute the .sh file my item definition will work as well.
I recognise the Segmentation fault error message, but can’t remember the cause. I think it was permissions related and if you can run it from the CLI I’d say that’s the case. What user is Openhab running under? Can you add that to the visudo group too?
I’ve since moved away from using a Pi with the Exec Binding and now have an ESP with an RF module hooked up so I can turn things on and off via MQTT.
I am running openhabian and the user is there as well openhabian. Connecting ssh with 8180 I am using the user openhanded. I will try tomorrow to ad this user as well to the visudo group. Main problem is that I can’t execute the .sh file which is required for the exec command from openHab system afterwards.
I am now able to switch the light on and off. The only thing I am wondering about is that after switching the light on, some seconds after this action, the lamp gets switched of again and on and off…I have no clue why. Any thoughts?
2017-10-08 18:12:46.769 [ItemStateChangedEvent ] - ONLAmpe2 changed from OFF to ON
2017-10-08 18:12:47.283 [ItemStateChangedEvent ] - ONLAmpe2 changed from ON to OFF
2017-10-08 18:13:23.052 [ItemStateChangedEvent ] - ONLAmpe2 changed from OFF to ON
2017-10-08 18:13:25.554 [ItemStateChangedEvent ] - ONLAmpe2 changed from ON to OFF