Sonos Say API use help

Good morning,

I am really enjoying the Sonos plugin with my Vera Edge. I would like to ask a few questions about the Say facility.

I’d like to get a definitive understanding of the relationship between GroupZones and Device ID (the last parameter you pass).

If I have some Sonos speakers, where Zone “Study” is Vera device 4 and Zone “Kitchen” is Vera device 5 and I use Say with GroupZones=“Study,Kitchen” and the last parameter being 4, then I get sound only in the Study.

If I make the last parameter 5, then I get sound in both the Study and the Kitchen.

If I change the order of GroupZones to be “Kitchen,Study” and leave the last parameter as 5, then sound is heard in both Zones… if I change the last parameter back to 4, sound is only heard in the Study again.

Is there a way of sending a Say command to multiple Sonos speakers by just using GroupZones and ignoring the last device ID parameter? I tried -1, 0 and nil but nothing resulted in anything being heard.

If GroupZones has a number of Zones listed, it’s seeming like the last parameter has to be the highest device ID of any Zone listed? In my case, if the Zones refer to Sonos devices 4 and 5, as long as my last parameter is 5 I get sound in both Zones, if it’s 4 then I get sound only in the Study, regardless of what’s listed in GroupZones and whether the Zone that relates to device 5 is listed or not.

If I am missing something very obvious, please tell me. :slight_smile:

This plays sound only in the Study (4):

[font=courier]luup.call_action (“urn:micasaverde-com:serviceId:Sonos1”,“Say”,{Text=“Zones Test”,Language=“en”,Volume=40,SameVolumeForAll=“true”,GroupZones=“Study,Kitchen”},4)[/font]

This plays sound in Study (4) and Kitchen (5):

[font=courier]luup.call_action (“urn:micasaverde-com:serviceId:Sonos1”,“Say”,{Text=“Zones Test”,Language=“en”,Volume=40,SameVolumeForAll=“true”,GroupZones=“Study,Kitchen”},5)[/font]

This plays sound only in the Study (4):

[font=courier]luup.call_action (“urn:micasaverde-com:serviceId:Sonos1”,“Say”,{Text=“Zones Test”,Language=“en”,Volume=40,SameVolumeForAll=“true”,GroupZones=“Kitchen,Study”},4)[/font]

This plays sound in Study (4) and Kitchen (5):

[font=courier]luup.call_action (“urn:micasaverde-com:serviceId:Sonos1”,“Say”,{Text=“Zones Test”,Language=“en”,Volume=40,SameVolumeForAll=“true”,GroupZones=“Kitchen,Study”},5)[/font]

[quote=“Hippogriff, post:1, topic:187628”]Good morning,

I am really enjoying the Sonos plugin with my Vera Edge. I would like to ask a few questions about the Say facility.

I’d like to get a definitive understanding of the relationship between GroupZones and Device ID (the last parameter you pass).

If I have some Sonos speakers, where Zone “Study” is Vera device 4 and Zone “Kitchen” is Vera device 5 and I use Say with GroupZones=“Study,Kitchen” and the last parameter being 4, then I get sound only in the Study.

If I make the last parameter 5, then I get sound in both the Study and the Kitchen.

If I change the order of GroupZones to be “Kitchen,Study” and leave the last parameter as 5, then sound is heard in both Zones… if I change the last parameter back to 4, sound is only heard in the Study again.[/quote]

My intuitive analysis would be that your Sonos zone is not really named “Kitchen” and so the plugin is not able to to identify a zone with this name. Check that you don’t have a leading or ending space or that the name is not kitchen rather than Kitchen.

Displaying the value of the variable ZoneGroupState could help the analysis.
luup.log(luup.variable_get(“urn:schemas-upnp-org:service:ZoneGroupTopology:1”, “ZoneGroupState”, 4))

Is there a way of sending a Say command to multiple Sonos speakers by just using GroupZones and ignoring the last device ID parameter? I tried -1, 0 and nil but nothing resulted in anything being heard.

No because any Vera command has to be sent to a device, this device being identified by this id.
Plus in our context, this device is the master of the group that will be created.

[quote=“Hippogriff, post:1, topic:187628”]If GroupZones has a number of Zones listed, it’s seeming like the last parameter has to be the highest device ID of any Zone listed? In my case, if the Zones refer to Sonos devices 4 and 5, as long as my last parameter is 5 I get sound in both Zones, if it’s 4 then I get sound only in the Study, regardless of what’s listed in GroupZones and whether the Zone that relates to device 5 is listed or not.

If I am missing something very obvious, please tell me. :)[/quote]

No, that is not the case.

As an additional note, the zone identified by the device id will be the master of the created group, and zones listed in GroupZones will be additional members of this group.

[quote=“lolodomo, post:2, topic:187628”]My intuitive analysis would be that your Sonos zone is not really named “Kitchen” and so the plugin is not able to to identify a zone with this name. Check that you don’t have a leading or ending space or that the name is not kitchen rather than Kitchen.

Displaying the value of the variable ZoneGroupState could help the analysis.
luup.log(Luup.variable_get(“urn:schemas-upnp-org:service:ZoneGroupTopology:1”, “ZoneGroupState”, 4))[/quote]

It must be “Kitchen” surely? Otherwise I wouldn’t get it to play at all, whereas it does in some of the scenarios I showed above?

