Rule based on String not working, need help :-(

(Thomas Kranz) #1

Hi,

I want to create a rule based on Stings received from Harmony hub, but the rule doesn’t work.

here the rule:

rule “TV on"
when
Item Harmonyactivity changed to “Fernsehen"
then
executeCommandLine(”/srv/openhab2-conf/scripts/tv_control.sh on 1”)
end

rule “TV off"
when
Item Harmonyactivity changed to “PowerOff"
then
executeCommandLine(”/srv/openhab2-conf/scripts/tv_control.sh off 1”)
end

in the events i see the following :slight_smile:

2017-10-13 11:49:48.173 [vent.ItemStateChangedEvent] - Harmonyactivity changed from NULL to PowerOff
2017-10-13 11:52:27.509 [vent.ChannelTriggeredEvent] - harmonyhub:hub:Kino:activityStarting triggered Fernsehen
2017-10-13 11:52:31.048 [vent.ChannelTriggeredEvent] - harmonyhub:hub:Kino:activityStarted triggered Fernsehen
2017-10-13 11:52:31.061 [vent.ItemStateChangedEvent] - Harmonyactivity changed from PowerOff to Fernsehen
2017-10-13 11:52:45.048 [vent.ChannelTriggeredEvent] - harmonyhub:hub:Kino:activityStarting triggered PowerOff
2017-10-13 11:52:46.840 [vent.ChannelTriggeredEvent] - harmonyhub:hub:Kino:activityStarted triggered PowerOff
2017-10-13 11:52:46.860 [vent.ItemStateChangedEvent] - Harmonyactivity changed from Fernsehen to PowerOff
2017-10-13 11:52:56.951 [vent.ChannelTriggeredEvent] - harmonyhub:hub:Kino:activityStarting triggered Fernsehen
2017-10-13 11:53:00.517 [vent.ChannelTriggeredEvent] - harmonyhub:hub:Kino:activityStarted triggered Fernsehen
2017-10-13 11:53:00.539 [vent.ItemStateChangedEvent] - Harmonyactivity changed from PowerOff to Fernsehen
2017-10-13 11:53:06.397 [vent.ChannelTriggeredEvent] - harmonyhub:hub:Kino:activityStarting triggered PowerOff
2017-10-13 11:53:13.045 [vent.ItemStateChangedEvent] - Harmonyactivity changed from Fernsehen to PowerOff

but it doesn’t trigger the script :frowning:

please help.
thanks
Thomas

0 Likes

(HomeAutomation) #2

I think you should try it without brackets? This syntax is used by switches and contact? Maybe here too?

Because of: Harmonyactivity changed from NULL to PowerOff

and not: Harmonyactivity changed from NULL to “PowerOff”

0 Likes

(Thomas Kranz) #3

Thanks, that worked :slight_smile:

the script is executed according the openhab.log but nothing happens on TV, if i run it manually in shell
it works perfekt…

Any idea ?

thanks
Thomas

0 Likes

(HomeAutomation) #4

puh, I’m not a linux freak. Try some debug in your tv_control.sh.

Write form “tv_control.sh” into a log file what the script gets and compare if this is the same as if you send the same via command line ot the script.

Maybe there is a difference. Or the script will never started because of access writes or syntax of the line "/srv/openhab2-conf/scripts/tv_control.sh off 1”

Just a hint, not sure.

0 Likes

(Jürgen Baginski) #5

You might be running the script manually using a different user then OH is running at.
So look into the access rights of your file.

0 Likes

(Rich Koshak) #6
0 Likes