So, I am one step further, but still I am fighting against some kind of access rights, I do not understand. Hopefully someone can give me the final idea.
OH2 was installed on a Raspberry Pi with apt-get, I have the latest Oracle Java 1.8.0_121, but still problems to run some commands by openhab.
Finally, because openhab was not able to execute sh-scripts, I granted a lot of access rights (which is maybe not the best idea, but now I am one step further):
sudo visudo
# Allow members of group sudo to execute any command
sudo ALL=NOPASSWD: ALL
and in addition to that
sudo usermod -aG root openhab
sudo adduser openhab sudo
So what is the current result?
My Thing is as follows:
Thing exec:command:GB01_switch_control [command="/etc/openhab2/scripts/steckdosenleiste1.sh %2$s", transform="REGEX((.*?))", interval=0, autorun=true]
Item:
String GB_01_01 { channel="exec:command:GB01_switch_control:input", autoupdate="false" }
Sitemap:
Switch item=GB_01_01 label="Power" mappings=[ON="ON", OFF="OFF"]
This is my sh-Script:
#!/bin/bash
echo $1 >> /etc/openhab2/scripts/log.txt
if [ "$1" = "OFF" ]
then
sudo /etc/openhab2/scripts/raspberry-remote/send 10011 1 0
else
sudo /etc/openhab2/scripts/raspberry-remote/send 10011 1 1
fi
So what works an what not?
works: When pressing the Switch in OpenHab, it now creates new lines with “ON” or “OFF” values in the log.txt file.
works not: the send command (so the part within the if-condition) is not run by openhab
Of course, it works, when doing it as user pi from shell.
So I assume that there are still user permission problems. Maybe those different colors are an indicator for it: