OH2 - Rule to PAUSE and PLAY Sonos do not work

I try to create a rule to pause and play a sonos device using wireless switch.

I’m using the same rule for turning on and off lights, and that is working OK.

Shouldn’t this work?

rule "SonosToalett"
	Item E1_Toalett_Bryter_Venstre_Contact changed
	if (E1_Toalett_Bryter_Venstre_Contact.state == OPEN) {
	if (E1_Toalett_Bryter_Venstre_Contact.state == CLOSED) {

Looks good… what happens in the log when the rule is triggered? How are the two items defined?

I can see the switch event, but nothing in the log from the sonos binding

2017-01-03 21:49:59.828 [ItemStateChangedEvent     ] - K1_Toalett_Bryter_Venstre_Contact changed from OPEN to CLOSED

If I use the same script but trigger a light - everything is working OK.

The Sonos item uses the control channel and are defined as a “player”


For the Player item there should also be an entry in the log, like this:
2017-01-03 18:59:48.223 [ItemStateChangedEvent ] - LVPanasonicAll30Control changed from PLAY to PAUSE

What happens if you insert a log as the first line of the rule? Like this:
logWarn("SonosToalett.rule", "SonosToalett rule has been triggered")

Are your items defined in a *.items file or directly via PaperUI?
Do you maybe have two rules with the same name? This also causes trouble in my experience.

Nothing in the log if I insert a log…

The items are defined using the PaperUI.

I don’t have two rules with the same name.

Seems like the rule is not called if even the logWarn is not displayed in the logs. Then again, the rule works if you trigger a light… what happens if you trigger a light and put the logWarn into the first line?
I guess you know there are two log files, the openhab.log and the events.log. Make sure to check the openhab.log for the manually inserted log statements.

Maybe a problem with your Sonos items? Do they work in a sitemap? What does the item file entries look like?

I have defined them using the PaperUI.

If I control the Sonos from the openHAB app on the phone (and I guess its using a default sitemap then) I able to control it without problems.