i have experienced permission issue while trying to use openhab with exec binding
first of all you can always check the permissions by “sudo -u”.
For example
1 | sudo -u openhab /usr/bin/python /home/pi/testscript.py |
to guarantee fixing the permissions issue of openhab, i did a couple thing, all of them were needed
you should also do these steps
1-) copy your scripts to /etc/openhab2 folder, and use them there if possible
2-) grant scripts permissions like this
1 2 3 | sudo chown openhab testscript.py sudo chmod 777 testscript.py sudo chmod a+x testscript.py |
3-) edit config file and change user and usergroup to root from openhab
1 | sudo nano /etc/default/openhab2 |
1 2 | OPENHAB_USER=root OPENHAB_GROUP=root |
4-) add openhab user to sudoers
1 | sudo adduser openhab sudo |
5-) open this file with
1 | sudo visudo |
and edit this like the example below
1 | openhab ALL = NOPASSWD: /usr/bin/python, /usr/bin/sh |
6-) restart openhab service after all these steps
1 | sudo service openhab2 restart |