Exec Binding on Raspi for 433 MHz

Hi there,

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]" }


Which Exec Binding do you have installed in PaperUI?

1 Like

Just switched to 1.9 hoping it would be the same as with openhab 1.8.x, but it is still not working.

I’m using OpenHAB 2.0 with the Exec Binding (binding-exec1 - 1.10.0.SNAPSHOT)

I then have wiring pi and a script to turn on and off the units.

My items looks like this:

/* Dehumidifier (On switch) */
Switch          BathroomDehumidifier    "Power" {exec=">[OFF:sudo /home/pi/config/wiringpi/switchOff.sh 3 1] >[ON:sudo /home/pi/config/wiringpi/switchOn.sh 3 1]"}

and the .sh script looks like this:

for run in {1..10}
/home/pi/config/wiringpi/rcswitch-pi/send $1 $2 0

I used this tutorial as a guide, don’t forget to grant permissions to the script.

Hope this helps!

1 Like

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:

openhab ALL=NOPASSWD: /usr/local/bin/send
openhab ALL=NOPASSWD: /home/pi/Automation/scripts/switch*

I don’t know whether this is a any help, but

sudo runuser -l openhab -c "sudo /usr/local/bin/send 10101 1 1"

is not working either.

May I ask in which groups your openhab user is?

The OpenHAB user in in the OpenHAB group (groups openhab) and I have the following in my sudo visudoers file

# User privilege specification
root    ALL=(ALL:ALL) ALL
#pi     ALL=NOPASSWD: /home/pi/config/wiringpi/switch*
#hab     ALL=NOPASSWD: /home/pi/config/wiringpi/switch*
openhab ALL=NOPASSWD: /home/pi/config/wiringpi/switch*

1 Like


Thanks for your quick response!

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?

Thank you so much!

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.

The exec binding was installed via PaperUI.

1 Like

Thank you!

I’m still trying to find the error, as it is not working, but I guess I’ll be calling it a day soon (or maybe not ;)).

Enjoy your evening!

Hi Rob!

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. :wink:

1 Like

Glad to be of help! My next task is to get it running with the OH2 Exec Binding which uses slightly different syntax as it supports things

I think after my tinkering I’ll stick with 1.9. But let me know when it works, maybe I can just copy your solution (again) ;).

1 Like

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.

In PaperUI you can enable legacy bindings and then install the 1.9 exec under addons.
From my point of view, it was much easier with the 1.9 version.

1 Like

sounds like the best option… i didn’t know about the legacy options thank you

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:

for run in {1..5}
/opt/rc-switch/rcswitch-pi/send 11011 $1 0

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.

Can someone help me?

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.

Hi Rob,

thank you for the response.

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.

Any other guesses?

I was able to solve the segmentation fault issue. I had to create a thing and ad the following command:

Thing exec:command:on [command="/opt/rc-switch/switchOn.sh 3"]
Thing exec:command:off [command="/opt/rc-switch/switchOff.sh 3"]

After that with the following .item command:

Switch ONLAmpe2		"Lampe2 On" 	{ channel="exec:command:on:run"}
Switch OFFLAmpe2	"Lampe2 Off" 	{ channel="exec:command:off:run"}

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

How close are your neighbours? Try another channel maybe?

Do you see the switch change state in OpenHAB?