Advanced Sonos Commands for Alexa/Echo (choose playlists/radio, control volume, skip songs, etc.)

UPDATED TO REFLECT THE NEW FEATURES OF ECHO-SONOS:

I have noticed that many people with Amazon’s Echo and Sonos devices have been wishing that they could do more than just play/pause the music that was already in the Sonos queue.

Luckily, someone wrote a really great set of Echo-Sonos instructions on how to integrate Alexa and Sonos. Basically uses jishi’s node-sonos-http-api and merges those commands into a new Alexa skill.

Using Echo-Sonos, Echo can:

Global commands (no rooms required):

  1. Presets: “Alexa, tell Sonos to play Rock”
  2. Pause all: “Alexa, tell Sonos to pause all”
  3. Resume all: “Alexa, tell Sonos to resume all”

Room-specific commands, where “ROOM” could be any of your Sonos room names (eg Kitchen, Master Bedroom, and so on):

  1. Playlists: “Alexa, tell Sonos to start playlist MY PLAYLIST in the ROOM”
  2. Favorites: “Alexa, tell Sonos to play favorite MY FAVORITE in the ROOM”
  3. Next: “Alexa, tell Sonos go to the next track in the ROOM”
  4. Previous: “Alexa, tell Sonos to go back in the ROOM”
  5. What’s playing: “Alexa, ask Sonos what’s playing in the ROOM”
  6. Pause: “Alexa, tell Sonos to pause in the ROOM”
  7. Resume: “Alexa, tell Sonos to resume in the ROOM”
  8. Mute: “Alexa, tell Sonos to mute in the ROOM”
  9. Unmute: “Alexa, tell Sonos to unmute in the ROOM”
  10. Repeat: “Alexa, tell Sonos to turn repeat [on,off] in the ROOM”
  11. Shuffle: “Alexa, tell Sonos to turn shuffle [on,off] in the ROOM”
  12. Crossfade: “Alexa, tell Sonos to turn crossfade [on,off] in the ROOM”
  13. Clear queue: “Alexa, tell Sonos to clear the queue in the ROOM”
  14. Volume up or down (single room): “Alexa, tell Sonos to turn it [up,down] in the ROOM”
  15. Volume up or down (all in group): “Alexa, tell Sonos to turn it [up,down] in the ROOM group”
  16. Set volume (single room): “Alexa, tell Sonos to change the volume to 22 in the ROOM”
  17. Set volume (all in group): “Alexa, tell Sonos to change the volume to 22 in the ROOM group”
  18. Many other natural phrasings are supported for each command. The file “echo/utterances.txt” has all of the examples.

In light of the advancements that Echo-Sonos has made, there is no need for my “Enhanced Echo-Sonos” fork.


You can find all the the instructions you need in the Readme. But let me know if you have any weird problems / questions. It worked for me (almost) right away, and has been consistently working really, really well for me.

12 Likes

interesting… I don’t know how I feel about opening up an home server on the internet…

just thinking out loud here, but couldn’t you write a smartApp with REST API and OAUTH and point the Alexa skill at the ST cloud?

Not to control Sonos playlists, next / previous songs, change volume, etc. as I am able to do now. To have that functionality, you need a server to handle those commands.

Hi guys, for a long time now I’ve been having major issues with the ST-Sonos integration. Basically, it does not work! That said, I wonder if there’s a way to substitute the Echo for the Sonos speakers for things like “Say the weather when [user specified trigger, like motion] happens”, or “Say [user specified phrase] when [user specified trigger] happens”, etc. Seems like you guys might know the answer to this. I’ve asked ST support but all they said was that Amazon is not treated as a speaker by ST so no it cannot. Thoughts?

@mhatrey - perhaps you might know considering you work at Amazon?

My understanding is that this isn’t possible because the echo cannot be used as an external speaker.

See Will Amazon Echo Ever Announce Alerts via Smartthings?

1 Like

@triggertact - Unfortunately Echo does not support this feature. I know, I would like this feature very much. At this point Echo’s forum would be right platform to bark at, so the echo product team knows your feedback and based on the weight they might prioritize the feature, if this is something in their roadmap.

1 Like

So I am following along in your instructions but in Amazon when I click Save I am getting errors such as:

Error: There was a problem with your request: Error in sample on line 134 - ‘LevelIntent set level {ten|Level}’. The given intent doesn’t declare the slot ‘Level’.

Ideas? Did I miss something?

Updated the description above to reflect the many new features of the Echo-Sonos. Deleted the link to my “Enhanced Echo-Sonos” fork as it was no longer relevant.

@infofiend I’m in the process of having the github post you referenced carried out on my network to integrate Alexa with Sonos. (I’m having a developer do it as it’s over my head."

Spotify is my only source of music. All others pale in comparison IMO. That said, I love the freedom of Alexa in that I can say “Play [artist] on Spotify”. Is there any solution that you know of that allows all the Spotify / Alexa commands to work but play through Sonos? Thanks in advance!

One way would be to make your selection one of your Sonos favorites. Then you can just use the echo / Sonos integration in normal manner.

Another option would be Michael Struck’s Alexa Helper smartapp - [quote=“MichaelS, post:1, topic:46786”]

[/quote]

Hi,

I am trying to run sonos http api on my Ubuntu 12.04 server.
When I run the server.js I get this error:

node --harmony server.js

/root/node-sonos-http-api/server.js:109
process.on(“unhandledRejection”, (err) => {
^
SyntaxError: Unexpected token >
at Module._compile (module.js:439:25)
at Object.Module._extensions…js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:945:3

~/node-sonos-http-api# npm -v
node -2.15.1
~/node-sonos-http-api# nodejs -v
v0.10.47

What can I do ?

I can’t tell what the problem is from that error, sorry. I think your best bet is to see if you followed each and every step in the Github Readme. If you think you have, try asking ask jishi.

hi,

I followed the steps. How can I ask Jishi ?

meanwhile , I am trying to create the Lambda AWS and Alexa side configurations.
I created both.
Should I use the same Amazon user ID for AWS and Alexa logins ?

when I try the test code after I create the lambda function I get this error:

{
“errorMessage”: “Unexpected token <”,
“errorType”: “SyntaxError”,
“stackTrace”: [
“Module.load (module.js:343:32)”,
“Function.Module._load (module.js:300:12)”,
“Module.require (module.js:353:17)”,
“require (internal/module.js:12:17)”
]
}

What is the reason for this error ? How can I fix it ?

ok. I fixed the lambda and alexa side.
now my commands from Alexa come to my router.
However, as I can’t start the nodejs server, it does nothing.

How can I fix the problem when starting nodejs ?

node --harmony server.js
/root/node-sonos-http-api/server.js:109
process.on(“unhandledRejection”, (err) => {
^
SyntaxError: Unexpected token >
at Module._compile (module.js:439:25)
at Object.Module._extensions…js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:945:3

~/node-sonos-http-api# npm -v
node -2.15.1
~/node-sonos-http-api# nodejs -v
v0.10.47

I really wish I could tell you what the issue is, but to be honest, I am not that familiar with setting up node.js servers. I had never even set one up prior to using the instructions on jishi’s Github page. And I set mine up a looooong time ago - a couple years I think. All I can say it that if it’s not working, it’s likely that you missed a step or perhaps are missing one of the required libraries. Check your history to see if some library didn’t load or if there are packages that need updates (if so, run sudo apt-get upgrade). Other than that, Jishi is your best bet.

OK. I understood that. But I don’t know how to contact Jishi.
Any way I found an email address on github ; I’ll try that.

Other than that , my Echo has not arrived yet. So I wanted to try this setup to see if the added skill is usable through a device. And I’ve found 2 options:

  1. Android app called Alexa Listens
  2. http://echoism.io we app

But both of these responded : Amazon music is not supported on these devices.
What does that mean ? I am not trying to use any Amazon music service in this skill. Am I wrong ?

You should check out Ask Alexa smartapp by @MichaelS. It has the ability to set up and store multiple radio stations so you can Trigger them via voice (also need CoRE). With those two smartapps, you can pretty much do anything via voice.

The issue is that I want to use Echo-Sonos because I want to use an Echo (already ordered)
“Ask Alexa” might be a good alternative from phone.

So, is there any way to simulate Echo and test Echo-Sonos ?

Echosim.io