Sonos and Amazon jointly announced their Alexa integration earlier this year and the world rejoiced. Voice control of your Sonos system is one of those holy grails. The integration is expected to be available at some point in 2017.
But I’m an impatient geek so, while I’m waiting for official support to be available, I spent an hour yesterday getting this working using freely-available open-source tools. Fair warning: to follow this tip you’ll need to be a geek, too or, at the very least, if you follow this tip you’ll most certainly be a geek by the end.
I now live in the mostly-bliss state that comes with having the ability to say, “Alexa, tell Sonos to pause,” or “Alexa, ask Sonos what song is playing,” or even, “Alexa, tell Sonos to add the living room to the kitchen.” It’s pretty cool, and it mostly-works. For a freely-available, open-source type of setup, it’s amazingly robust.
How You Can Integrate Alexa with Sonos Today
Your path will start with the very clear instructions at Ryan Graciano’s echo-sonos repository, but before I send you off I figure you might appreciate reading the high-level approach to what you’re about to do. There are essentially three pieces that you’ll stitch together.
- First, you’ll install node-sonos-http-api on a computer at your house. This could be a Mac, a Synology DiskStation, a Raspberry Pi or anything else that can run node.js (hint: if you want to install node.js on your Mac, first install homebrew, then type “brew install node”). That will be the local bridge between the outside world and your Sonos.
- Second, you’ll create an Alexa Skill, hosted at Amazon, that will eventually talk across the internet back to your bridge computer at your house. I know… Alexa is in your house and so is Sonos. But Alexa talks to Amazon, and then Amazon talks to the other services that Alexa controls. It’s weird to think about, but that’s how it works. You’ll need to set up a free Amazon Developer Account to do this, and Ryan’s great instructions walk you through this, too.Note: during the process of creating the Alexa Skill you will have to add things like PRESETS, ROOMS, SERVICES and more to your Alexa Skill. Don’t worry that these names don’t match your existing rooms, playlists or services. Yours will be dynamically collected when you fire it all up at the end.
Another note: create your Alexa Skill and Amazon Lambda service using the same Amazon account to which you have your Amazon Echo devices attached, otherwise they won’t talk with each other. You’re going to leave this skill in Developer Test mode because it’s only built to talk to your house, so it must all be attached to the same account “for testing.”
- Finally, you’ll configure Amazon’s Lambda servers to talk to both the Alexa Skill and the node.js server you set up at home. At that point, you’re finished. Talk to your Sonos (via your Echo) and… listen to the results!
As I said, this took me about an hour to do, but I already had node.js setup on my Mac via homebrew, and I’m pretty comfortable with the command-line. Most importantly, though, I didn’t really care if I broke something, and that’s the trick. If you get it wrong, you can just wipe it all out and start again. Or not. But when you get it working, it’s pretty darned cool.
Head over to Ryan’s echo-sonos GitHub repo to get started, have fun, and let us know in the comments how it goes. If you run into trouble, we might just be able to help, too!
Dave, can you help? I got almost all of the way thru setup. Got to a point where any proper commands given to Echo resulted in music playing- but NOT the music I asked for… rather my sonos just played the last song that they had previously played. No idea where to look to figure this out. I went back through all setup instructions to confirm done correctly.
But now (for past 4 days) it seems like there’s an overriding issue…. I give a command to Echo and I get response “The Lambda service encountered an error. Unexpected token E”.
Got it working. Is there a way to add Pandora and Amazon Music as additional services??? Any guidance appreciated.
@Niko, once you have homebrew installed the commands should be:
brew install node
cd ~/Downloads/node-sonos-http-api-master
(or whatever directory you downloaded that to)npm install --production
npm start
That should do it and allow you to connect to it at http://localhost:5005/ and see your zones by clicking on that link in the resulting page, etc.
I’m having problems installing node-sonos-http-api to macOS sierra, can’t really figure how to do it… Already installed homebrew but after that I’m stuck.. ):