Hi community,
I’m using openhab for more than one year now and it works really stable and reliable.
Now I want to integrate a buetooth box and the first function I programmed is to check if the bluetooth connection from my raspberry pi (accessable via ssh) is working.
The shell script is quite simple and looks like this:
btinfo=$(ssh pi@raspberry.dahoim 'echo -e "info 00:13:7B:69:3C:94" | bluetoothctl')
if [[ $btinfo == *"Connected: no"* ]] ; then
echo "no"
elif [[ $btinfo == *"Connected: yes"* ]] ; then
echo "yes"
fi
The rule to trigger it looks like this:
rule "check-BT-connection-denon"
when
Item AU_D01_01 received command ON
then
logInfo("BTcheck","Rule to check BT connection triggered")
var String btinfo
btinfo = executeCommandLine("/etc/openhab2/myscripts/btcheck.sh",100000)
logInfo("BTcheck",btinfo)
end
Unfortunately I can see from the logs that there is an error saying:
2019-06-03 18:02:47.951 [INFO ] [lipse.smarthome.model.script.BTcheck] - /etc/openhab2/myscripts/btcheck.sh: 3: /etc/openhab2/myscripts/btcheck.sh: [[: not found
The shell script is working fine if I just run it via bash shell (also with the openhab user)
When I remove the if else statement from the shell script and just echo the variable $btinfo it gives the output of the command so this looks not like an issue with wrong permissions
Are there some limitations for executeCommandLine which I overlook in the documentation?
I’ve some other shell scripts running but no other script have an if statement.
Hope you can help me to get the script running. If this would not work, may I can try to run an python script doing the same thing or give the exec binding a try but I want to avoid that if possible.
Openhab runs on version 2.4.0. on a Debian Server 9 VM