Sonos sitemap status update?

Hi there,

I’m a newbie to openHab, so please bear with me in case this is a trivial question.
I’ve openHab running fine one my home server and successfully added my Hue as well as my Sonos speakers. Selecting a radio station or a favourite, adjusting the volume, etc. is working just fine from my openHab app on Android as well as on iOS.
There’s only one little flaw though: In case a speaker is switched on e.g. by using the Sonos app or the button on the speaker itself and the openHab app is started afterwards, the status switch is still deactivated. You can then activate it (no effect) and deactivate it again (speaker turns off properly). Do you experts happen to have an idea if there is a possibility to solve this in order to have the “power” switch in the app reflecting the actual status of the speaker?

These are the corresponding item entries:

Switch Sonos_Diningroom_Power             "Ein/Aus"                             <power>            {sonos="[ON:diningroom:play], [OFF:diningroom:stop]"}
Switch Sonos_Bathroom_Power             "Ein/Aus"                             <power>            {sonos="[ON:bathroom:play], [OFF:bathroom:stop]" }

And these are the sitemap entires:

Switch item=Sonos_Diningroom_Power
Switch item=Sonos_Bathroom_Power

In case you need anything else from me, please let me know. Many thanks in advance for your help!

There is still an open feature request for that:

Edit: maybe this is a a workaround for you:

Hi sihui,

many thanks for your response and for the workaround hint! I must have overseen there’s already been a thread opened for this - Huge sorry from my side!
How exactly does this workaround have to be applied? Is this a rule where you say something like “When item state changes to OFF, also switch the button to OFF”? Would somebody mind posting a small example snippet of how it has to be implemented? Again, sorry if this is a stupid request and many thanks for the great support!

Hi there,

just to let you know: I’ve meanwhile managed to achieve a working solution on basis of what @sihui has digged out (many thanks once again). This is my items:

Switch Sonos_Diningroom_Power             "Ein/Aus"                             <power>            {sonos="[ON:diningroom:play], [OFF:diningroom:stop]"}
String Sonos_Diningroom_Transportstate  "Status [%s]"                                        {sonos="[diningroom:transportstate]"}
Switch Sonos_Bathroom_Power             "Ein/Aus"                             <power>            {sonos="[ON:bathroom:play], [OFF:bathroom:stop]" }
String Sonos_Bathroom_Transportstate      "Status [%s]"                                        {sonos="[bathroom:transportstate]"}

Here’s the rules:

rule "Sonos status change on"
    when
        Item Sonos_Diningroom_Transportstate received update PLAYING
    then
            sendCommand(Sonos_Diningroom_Power, ON)
end

rule "Sonos status change off"
    when
        Item Sonos_Diningroom_Transportstate received update STOPPED
    then
            sendCommand(Sonos_Diningroom_Power, OFF)
end

And this is the sitemap (quite simple, nah?):

Switch item=Sonos_Diningroom_Power
Text item=Sonos_Diningroom_Transportstate
Switch item=Sonos_Bathroom_Power
Text item=Sonos_Bathroom_Transportstate

When starting/stopping one of the sonos speakers from e.g. the Sonos app, both the according switch as well as the status text will update appropriately on the frontend.

I’ve thereby achieved what I was aiming at and maybe this snippets can help someone who’s stuck at the same point. In case of any questions, don’t hesitate to ask. Cheers!