howto Sonos Multi-Room Features

612 views
Skip to first unread message

Jens Kluge

unread,
Jul 11, 2014, 12:13:47 PM7/11/14
to ope...@googlegroups.com
Hi Karl,
I just stumbled into your thread which sounds really interesting and instead of hijacking it I thought let's better open a new one.

I would be more than interested to control multi room features of sonos with openhab.

I do have some (more) sonos devices.... sonos TV (2xplay1 stereo), sonos living (2xplay5 stereo)

Following would be my use case I would like to implement:

NOW - current solution -----------
TV switched ON:
* sonos living goes on mute
* sonos tv starts play and unmute
* whatever is selected will be played at whatever volume, etc.
TV switched OFF:
* sonos living starts to play
* sonos living goes on mute
* whatever is selected on sonos living will be played at whatever volume

NEW -- like to have --------------------

TV switched ON:

* play tv audio on sonos tv (play1) which is feeded into sonos living (including change of imput to line-in)
* save sonos living state
* The actual state of the sonos living shall be saved and Sonos living shall play same sound and volume level of sonos TV
TV switched OFF:
* restore sonos living state, e.g. track/radio and volume
* The actual state of the sonos living shall be saved and Sonos TV shall play same sound and volume level of sonos living

Additional functionality:

Group living:
* Virtual Switch to group sonos tv and sonos living
* play same on sonos tv what is on sonos living

Group tv:
* Virtual Switch to group sonos tv and sonos living
* play same on sonos lviing what is on sonos tv

De-Group:
* Virtual Switch to de-group sonos tv and sonos living
* restore and play only sonos living


Following is my (NOW) configuration for this:

rules:

rule "Select switch on sonos tv if tv is switched on"
    when
        Item TV_GF_Living received command
    then
            switch (receivedCommand)
        {
            case ON:  {
                sendCommand(SO_Living_Mute, "ON")
                sendCommand(SO_TV_Mute, "OFF")
            }
            case OFF: {
                sendCommand(SO_Living_Mute, "OFF")
                sendCommand(SO_TV_Mute, "ON")
            }
        }
    end


items:

Switch TV_GF_Living "TV" <video> (GF_Living, Switches) {homematic="address=KEQxxxxxx, channel=1, parameter=STATE"}

sitemap:

Switch item=TV_GF_Living  
 



While I do look at the example below, I currently have some blocking points to see how I can implement my new funktionality. Especially the function "select line" and play on grouped devices, as well as grouping devices is something I have not understood.

Therefore any hints how to implement that are welcome

Best, Jens


Am 10.07.2014 08:46, schrieb Karel Goderis:
hi Joe,

The multi-room features are part of how Sonos works, so you can link a source to a Sonos device, and then distribute that to any other Sonos device you have. Below is how I implement the doorbell in my house:

in .rules:

rule DoorbellPracticeRule
when
Item DoorbellPractice changed to ON
then
stateSwitches.sendCommand(ON)
Thread::sleep(1000)
volumes.sendCommand(50)
SonosURIs.sendCommand("guestbathroom")
playSound("doorbellpractice.mp3")
stateSwitches.sendCommand(OFF)
end

in .items:


Switch practiceSwitch (stateSwitches) {sonos="[ON:practice:save],[OFF:practice:restore]"}
Switch masterbathroomSwitch (stateSwitches) {sonos="[ON:masterbathroom:save],[OFF:masterbathroom:restore]"}
Switch diningroomSwitch (stateSwitches) {sonos="[ON:diningroom:save],[OFF:diningroom:restore]"}
...

and 

Dimmer diningroomVolume (volumes) {sonos="[diningroom:volume], [INCREASE:diningroom:volume], [DECREASE:diningroom:volume]", knx="5.001:5/2/5,3.007:5/2/4"}
....

and 

String practiceURI "URI is [%s]" (SonosURIs) {sonos="[practice:playline]"} 
String masterbathroomURI "URI is [%s]" (SonosURIs) {sonos="[masterbathroom:playline]"}
String diningroomURI "URI is [%s]" (SonosURIs) {sonos="[diningroom:playline]"}
....

