Exec Binding Setup on OpenHAB2

I’ve migrated to OH2 from 1.8 and all is going well.

In 1.8 I had an Exec binding which called RCSwitch to turn on some 433Mhz power sockets.

In OH2 I’ve installed the Exec 1.9.0.b4 through PaperUI.

My items file:
Switch BathroomDehumidifier “Power” {exec=">[OFF:sudo /home/pi/config/wiringpi/switchOff.sh 3 1] >[ON:sudo /home/pi/config/wiringpi/switchOn.sh 3 1]"}

My sitemap:
Switch item=BathroomDehumidifier

If I call the command in the items file the switch works, but not from the OpenHAB UI.

Any ideas? Is it configuration or permissions causing the problem?

Do you see anything happening in the logs?

Nothing in /var/log/openhab2/openhab.log

However, if I call service openhab2 status I see:

openhab : command not allowed ; TTY=unknown ; PWD=/var/lib/openhab2 ; USER=root ; COMMAND=/home/pi/config/wiringpi/s...hOn.sh 3 1

It was permissions.

Calling sudo visudo and adding

openhab ALL=NOPASSWD: /home/pi/config/wiringpi/switch*

Got things working

Excellent - don’t you like when you get to answer your own questions? :wink:

1 Like

I’d added the user hab to that file, and pi for good measure. Only in the service log did I see that it was referencing the user “openhab”