Get CPR certified in 30 minutes at CPR Test Center.
Echo & Alexa Forums

Amazon Echo integration with Sonos

0 Members and 1 Guest are viewing this topic.

arjan

Amazon Echo integration with Sonos
« on: August 01, 2015, 07:07:31 am »
Hi all, I want to bring up an idea of integrating the Amazon Echo with the Sonos speaker system.

Imagine the following situation:
1. All of your music available on a network drive, able to play this with Sonos.
2. All of your music equally available in your Amazon Music library, able to play this with Amazon Echo.
3. A local script "copying" the current state of Amazon Echo to the Sonos speakers. The state contains the variables: Play or pause, volume level, content name.
4. All of the music in the Amazon Music library is "fake". The music files do contain the meta data, name, length, but do not contain volume. When the Amazon Echo is playing music, nothing can be heard. These "fake" music files can easily be created by a script going through all of your music files.

This would create the situation that people can use the Amazon Echo voice recognition, and native play capabilities, to play music on the Sonos speakers.

The only missing link in this story is how to retrieve the Amazon Echo play state attributes:
- Playing or paused
- Volume level
- Name of content

If this could be retrieved in real time, or within 1 second, I believe this would perfectly suit for integration.

Does anyone know how to poll for the "now playing" attributes?

Update: It's working https://youtu.be/nQ5h1jPsqjI
« Last Edit: August 02, 2015, 02:21:40 pm by arjan »

markv

Re: Amazon Echo integration with Sonos
« Reply #1 on: August 01, 2015, 11:32:56 am »
I have a similar interest in using the Echo to send music directly to my home theater. The Echo has decent sound quality, but can't compare to a 7.1 or 5.1 speaker system.

So far, I've got my Echo controlling a bunch of Insteon lighting scenes (via a Hue emulator) as well as power on/off and general source selection of all the home theater components ("Alexa, turn on DirecTV / ChromeCast / Roku / DVD / etc"). But I haven't yet found a way to get Alexa to stream audio to another device.

If Amazon adds integration with the Fire TV Stick, then I'll be a happy camper  :D

arjan

Re: Amazon Echo integration with Sonos
« Reply #2 on: August 01, 2015, 02:36:04 pm »
Update:

Good news, we can easily retrieve what Amazon Echo is playing by:

https://pitangui.amazon.com/api/media/state?deviceSerialNumber=XXXXX&deviceType=XXXXX

We can find the serial number and device type here:

https://pitangui.amazon.com/api/device-preferences

The whole queue is shown, as well as the current play state and the volume.
Now let's feed that to the Sonos Operator and it's done.

To summarize:

1. Sonos will play what Echo is playing.
2. Sonos will pause when Echo pauses.
3. Sonos will change volume when Echo changes volume.

The only trick here is that Echo is playing muted songs, and Sonos is playing real songs.

arjan

Re: Amazon Echo integration with Sonos
« Reply #3 on: August 02, 2015, 02:20:47 pm »
I've got the integration working like described, for those who are interested:

https://youtu.be/nQ5h1jPsqjI

It's working very smooth, all of the Amazon Echo native commands can be used.

markv

Re: Amazon Echo integration with Sonos
« Reply #4 on: August 03, 2015, 11:55:15 am »
Nice demo. Thanks for the pitangui.amazon.com links.

RILEY6683

Re: Amazon Echo integration with Sonos
« Reply #5 on: August 31, 2015, 09:54:39 pm »

The whole queue is shown, as well as the current play state and the volume.
Now let's feed that to the Sonos Operator and it's done.


Thank you for posting this!
Apologies but I'm new to integrating with Sonos like this.  How exactly is this feed accomplished?

arjan

Re: Amazon Echo integration with Sonos
« Reply #6 on: September 02, 2015, 04:29:43 am »
Thank you for posting this!
Apologies but I'm new to integrating with Sonos like this.  How exactly is this feed accomplished?

The process is globally explained in the posts above. What part are you pointing at?

johnehurst

Re: Amazon Echo integration with Sonos
« Reply #7 on: October 14, 2015, 02:38:22 am »
First off, nice work w/ integrating Sonos.  This is exactly what I would like to see done commercially.  Arjan I've been able to use your links to query my own Echo and see the attributes that carry the information needed to pass to Sonos.  Thanks for supplying those links.

I realize this is not a Sonos forum, per se, but RILEY6683 has a good question.  It's not clear how we could go about accessing our Sonos systems.  Once that piece is in place, the scripting and automation should follow.

arjan

Re: Amazon Echo integration with Sonos
« Reply #8 on: October 14, 2015, 03:44:12 am »
I've used SoCo, a Python library for connecting to Sonos devices and controlling them.

SoCo can be found at github.

BDN13

Re: Amazon Echo integration with Sonos
« Reply #9 on: November 03, 2015, 03:16:11 am »
great work - unfortunately I have a Bluesound setup instead of Sonos (liked the sound better) - but if you've figured it out for Sonos, I'll try to do the same for Bluesound

Tb001

Re: Amazon Echo integration with Sonos
« Reply #10 on: December 27, 2015, 02:33:58 pm »
Has anyone else been able to implement this solution who might be able to give simple instructions to walk a non-super tech savvy person through the setup? We have a pi2 running a bridge to the echo and are using it to control our home automation system, so I'm not totally clueless, but I can't figure out what I'm supposed to do here.

From what I can tell, the other solutions to integrate with sonos will let you play predefined stations, favorites or playlists, which is great, but doesn't really leverage what is IMO the most powerful aspect of echo's voice control. We've pretty much stopped using the sonos because it's so much easier to just tell Alexa to play an album or artist. We have almost 100gb of music, all uploaded to our Amazon music acct, plus Amazon prime music and the echo voice interface is just so much better.  Please LMK if I'm missing something basic here...the solutions I've seen look great, but if I have to predefine every permutation of what I might want to play, it's just not interesting.

FWIW, I think arjan's solution really is a killer app for the echo--I'd be more than willing to pay someone to help me get this set up and would imagine I'm not alone.

arjan

Re: Amazon Echo integration with Sonos
« Reply #11 on: December 27, 2015, 04:27:54 pm »
My solution also requires some preparation. The mp3 files uploaded to Amazon cloud music have to be adjusted to volume 0. Although this can easily be done using a script.

I agree with you that using the native speech capabilities of Amazon Echo is the way to go.Other solutions, using the skills,  do not use these capabilities.

I'm willing to build any good app for using Amazon Echo with Sonos, but unfortunately Amazon is not cooperating:

Amazon does not provide an API for retrieving information on what is being played. In my solution this information is retrieved using a script fetching the Amazon Echo website. Amazon is actively blocking this by presenting a captcha when logging in using a Pi2. Currently there are ways around this, but Amazon could easily improve this anti-script protection.

I believe we should collectively request Amazon to enable to play our music on Sonos, or other devices. Since Sonos already supports Amazon Prime music, this is a minor feature to implement: just tell Sonos what to play.

mhonard

Re: Amazon Echo integration with Sonos
« Reply #12 on: January 31, 2016, 03:38:46 am »
You state "I'm willing to build any good app for using Amazon Echo with Sonos, but unfortunately Amazon is not cooperating" does this mean it works or not? Can you post instructions suitable for a newbie as I am struggling on how to integrate soco (verbally sends commands to echo), convert files etc. I've been able to get rgraciano's github https://github.com/rgraciano to work well but want the native language set and access to all my music. Any detailed help would be appreciated
« Last Edit: February 01, 2016, 06:30:05 am by mhonard »