Anyway, I will try whatever you would like me to - where would I put this code? “luup.log(Luup.variable_get(“urn:schemas-upnp-org:service:ZoneGroupTopology:1”, “ZoneGroupState”, 4))” - I can’t put it in the test LUA area, can I? It says “code failed”… if you enlighten me I can give it a shot. Appreciate the guidance.

No, you should have exactly the behaviour you have if you used a wrong zone name.

Anyway, I will try whatever you would like me to - where would I put this code? "luup.log(Luup.variable_get("urn:schemas-upnp-org:service:ZoneGroupTopology:1", "ZoneGroupState", 4))" - I can't put it in the test LUA area, can I? It says "code failed"... if you enlighten me I can give it a shot. Appreciate the guidance.

luup in lowercase.

Is Kitchen zone your pair of Play:1 ?

Unfortunately, my plugin is known as not working very well with pairs. That could explain your result. You have to know that it could even lead to a “break” of your pair (unpairing). You can find few discussions on the forum about this “problem” and you can even find that I tried to do my best to support pairs with apparently no success.

OK, I’ve done some more testing with 2 Zones - one named “Study” device #4, one named “DpM’s Bedroom” device #5 (this Zone is also a Pair of Play:1s so we are talking about 3 physical speakers in all).

This code speaks in both Zones (and all 3 speakers):
[font=courier]luup.call_action (“urn:micasaverde-com:serviceId:Sonos1”,“Say”,{Text=“Test”,Language=“en”,Volume=40,SameVolumeForAll=“true”,GroupZones=“Study,DpM’s Bedroom”},5)[/font]

This code also speaks in both Zones (and all 3 speakers):
[font=courier]luup.call_action (“urn:micasaverde-com:serviceId:Sonos1”,“Say”,{Text=“Test”,Language=“en”,Volume=40,SameVolumeForAll=“true”,GroupZones=“Study,DpM%27s%20Bedroom”},5)[/font]

This code only speaks in the Study:
[font=courier]luup.call_action (“urn:micasaverde-com:serviceId:Sonos1”,“Say”,{Text=“Test”,Language=“en”,Volume=40,SameVolumeForAll=“true”,GroupZones=“Study,DpM’s Bedroom”},4)[/font]

This code also only speaks in the Study:
[font=courier]luup.call_action (“urn:micasaverde-com:serviceId:Sonos1”,“Say”,{Text=“Test”,Language=“en”,Volume=40,SameVolumeForAll=“true”,GroupZones=“Study,DpM%27s%20Bedroom”},4)[/font]

This is not intuitive behaviour to me. The call to Say is the same, apart from the device ID used at the very end. If I use the ‘highest’ device ID then both Zones are played in, if I used the lowest device ID then the higher one seems to be ignored, even though it is specified in GroupZones.

Also, the use of apostrophe and spaces in the Zone names does not seem to have a negative effect. It works the same if they are literal or if they are URL encoded (%27, %20).

Can I provide any more information that would be useful?

In addition, although it is the pair of Play:1s that sometimes do not work… I’m not sure whether it’s related to them being a Pair or not… after all, the first and second lines of code work fine for this Pair, when the device ID of 5 is used.

Is this expected behaviour or could it be some kind of bug?

Please first do a test with 2 zones that are not pairs and that have a name without blank or quote. It should work.

Then change the zone name adding a blank and/or quote and let me know if it works or not, either using direct character or character code. This will conclude if there is or not a problem with zone name.

Then when you know how to use zone name (if not keep a simple name without quote), try to do the job with a zone that is a pair. But as I already explained, it could not work with pairs (and even you could unpair your zone) because pairs are not perfectly supported by the plugin.

Finally, please provide the log I requested. This could help me to identify where is your potential error.

Back again, with what I think is good news…

I have used 2 Zones, “Study” and “Den”, which are a Connect:Amp and a Play:1. They have Vera Device IDs 4 and 7 respectively.

This code plays in both Zones:

[font=courier]luup.call_action (“urn:micasaverde-com:serviceId:Sonos1”,“Say”,{Text=“Test”,Language=“en”,Volume=40,SameVolumeForAll=“true”,GroupZones=“Study,Den”},4)[/font]

As does this code:

[font=courier]luup.call_action (“urn:micasaverde-com:serviceId:Sonos1”,“Say”,{Text=“Test”,Language=“en”,Volume=40,SameVolumeForAll=“true”,GroupZones=“Study,Den”},7)[/font]

Indeed, as does this code:

[font=courier]luup.call_action (“urn:micasaverde-com:serviceId:Sonos1”,“Say”,{Text=“Test”,Language=“en”,Volume=40,SameVolumeForAll=“true”,GroupZones=“Den,Study”},4)[/font]

And this code:

[font=courier]luup.call_action (“urn:micasaverde-com:serviceId:Sonos1”,“Say”,{Text=“Test”,Language=“en”,Volume=40,SameVolumeForAll=“true”,GroupZones=“Den,Study”},7)[/font]

But not if I give a Device ID of 0 or -1 or Nil… which is completely expected now I understand it more.

I’m happy to rename “Den” to be “Hippo’s Den” and do more tests if that will provide further useful information?

So ok, it works well without pairs and with “standard” zone names.

Now please try to rename your zone to “Hippo’s Den” and tell us if it still works.

If it works well, this will just confirm that your initial problem is due to using a pair.