Exec Binding - Scripts get executed every 30 sec

Hello openHab-Community,

I´m quite new to this but I already managed to get some stuff working for me, but I´m struggeling a bit with the behaviour of my exec-binding:

I´m can Power on my Bose Soundtouch via openHab - I created a simple script for it that takes an argument and calls the API with it.

This is my config:

Thing:

Thing exec:command:st [command="bash /etc/openhab2/scripts/test.sh POWER", autorun=true, timeout=5]

Item:
Switch ST { channel="exec:command:st:run"}

Sitemap
Switch item=ST

I can execute the script from the BasicUI and it works fine - openHab can turn it on and off again. The strange thing is, that e.g. I have turned it on, it gets automatically turned off 20-30sec later and turned on again after the same time.

I executed my script without openhab and this is not the cause of this.

Hopefully someone has an idea :slight_smile:
Thanky You so far!

Could it be there is a loop defined ?
this could be for 2 reasons.
You press 1 button but actually 2 things trigger the script.
Some sort of loop inside your script ?

do you have 1 script for on and 1 script for off?
What exec binding version you use ?

Not that I´m aware of - this is the content of my scrip:

#!/bin/sh
curl --request POST --header "Content-Type: application/xml" --data ' <key state="press" sender="Gabbo">'$1'</key> ' http://192.168.0.10:8090/key
curl --request POST --header "Content-Type: application/xml" --data ' <key state="release" sender="Gabbo">'$1'</key> ' http://192.168.0.10:8090/key
exit 0

The script is not behaving like this if a call it directly like: sh test.sh POWER

I installed the exec binding via the PaperUI, therefore I think it should be 2.0

Have you checked the eventlog (/var/log/openhab2/event.log) to see what actually happens with ST which might explain this behaviour

That´s a good hint - I can see that events get triggered without me doing something:

2017-09-08 11:23:07.559 [ItemStateChangedEvent     ] - Date_Time changed from 2017-09-08T11:22:07.537+0200 to 2017-09-08T11:23:07.537+0200
2017-09-08 11:23:15.492 [ItemStateChangedEvent     ] - ST changed from OFF to ON
2017-09-08 11:23:21.802 [ItemStateChangedEvent     ] - ST changed from ON to OFF
2017-09-08 11:24:07.557 [ItemStateChangedEvent     ] - Date_Time changed from 2017-09-08T11:23:07.537+0200 to 2017-09-08T11:24:07.537+0200
2017-09-08 11:24:21.814 [ItemStateChangedEvent     ] - ST changed from OFF to ON
2017-09-08 11:24:28.121 [ItemStateChangedEvent     ] - ST changed from ON to OFF

I found a workaround that is fine for me:

rule Test
when
  Item ST received command ON
then
  executeCommandLine("/etc/openhab2/scripts/test.sh POWER")
end

Thanks for your help!

I actually ran into the same issue and asked for some help here and after more fiddling found that the solution was to add interval=0 to the end of the thing entry. Included is an example from my own things file.

Thing exec:command:TVON [command="sudo /Scripts/TVON.sh", interval=0, timeout=10, autorun=false]