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

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

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”

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

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.

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.