Yes - sort of.
WARNING: This post is not for the faint of heart because the solution is not trivial.
So, I found a project on github that uses another project on github combined with a custom skill on
the Echo via a web service hosted by AWS Lambda. OK, that was the easy part. I knew that going in. That's why, initially, I waited. There must be an elegant solution out there. I searched and waited and searched again and waited again. Finally I decided to give it a try. If it worked it would be really cool. If it didn't, well I'm no worse off than before.
Now that it was decided, I sat down and went through the instructions provided by Ryan Graciano. Here are the instructions with my extra notes.
Get jishi's node-sonos-http-api working
- Install node.js on a server on the same network as your Sonos.
- Oddly enough, I didn't see this step which may have been a good thing because I may have done it wrong.
- So I tried the command and, not unexpectedly, it failed miserably. OK now I have to find out what "npm" is and how to install it. Here's what I did.
- I found the npm website and created an account (not sure if I really needed to do that)
- Downloaded the program from https://nodejs.org/download/release/latest/
- This was hard to find because there are a lot of options and it took a bit to find the right one (it was the node-v6.3.1-x86.msi for my 32 bit Windows machine)
- Installed the program
- Then I had to grab the node-sonos-http-api - the instructions say use the following command "npm install https://github.com/jishi/node-sonos-http-api"
- Tried it and it failed spectacularly (tons of error and warning messages)
- One of the first errors was "Error: not found: git" - I guess I need git as well
- Download git from https://git-scm.com/download/win
- Install git
- I chose to use the windows cmd.exe and the rest were the defaults
- Tried it again - it errored off
- Remembered that I just installed git so my DOS window that was already open wouldn't have the new environment variables. I closed the window and opened an new one
- Tried it again - SUCCESS
- There were some warnings but it worked!
- OK - I found the directory on the website that referenced the presets.json file but, instead of downloading the file, it brought up the file text.
- Fine - I copied the file text (control c is my friend)
- Found the node-sonos-http-api root directory and created the presets.json file with the data I copied from the web page.
- I opened up Internet Explorer and tested it out - it worked!!
- Also worked!
Expose your server to the outside world
- You need some way for Lambda to contact your server consistently. Services like DynDns and yDNS.eu will give you a consistent hostname for the outside world to use. If you have an Asus router like I do, then dynamic DNS is actually a built-in / free feature.
- I have an ASUS router so this should be easy - yay!
- Logged into router settings
- Set up a dns name for my connection (
- WAN -> DDNS
- Set up port forwarding
- WAN -> VIRTUAL SERVER/PORT FORWARDING
- Tested it: http://
- It worked!!
- Did that.
- I did not do this as I don't intend for my desktop to be a server. I am aware I will need to manually restart the application if I ever log out or reboot my desktop.
- It worked!
Create the Alexa Skill that will send events to AWS Lambda
- Create a new Skill in the Alexa Skills control panel on Amazon. You need a developer account to do this. The account must be the same as bound to your Echo, and make sure you are logged into that account on amazon.com. You will get access denied if the two accounts are different.
- I went to developer.amazon.com and signed up for a new account.
- I used Sonos as well - it's my Sonos after all
- Here once again I copied the text of the files from the github site and pasted them into the appropriate boxes.
- More cutting and pasting.
Configure the AWS Lambda service that will trigger your node-sonos-http-api server
- Create an AWS Lambda account if you don't have one already. It's free!
- It free! but Amazon still requires a credit card number so they can charge you for any non-free services. That almost did it for me but I had come this far and I wanted to finish it.
- He's not kidding here. I picked one in the western US and it didn't work at all, I had to recreate my whole service in the N. Virginia zone.
- Created a directory on my desktop and copied the text into the options.js file.
- Made the updates as directed.
- Once again, I cut and pasted the text from the github source into the files on my desktop.
- The role options have changed. I just picked custom role and named it something. I don't know if that was right or not but it let me continue.
- This has been changed to triggers. It took me a while to figure that out. I actually tried skipping it at first but the thing wouldn't work.
Connect Alexa Skill to AWS Lambda
- In the Lambda console, copy the long "ARN" string in the upper right.
- Go back into the Alexa Skill console, open your skill, click "Skill Information", choose Lambda ARN and paste that ARN string in.
- Now you're ready to put it all together. Try "Alexa, use Sonos to play test"
And we're done!! It's going to be so awesome!! I try it out: "Alexa, tell Sonos to pause all" - It work's!! "Alexa, tell Sonos to play playlist My Favorites in the Kitchen" - nothing. "Alexa, tell Sonos to play favorite My Favorites in the Kitchen" - nothing.
OK - I can play and pause but I can't play playlists or favorites. Not cool.
I do some research and dig through forums. OK - it looks like it doesn't work right on node.js versions higher than 4.x and I have version 6.3.1.
So I uninstall node.js 6.3.1 and install version 4.4.7 and restart the server.
Now it works! Well, mostly. It has a hard time with multi-word playlists and almost all of my playlists are multi-word. Well, apart from that, it works.
I'm going to play around with it for a while and, if I can get it working like I want, I'll get a raspberry pi computer and run the whole thing from there. More to come...