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

Ask Alexa is a SmartThings app used to control an Amazon Echo.

Im starting to see why developers and coders need customer facing teams to get their products out. While this may be a great app, the chances of a relative newbie getting this workig from these instructions is almost zero.

Im not a complete novice to IT, but Ive been trying to get this working for a couple of hours now and I don’t think Im even close to getting node.js installed.

The first instruction is: “Install node.js on a server on the same network as your Sonos.”

Thats a rather large first step. No instructions what so ever, so its off to google to see whether I can run this on a windows box. When I think Ive got it running according to these instructions:
http://blog.teamtreehouse.com/install-node-js-npm-windows

The next step is: "Grab https://github.com/jishi/node-sonos-http-api and run it on that server. On Mac, it’s “npm install https://github.com/jishi/node-sonos-http-api”, then go to the directory created and “npm start”.

Wow. Talk about in at the deep end. Just “grab” that and run it on the server. Its at this point a newbie to node.js is now completely lost, and thats step 2 of about 30.

Having managed to setup and tweak AskAlexa, Im capable of doing stuff like this, but the instructions for this are just so high level there isn’t a prayer of it being taken up by lots of people without a much more comprehensive set of instructions.

So far, Ive followed the steps to get node.js installed and can get it to say “node is installed” from a simple .js file. After that, its all just fallen apart. Shame, as Ive got quite a few sonos around the house and I would have liked to try this.

this is exactly what I’m feeling.

There are instructions but they are so large. I am an IT professional. Well actually I am working on network side but I do even write codes of my own.
I’ve installed hundreds of Linux/Unix systems myself. But with these instructions I am not able to install the correct version of nodeJS.
On the api instructions it says :

This application requires node 4.0.0 or higher!

This does NOT work on Node 6+ at the moment

but my Ubuntu server is installing a total different version (10.47)
So I’m not even sure if this is suported or not.
And if it’s not supported, I don’t know how to solve the problem. Because I don’t know a source to download the correct version of nodeJS.

I’m stuck…

I got node.js installed on a windows box.

From a command prompt if I type “node -v”, I get v4.6.0

So it appears node is installed. I can call a simple script (console.log(‘Node is installed!’);) in a file called hello.js

It outputs “node is installed”. So it looks like node is installed and should be working.

Its at the next steps, where there is no clarity at all - “Grab jishis code and run it on that server”. For anyone who hasnt even seen node.js before, it may as well be written in arabic.

Btw, when we install node-sonos-http-api and open access to it from internet, we actually open our Sonos speakers to anybody. There’s no authentication mechanism , right?
How can we prevent anybody accessing our Sonos ?

after a LOT of head scratching and frustration, Ive got somewhere close.

I can say “Alexa, ask sonos play robbie williams in the kitchen”.

She responds with “Queued and started robbie williams” - which is what I expected after testing on the amazon developer page.

However, nothing happens with my sonos. Nothing.

web page requests seem to work such as “http://192.168.1.253:5004/kitchen/queue

It’s obviously not for everyone. I was able to set it set up (with the help of Google when I didn’t know how to set up a node server on a raspberry pi) and it works great for me (and others).

However, nothing happens with my sonos. Nothing.

web page requests seem to work such as “http://192.168.1.253:5004/kitchen/queue

Try refreshing your ST Sonos device before you add a Playlist or a Station to ask Alexa. @MichaelS is the person to ask if that doesn’t work.

Its not that it isn’t for everyone (in my opinion), its that without wishing to offend, the instructions are awful.

Take this for example: “The default handler is fine. Create a new role of type Basic Execution Role. Pick smallest possible memory and so on.

There are several more fields beyond selecting the new role of Basic Execution Role. “and so on” does not come close to being an instruction.

Consider if somebody were writing instructions for wiring up a plug. If they said “open the plug and put the wires in and so on”, it would be useless. Which wires? Where? Which colour goes to which pin?

Its only because I previously set up AskAlexa and followed the excellent instructions for that app that I was able to remotely follow the instructions given for this sonos integration. There are virtually zero instructions on setting up node.js without going off to google - and then you may not set it up in a way that will work correctly with this integration.

If a set of instructions is not clear enough to guide people through a process without them having to google for answers, then they fail in their role as a set of instructions.