to be complete, the "guestbathroom" sonos player happens to be the instance that is connected to my openHAB host line-out (all my Sonos players are in  a 19" rack in the basement, I just happened to pick one at random to connect to my OH host). In short, the script stores the actual state of the Sonos's in the house, then sets the volume on all devices, make them connect to the line-in of the guestbatrhoom player (e.g .OH host), play the doorbell.mp3 file on the OH host, and finally restore all the previously stored states (so that a player playing your favorite playlist will return to doing that after that the doorbell.mp3 is played)

The same can be achieved also by first grouping all the players into a single group (a sonos feature), and then have that group play the line-in of the guestbatrhoom device. Grouping is also a sonos feature whereby a single source of music is "synced" accross a number of devices

Karel Goderis

unread,
Jul 12, 2014, 7:12:08 AM7/12/14
to ope...@googlegroups.com
Jens

With the introduction of the Playbar Sonos has changed/added  some specific functionalities to group and ungroup players that are related to playing TV audio. When you switch on a TV, then the connected Playbar (if you have any, but it is in my case) creates a special Group of sonos players (in casu, the Sub and the back Play:1 players) on which TV audio is played. At this point in time I have not yet investigated how Sonos does this switch over. This special group of devices shows up as a single player in the Sonos Controller, and has an new kind of Music Source ("TV") which can be selected. 

If you do not intend to use the TV-playing features of Sonos, but rather instead DIY and depend on the line-out features of your TV to feed the sonos, then you maybe achieve the same with a ruleset. 

To group players, you can use the "add" and "remove" commands

String baseOfGroup   {sonos="[RINCON_000E581369DC1234:add]"}

if you sendCommand(someID) to the baseOfGroup String Item, with someID the ID (could be both the Item name or the RINCON string If I remember well) of the player to be added, then the someID is added to the group of player RINCON_000E581369DC1234

When you switch off your TV, then you do the same with the "remove" command to remove the someID player from the formed group.

For storing/retrieving states, pls see the thread on the doorbell example of a few days ago

Regards
Karel

--
You received this message because you are subscribed to the Google Groups "openhab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/d/optout.

Joe Barneson

unread,
Jul 12, 2014, 8:26:08 AM7/12/14
to ope...@googlegroups.com
These are really interesting ideas and starting to make me think the price for SONOS is worth it.

I'm curious the experience you've had with SONOS and sync of audio between different units. Particularly the line in. If we were to use one of the SONOS unit's line in from the output of my tv, would my whole house audio be in sync enough to hear the show/game we're watching from room to room and stay in sync without lag?

Jens Kluge

unread,
Jul 12, 2014, 9:18:12 AM7/12/14
to ope...@googlegroups.com
Hi Karel,


On Saturday, July 12, 2014 1:12:08 PM UTC+2, karel....@me.com wrote:
Jens

With the introduction of the Playbar Sonos has changed/added  some specific functionalities to group and ungroup players that are related to playing TV audio. When you switch on a TV, then the connected Playbar (if you have any, but it is in my case) creates a special Group of sonos players (in casu, the Sub and the back Play:1 players) on which TV audio is played.

Do not have a Playbar (yet) and also not Sub (yet).

Insteady I do use 2xPlay1 (rear grouped as left/right) and 2xPlay5 (front grouped left/right) and want to add that into one group as described above. I have no intend to use any suround etc. just stereo is sufficient for my ears :)

At this point in time I have not yet investigated how Sonos does this switch over. This special group of devices shows up as a single player in the Sonos Controller, and has an new kind of Music Source ("TV") which can be selected. 
 
My guess is that the specific functionality of the Playbar could be used for the other players as well

To group players, you can use the "add" and "remove" commands

String baseOfGroup   {sonos="[RINCON_000E581369DC1234:add]"}
 
if you sendCommand(someID) to the baseOfGroup String Item, with someID the ID (could be both the Item name or the RINCON string If I remember well) of the player to be added, then the someID is added to the group of player RINCON_000E581369DC1234

So from what I understood I try to create above item for Sonos TV and afterwards use sendCommand(Sonos_living_ID) to add/Remove from group.
Will try and publish in that thread later on.

When you switch off your TV, then you do the same with the "remove" command to remove the someID player from the formed group.
sounds logical.. will try.

For storing/retrieving states, pls see the thread on the doorbell example of a few days ago
Already dived into it and this is a really interesting feature you can stop playing sound, have some "jingles" in between and afterwards just retrieve and proceed with earlier sound. At least that is my understanding as long as I have not implemtented it. Will definetly try

Regards
Karel

Many thanks Karel
Best
Jens

Karel Goderis

unread,
Jul 12, 2014, 1:09:33 PM7/12/14
to ope...@googlegroups.com
Yes. There hardware is truly fantastic. We use the line-in/multi-room feature all the time. As "candy" factor I was thinking of implementing a follow-me feature whereby music would follow me through the house using the PIR detectors I have everywhere....

Beware, the implementation of the Sonos procotol in the OH binding is far from complete - it is reverse engineering and still needs some debugging etc to be perfect...

K

Beat Graf

unread,
Aug 6, 2014, 3:02:50 PM8/6/14
to ope...@googlegroups.com
Hi Karel

I didn't know how to contact you on a different way.
As I've seen, you have developed the Sonos binding. So you are experienced in programminh Upnp devices.

I wanted to ask, if you were interested in programming a binding for Linn Digital Streamers.

For more information just look here : www.linn.co.uk
There is also a good documentation on www.openhome.org

Just let me know if you are interested. I could help you with the needed hardware for testing.

Regards
Beat

Karel Goderis

unread,
Aug 7, 2014, 3:38:53 AM8/7/14
to ope...@googlegroups.com
Beat

The short answer would be no as I have no intention to invest in their solution/hardware (I am  on Sonos), but I share an interest in the UPNP part. That being said, cfr Eclipse Smarthome project (and openHAB 2.0, on top of that), UPNP most likely will be part of the "core" and thus I would wait for that to materialise before starting to develop UPNP-based code

Kind Regards
Karel
Reply all
Reply to author
Forward
0 new messages