We have moved at community.getvera.com

Author Topic: Group Sonos players? Party Mode? then restore previous mode...  (Read 21054 times)

Offline big517

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 576
  • Karma: +1/-4
Group Sonos players? Party Mode? then restore previous mode...
« on: December 12, 2012, 11:19:28 am »
Hello All,

I have 2 Sonos systems now.
I have a scene that plays a file when someone approaches the home.
The problem is that I cannot play across both zones unless I happen to have selected the first zone as the source, then Grouped the other zone.

So, if someone changes the 2nd zone, that zone will never receive the alert.  I've tried to run the scene to duplicate the actions across both zones, but it seems to stop playback (maybe acessing same file?)

I'm thinking a solution would be to Save the mapping of players and playback info, Group the players, play the file on the master, then restore the Mapping and Playback context. 

Is that possible?  I'm looking at some of the options in the plugin events and I see something about manage with source, but there is a lot of data that needs to filled in and i'm not too familiar with that yet.  Anyone know the answer on how to do this?

Thanks,

Offline MikeT

  • Sr. Newbie
  • *
  • Posts: 30
  • Karma: +1/-0
Re: Group Sonos players? Party Mode? then restore previous mode...
« Reply #1 on: December 13, 2012, 02:26:24 pm »
Good idea, sounds like we need some kind of 'broadcast' function...I have three rooms covered by Sonos systems so this definitely makes sense as a requirement!

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Group Sonos players? Party Mode? then restore previous mode...
« Reply #2 on: December 16, 2012, 01:38:59 pm »
Grouping them prior is fairly easy, restoring everything afterwards would require some work.

Each Sonos has a unique "address" of sorts.  It looks like:
     x-rincon:RINCON_000E5....01400

where the last part is basically the MAC address concatenated to "1400" (the Port used for commands).  You'll see something like this value in the Advanced section, under "SonosID".

As an example, let's say I have Sonos units called "Master" and "Portable".  If I want "Master" to play the stuff currently playing on "Portable", then I issue a Scene command like the attached screenshot.