Im getting close to getting this working, but sadly this integration is massively let down by the total lack of step by step instructions. Only those with some coding knowledge will be able to even attampt this, which is a shame as there will be lots of people missing out.

Lol. Sorry it didn’t work out for you. Better luck next time.

Wow. Very helpful.

Hows about you try setting it up again, following the instructions exactly as written and see where you think they need improving? Or possibly trying to point to complete instructions on how to install the various steps? Or maybe actually acting in a more positive manner for the community.

“Better luck next time” is hardly a great attitude.

Ive been trying to get this working for two days now, I know nothing what so ever about node.js, and have never installed it in any fashion before, probably like most of the other people wanting to follow this guide.

My intention once I got it working was to write full instructions that anyone could follow (as documenting instructions is something I have done in the past professionally), but if you want to just leave it down to “luck” as to whether somebody can actually get this working or not, then thats your choice.

Are you UK based?

As was I. I had no prior experience with node servers. My very first one was for this project. Don’t blame the instructions for your inability to get it to work.

I posted the instructions exactly as I found them - as they worked for me. If that helps you, grand; if not, sorry.

Or maybe actually acting in a more positive manner for the community.

You’re right, I never provide help to anyone here. I don’t share my smartapps or DTHs.

Perhaps I’ll just follow your lead and make complaints about how others are to blame for my inability to figure things out.

You are a coder, or at least have some experience with these things (other than node.js which you state). Perhaps this is why you can follow these instructions.

However, as far as instructions go, they are garbage.

No set of instructions should contain the words “and so on”, ever.

No set of instructions would gloss over the installation of an entire item like node.js with one single step.

No set of instructions would have “Grab xxxx and run it on that server”.

If you can’t see how the instructions are fairly useless for anyone without prior experience in some form of coding or software setup, then I can’t help you.

Amazing how I was able to follow instructions for AskAlexa, arguably one of the most complex and comprehensive projects, and install it first time and it work just fine. Yet this project which should be an awful lot simpler to achieve is proving so difficult because of the awful, awful instructions.

Btw, when we install node-sonos-http-api and open access to it from internet, we actually open our Sonos speakers to anybody. There’s no authentication mechanism , right?
How can we prevent anybody accessing our Sonos ?

Yes Alex.

I’ve already run into one issue that was fixed, in that when setting up the alexa app on the European (Ireland) side - you cannot use “Amazon.Literal” in the intent schema. Any apps using this will no longer be passed by Amazon apparently. There is a quick fix to alter all these instances to just “Litteral”, though whether that would be the approved method if an app was to be sent for official approval I dont know.

However, after that is done, the lambda service and alexa skill seem to be working well together. Testing on the Skill side you can test various utterances and the output looks OK. Try for real on the Echo unit and the response seems to be OK too. Until the node.js server falls over or doesnt work properly, and then every utterance after that comes back with a “trouble accessng the skill right now” or similar message.

The whole issue seems to be with the node.js and the setup of this element of the project as the instructions for this part are vague to say the least.

Just follow the instructions exactly as written. You wont be able to access it yourself, never mind the rest of the world. :wink:

this is not the answer I’m looking for. Please stop filling the thread with garbage.
The author may prefer to help or not. Nobody can force him/her to help or to write a better instruction.
Maybe the author is not capable of writing good instructions. Maybe he just does not want…

1 Like

If you’re using UK spotify, you might need to do this to fix. I had this issue. Works for me now.

Yah, I believe that is different than the US default. Do the following:

Add a song track from Spotify to your Sonos Favorites
Look in your Sonos Favorites and note the exact spelling of how it was saved
Invoke the URL …/YOUR_ROOM/musicsearch/spotify/setsid/EXACT_NAME_OF_SONG
This will read the service ID from the song, save your sids on disk in lib/sids.json with the updated sid, and use them from now on. Save and return this file when you update the api, or follow the same steps again.

Apologies, Im just frustrated at not being able to make this work and getting zero help.

There is a section regarding security and not having to open the server to the internet here:

This would also be a concern for me, and it is possibly something that I would look at once I got the basics working.

You can set up basic auth quite easily in the settings.json configuration. It’s documented in the readme on the sonos-http-api github page. You can also go one further by creating your own HTTPS certificate.