How to operate Sonos Connect with HTTP POST
I have finally managed to fully operate my Sonos setup 100% from the Zipabox. I have a Sonos Connect that receives line-in input, and three Play:1 speakers. What I have done until now is turn the Sonos components on and off via Z-wave on/off sockets, to avoid having the system on all day and using power. But I wasn't able to group the components, or operate the Sonos Connect in any way via the Zipabox - until now.
What I have done is not exactly group the players. I still don't know how to do that. What I've is use two HTTP POST commands to set the Sonos Connect to line-in input, and to play it. Then I use the Sonos integration of the Zipabox to set URIs of the Play:1s to the Sonos Connect, and play them. The result is that I get the same sound from all sources just as if they were grouped.
I've just now got this working, so I hope there isn't some last glitch that I've missed. It seems to OK. The real test will be on Monday morning when the radio is supposed to come on.
I'm posted my two rules:
1. One rule turns on the Sonos components via the Z-Wave sockets, waits a bit, and then invokes the "subroutine" that does all the rest.
2. The subroutine is invoked via a switch. The first thing it does is turn the switch off (otherwise it can never again be invoked). It must first wait 2 seconds, because otherwise the 2 changes to the switch state happening in rapid succession won't work. It then sends the HTTP request to connect the Sonos Connect to the line-in source, and another to start it playing. Each Play:1 is then set to take the Sonos Connect as the source, their volume is set and they're set to play. The Plays need to be sent the RINCON address, which is the MAC address of the Sonos Connect. You can find this out by going to this URL:
where 192.168.0.20 is the IP of your Sonos Connect. It may take some trial and error to find this out. Go and have a look at the IPs of the devices shown in your router. You'll see a line something like this:
currently: PAUSED_PLAYBACK x-rincon-stream:RINCON_xxxxxxxxxx01400
That last bit is the MAC address you need (all have 01400 added to the end. You must also include that.)
3. The HTTP Post to set the Connect to line-in sends as the URI the MAC of the Sonos Connect itself! At least that's what I'm doing right now. It seems to work. So it's the same number as above.
4. The HTTP post to play the Connect is simpler, not much to say here. I stole it all from web sites hither and thither.
Be careful with the syntax of the HTTP POST body. It's sensitive to things like whether the quotes are double or single (they should be double).
I'll be interested to see whether this works for anyone else.