This tells the "master" unit to play (join) the "Portable" unit (using it's unique address).


@lolodomo: If we wanted to make this part of "Say", then we'd need  a parameter that lists the SonosID's to group-prior, and restore-after.  This could be more generally useful if we had a "playOne" type call, that behaved similarly... for those wanting to play a Warning [MP3/WAV] Tone, then restore context also.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Group Sonos players? Party Mode? then restore previous mode...
« Reply #3 on: December 23, 2012, 06:17:53 am »
@lolodomo: If we wanted to make this part of "Say", then we'd need  a parameter that lists the SonosID's to group-prior, and restore-after.  This could be more generally useful if we had a "playOne" type call, that behaved similarly... for those wanting to play a Warning [MP3/WAV] Tone, then restore context also.

There is apparently two different needs:
1 - addressing TTS to all Sonos
2 - restoring grouping after TTS

For the first point, we could use your solution, meaning stopping the playback on the desired Sonos, then asking all others Sonos to play the same thing as this Sonos, and finally play the Google file.
We need a new parameter to choose between the targetted Sonos or all Sonos.

For the second point, that's doable, but that would require when saving the playback context to interrogate all Sonos to check if they are "grouped" with the Sonos that we ask to say something. In fact, we would have to store, save and restore the playback context of several zones.

That's an interesting subject but until I buy a second Sonos unit, unfortunately I cannot really help you.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Group Sonos players? Party Mode? then restore previous mode...
« Reply #4 on: December 23, 2012, 06:23:18 am »
When a Sonos is grouped to a master one, I am curious to know what we got in all our variables for the "slave" unit ?
I imagine we loose media information for example if the meta data are not filled ? If true, we could get them from the other Vera device.

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Group Sonos players? Party Mode? then restore previous mode...
« Reply #5 on: December 23, 2012, 12:29:35 pm »
I'd imagine we'd call_action on each Sonos unit to have it save its context, so they'd each do it themselves.  Then execute the grouping action, then Say (or more generally PlayOne for one off 'Siren' MP3s)

Afterwards we'd need to do the same for restore.... Basically telling each Sonos to restore itself by calling it via call_action.

I'll give it a go after Christmas sometime.

Offline big517

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 576
  • Karma: +1/-4
Re: Group Sonos players? Party Mode? then restore previous mode...
« Reply #6 on: December 24, 2012, 09:04:57 am »
I noticed you can originate media playing on the master, then group the slave so both are playing, then ungroup the master leaving the slave playing whatever you originally queued up for the Master and allow the master free to play whatever you want.  Once it's done playing you can re-group the original playlist or radio station and not have to restart a new track on pandora because it was never "stopped".

This makes me think of a solution to pause and resume media that cannot be resumed such as pandora, and this may be a workaround....

Theoretically if we could create a phantom sonos on the system it may be cleaner and faster to simply group (transfer) the information to the phantom sonos which will not lose the pandora or other internet media connection.  Play the TTS or announcement file on the main sonos or group, then re-group all sonos systems and continue / resume play without losing the track.

this was my thought when I originally started this post because it seemed to be the solution to interrupt Pandora without having to start a new track and deal with the delays involved.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Group Sonos players? Party Mode? then restore previous mode...
« Reply #7 on: December 27, 2012, 07:13:41 am »
I'd imagine we'd call_action on each Sonos unit to have it save its context, so they'd each do it themselves.  Then execute the grouping action, then Say (or more generally PlayOne for one off 'Siren' MP3s)

Afterwards we'd need to do the same for restore.... Basically telling each Sonos to restore itself by calling it via call_action.

I'll give it a go after Christmas sometime.

That's a good idea. But isn't call_action asynchronous, meaning it returns before the action is really executed ?
« Last Edit: December 27, 2012, 07:20:36 am by lolodomo »

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Group Sonos players? Party Mode? then restore previous mode...
« Reply #8 on: December 27, 2012, 07:19:20 am »
Theoretically if we could create a phantom sonos on the system it may be cleaner and faster to simply group (transfer) the information to the phantom sonos which will not lose the pandora or other internet media connection.  Play the TTS or announcement file on the main sonos or group, then re-group all sonos systems and continue / resume play without losing the track.

this was my thought when I originally started this post because it seemed to be the solution to interrupt Pandora without having to start a new track and deal with the delays involved.

Unfortunately, creating a phantom Sonos is certainly very complex, maybe simply impossible.
But you may use a real Sonos unit, one currently unused, setting its volume to 0.

Offline big517

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 576
  • Karma: +1/-4
Re: Re: Group Sonos players? Party Mode? then restore previous mode...
« Reply #9 on: December 29, 2012, 06:43:30 am »

Quote
.
But you may use a real Sonos unit, one currently unused, setting its volume to 0.

Can this be done via advanced scene setup?


 2


Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Re: Group Sonos players? Party Mode? then restore previous mode...
« Reply #10 on: December 29, 2012, 07:13:18 am »

Quote
.
But you may use a real Sonos unit, one currently unused, setting its volume to 0.

Can this be done via advanced scene setup?

Setting the volume ? Yes, of course.

For the full scenario, you are the guy who explained how to do it:

Quote
I noticed you can originate media playing on the master, then group the slave so both are playing, then ungroup the master leaving the slave playing whatever you originally queued up for the Master and allow the master free to play whatever you want.  Once it's done playing you can re-group the original playlist or radio station and not have to restart a new track on pandora because it was never "stopped".

You did it with a Sonos control application or with the Vera ?

Offline big517

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 576
  • Karma: +1/-4
Re: Group Sonos players? Party Mode? then restore previous mode...
« Reply #11 on: December 29, 2012, 08:23:03 am »
I did it with the Sonos Application on my iPad.  I'm just trying to figure out how to emulate that scenario with the functions we have available in the plugin.


Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Group Sonos players? Party Mode? then restore previous mode...
« Reply #13 on: December 29, 2012, 09:17:44 pm »
That's a good idea. But isn't call_action asynchronous, meaning it returns before the action is really executed ?
Whether it's sync or async across the channels it won't really matter as long as it's serial within a given [Sonos] device.

Basically the "initiator" device's Say method would logically do something akin to:

Code: [Select]
initiator.savePlaybackContext
store the list of remote Sonos devices
forEach remote Sonos device...
    remote.call_action(SavePlaybackContext)
    remote.call_action(SetAVTransport... initiator SonosID)
end
StartAutoPlay code...
initiator.call_delay(stopSay)
and then later, in stopSay on the "initiator" device...

Code: [Select]
restore the list of remote Sonos devices
forEach remote Sonos device...
    remote.call_action(RestorePlaybackContext)
end
initiator.restorePlaybackContext

It won't be perfect, since the "tracking" stuff you recently added will be local only to the initiator.  As a result, there's a possibility of things getting out of sync if a "Say" were initiated across multiple nodes concurrently... but it should be good enough. 

It'll take me a while to get the exact combo, but it should be something like the above... time will tell.  Hopefully this will spread the state-management burden across the various Sonos devices somewhat  ;-)

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Group Sonos players? Party Mode? then restore previous mode...
« Reply #14 on: December 30, 2012, 03:54:13 pm »
Ok, this is now implemented in the Say action.  I've added a new "Devices" parameter.  If present, it represents a CSV list of deviceId's of other Sonos units that should be included during the save-say-restore model of the Say command.

As a Lua snippet it would look like:
Code: [Select]
luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Say",
                 {Text="Welcome Home", Devices="667,668"}, 666)

This would instruct Sonos device "666" to say "Welcome Home", and during the execution the two other Sonos units (667 & 668) would follow whatever 666 is doing.  They'll all [separately] restore to whatever they were doing at the end.

I'll add some doco for this action to the Sonos Web/Wiki page.



We can use these techniques to eventually build out a similar, parallel, method for firing off "one-off" MP3's (sound files) per the original request (for alarms and such).... The main difference there being we don't know how long these files are, so the "restore" part of the work will need a timeout parameter.