Page 1 of 1

Connecting to an external WiFi speaker(Sonos)

Posted: 20 Aug 2014 20:14
by Shaka
Hey guys,

I know that there is a way to automatically connect to bluetooth speakers and also a condition to check if a bluetooth connection is established. I've been trying to do the same thing with my Sonos speakers but seem unable to do it. I'd like to, for example, automatically connect to the speakers when coming home(connecting to my wifi) and start music playback but haven't found a way to do it so far.

Any help is appreciated.

Edit: As far as I understand music isn't streamed directly from the phone so that might be a problem. If it helps I'm connecting to the speakers via google play music.

Re: Connecting to an external WiFi speaker(Sonos)

Posted: 21 Aug 2014 23:19
by auto_wiz
I'm so glad you asked this question! I've been thinking about looking in to this for ages and your question prompted me to do just that and I'm so glad to report success!

After some googling I found this discussion http://www.hirahim.com/blog/2012/04/29/ ... ontroller/

It describes an http request which we can implement from automagic. See attached example flow. Simply swapping play for pause in the header and body allows you to perform either. I couldn't stop grinning when this worked!

Just substitute the IP address for yours and it should work just fine.

Now for some experimentation to play certain music, adjust volume etc. I feel some voice commands coming on :-)

Enjoy! Please share if you find out anything more.

http://automagic4android.com/flow.php?i ... 1da8d631ac

Re: Connecting to an external WiFi speaker(Sonos)

Posted: 22 Aug 2014 10:17
by Shaka
Hey there!

Thanks so much for your response. At least knowing that it CAN work gives me hope :)

Sadly I wasn't able to duplicate your success, not sure where I went wrong...

I tried showing the response variable to see where the error might be but that didn't really get me any further:

8.2014 12:12:09.383 [Sonos Control] Action 'HTTP Request: POST http://192.168.0.13:1400/MediaRenderer/ ... rt/Control text/plain <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encodin ... y><u:Pause xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><Speed>1</Speed></u:Pause></s:Body></s:Envelope> store in response' URL data fetched successfully.
22.08.2014 12:12:09.401 [Sonos Control] End executing action 'HTTP Request: POST http://192.168.0.13:1400/MediaRenderer/ ... rt/Control text/plain <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encodin ... y><u:Pause xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><Speed>1</Speed></u:Pause></s:Body></s:Envelope> store in response'
22.08.2014 12:12:09.432 [Sonos Control] Flow continues executing with the next step.
22.08.2014 12:12:09.433 [Sonos Control] Start executing action 'Notification on Screen: {response}'
22.08.2014 12:12:09.434 [Sonos Control] Action 'Notification on Screen: {response}' Showing toast text '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encodin ... <UPnPError xmlns="urn:schemas-upnp-org:control-1-0"><errorCode>401</errorCode></UPnPError></detail></s:Fault></s:Body></s:Envelope>'.


http://automagic4android.com/flow.php?i ... 90e78cc857


My IP is entered correctly...

Any ideas? And thanks again!

Re: Connecting to an external WiFi speaker(Sonos)

Posted: 22 Aug 2014 18:55
by auto_wiz
I'm not really sure what to say. I've just copy pasted and got lucky. I realised after I uploaded the flow that I had the pause and play commands mixed up but it looks like you fixed that. "Upnp error" isn't much help is it. If you search online there is an AVTransport pdf with all the commands and some help on errors.

I tried this with a Play:1 and I haven't had a chance to check it on the playbar yet (other half occupying the TV). All I can suggest is try the play command and maybe another speaker IP if you have one. Also check you have a track loaded already with the sonos app. So here's the flow again this time with play entered properly. I've just had this working.
http://automagic4android.com/flow.php?i ... 87045d1a1f

Sorry I couldn't be more useful!

Re: Connecting to an external WiFi speaker(Sonos)

Posted: 24 Aug 2014 15:52
by auto_wiz
Try again. I just had an error exactly the same as you. I noticed the SET CUSTOM HEADERS checkbox was off in my last uploads and the headers had disappeared, I'm not sure how. This time it's fixed so try this.

http://automagic4android.com/flow.php?i ... c9d4b90f04