This page last changed on Dec 28, 2014 by nicokluin.

I am puzzled with probably a simple problem. I would like to use a KNX switch to change a Sonos speaker favorite. And Yes, I have problems mastering the rule language.

The situation:

  • at the start of OpenRemote I will set the channel ('favorite' on jishi's node-sonos-http-api) of the Sonos speaker to Skyradio and remember this in a virtual command as text; eg 'SKY'.
  • KNX switch which I can use as a trigger, so either on 'ON' or 'OFF' it will trigger the same rule.
  • On triggering the rule based on a change of the KNX switch I would like to check the current channel (in the virtual command) and change to the 'next'.
  • The 'next' channel would be rotating channels: Skyradio -> Slam!FM -> Q-Music -> Skyradio -> etcetera...

The problem:
I combined the KNX trigger with the remembered channel and then would like to change the channel. This code will NOT work... it goes into a loop, off course

rule "SonosShiftChannelToSky"
   ( Event (source == "SonosSwitchSensor", value == "on") OR Event (source == "SonosSwitchSensor", value == "off") and
     Event (source == "SonosRememberedChannel", value == "SKY") )
   execute.command("SonosRememberedChannel", "SLAM");

rule "SonosShiftChannelToSlam"
   ( Event (source == "SonosSwitchSensor", value == "on") OR Event (source == "SonosSwitchSensor", value == "off") and
     Event (source == "SonosRememberedChannel", value == "SLAM") )
   execute.command("SonosRememberedChannel", "SKY");

The above rules will be extended with extra rules to change between more channels. How do I need to change this rules to be able to shift the channels on the KNX trigger?

Document generated by Confluence on Jun 05, 2016 09:37