controlling sonos using a docker


pcgirl

Recommended Posts

After a long time trying to get this to work, I finally got it working.  So, I thought I would let anybody who is interested know how I did it.

 

The whole reason for doing this was so that I could send commands through my Smartthings Home Automation to my sonos system.  For instance, when people arrive at the house, I can have my Sonos say "Welcome Home, {name}!".  And then I can have my program in Smartthings send a command to turn on a specific playlist.  I had it setup on my Windows PC but I thought it would be better to have it on my UNRaid server, since it is always on.  I had to setup a Node Server on my Windows PC and I wasn't sure how to do it on UNRaid.  Anyways, after searching and asking questions this is how I did it.

Search for this docker using Community applications - chrisns node-sonos and install it.

Then make sure that it is in "HOST" mode.

At this point you will be able to your Sonos speakers from a web browser using the IP address of your Unraid server and the port :5005 at the end.  http://unraidserver:5005/

For information on what commands you can use see here.  https://jishi.github.io/node-sonos-http-api/   IE:  http://unraidserver:5005/state/Speaker1 will give you the state of Speaker 1

Now I wanted to set some presets for when I came home and when I left, etc. to play.  This was trickier to setup because I couldn't find the subdirectories to put the presets into.  So, what I did is I opened up a Terminal Window to the unraid server and did a search for .json files on the server then copied and pasted the results into Notepad++.  then I did a search in Notepad++ for example.json(which is installed with the program in the presets folder).  Once I found it, I could see where the presets folder was and I could copy over my presets to this folder.  Restarted the docker and voila, I could see that it had found my presets by looking in the log file.  I opened my web browser and typed in http://unraidserver:5005/preset/Jane and everything started playing.  You can copy over a settings.json also when you find the directories.  I have a voicerss api number in the settings.json file so that my sonos will speak the commands I give it from Smartthings.

I realize that there may be easier or better ways to do this but this is what I found out and learned along the way.

 

So now you can program whatever you want it to say and what music you want to play whenever.  Hope this is helpful.

 

Link to comment
  • 2 months later...

 This is how I 'altered' the Unraid Docker Settings to make it easier for Presets, etc.

 

Sonos-Basic Settings.JPG

This is how I 'added' the folders so that they are accessible under the Unraid Appdata 'sonos' folder. Much easier to find the presets and settings and they won't get erased by container updates.

The file 'settings.json' is to put in the settings folder and any presets you make should go into the presets folder. Clips and cache are also specified here but I haven't made use of them yet.

 

Sonos-Advanced Settings.JPG


I also added the line:

https://github.com/jishi/node-sonos-http-api/blob/master/static/sonos-icon.png?raw=true

in the advanced settings (upper right toggle) so that the docker has an icon in Unraid.
Also added the `r--restart=always` to the extra parameters although not sure it is necessary.

 

I also created the enclosed favicon icons as I saw errors when accessing this docker with my Apple devices - unzip these and place them in the settings folder.

sonos-icon.ico.zip

 

Hope this helps - I actually have mine working on the Lan and even through Let's Encrypt reverse proxy - hoping to find some small wifi button that will fire off a url to this docker as a night table switch.

 

Edited by dstanley
Easier reading
Link to comment
  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.