Sonos with node.js, my attempt!



Show first post
This topic has been closed for further comments. You can use the search bar to find a similar topic, or create a new one by clicking Create Topic at the top of the page.

397 replies

Badge
I've installed it on a different server own the network where I'm running many network services, as well as the original songs controller which works fine, and it's still not working, doing the same thing
Badge
I've tried that, no luck 😞
Userlevel 4
Badge +14
You could try disabling the firewall completely as a test. It might block the node process from opening a listening port.
Badge
Hi, its a windows server, windows 2012 Just connected to the network via normal network connection, wired, with an IP address on the same network as the Sonos. If I run the official controller, it works fine. I've disabled all firewalls and so on. If you mean the output from the command prompt when i run it, that is below:

C:\Node>node server.js
no settings file found, will only use default settings
info - socket.io started
http server listening on port 8888
queue-changed { uuid: 'RINCON_000E5825AA6C01400' }
getqueue 0 600
loading-queue: 133.683ms
Userlevel 4
Badge +14
Sounds like it doesn't find your system. Could you please provide the output from the console, and also describe the environment where you are running this? Device, operating system, how it is connected to your network and if you can run an official controller on that device, does it work?
Badge
Hi, i've just come across this effort for a web controller by you, it looks great and is exactly what i need for my home automation wall controller, but try as i can, i can't get anything to populate in the controller. I've installed it and can access it via the browser but it's just empty, no discovery etc. Am i doing something wrong?

Would really love to get the working.

Thanks
Userlevel 4
Badge +14
Thanks for the fast reply. It would indeed be fantastic if you could merge that functionality.
I'll definitely try to add some functionality as well. Unfortunately I'm not that good with javascipt but I'm working on it 🙂.


If you didn't notice, I merged this yesterday already, so feel free to play around with it!
Thanks for the fast reply. It would indeed be fantastic if you could merge that functionality.
I'll definitely try to add some functionality as well. Unfortunately I'm not that good with javascipt but I'm working on it 🙂.

Hello Jishi

Thanks for the amazing interface. I'm putting it to good use in my home automation setup.
I seem to be missing two things though:
- A call to get all sonos playlists (this already works for favorites)
- A way to play a specific url (e.g. a spotify url)
Am I looking in the wrong places? Anyway this would make the interface truly complete for me.

With regards


Hi, and thank you!

Getting the playlists are not part of the system as of now. The playlist support was added by a contributor but it shouldn't be very hard to add the functionality to retrieve the playlists. Unfortunately there are a lot of other requests that hasn't been done yet so I can give you any timeframe when I will have the time.

Playing spotify url is partially supported in a test-version that I've made. See this ticket: https://github.com/jishi/node-sonos-http-api/issues/113 I had the idea of merging that but honestly I forgot about it. I can add that in the coming day or 2, to make everybody happy. Disclaimer, it is beta, and doesn't support multiple accounts. That however should be fine for some user cases.
Userlevel 4
Badge +14
Hello Jishi

Thanks for the amazing interface. I'm putting it to good use in my home automation setup.
I seem to be missing two things though:
- A call to get all sonos playlists (this already works for favorites)
- A way to play a specific url (e.g. a spotify url)
Am I looking in the wrong places? Anyway this would make the interface truly complete for me.

With regards


Hi, and thank you!

Getting the playlists are not part of the system as of now. The playlist support was added by a contributor but it shouldn't be very hard to add the functionality to retrieve the playlists. Unfortunately there are a lot of other requests that hasn't been done yet so I can give you any timeframe when I will have the time.

Playing spotify url is partially supported in a test-version that I've made. See this ticket: https://github.com/jishi/node-sonos-http-api/issues/113 I had the idea of merging that but honestly I forgot about it. I can add that in the coming day or 2, to make everybody happy. Disclaimer, it is beta, and doesn't support multiple accounts. That however should be fine for some user cases.
Hello Jishi

Thanks for the amazing interface. I'm putting it to good use in my home automation setup.
I seem to be missing two things though:
- A call to get all sonos playlists (this already works for favorites)
- A way to play a specific url (e.g. a spotify url)
Am I looking in the wrong places? Anyway this would make the interface truly complete for me.

With regards
Userlevel 4
Badge +14
There is an official api.

You can get it by signing up here
http://musicpartners.sonos.com/


thanks Chris, but looks like this is music api for providing music service. What I meant is the sonos control api, like what Jishi did for "https://github.com/jishi/node-sonos-http-api". But for this server it requires either a laptop or hardware gadget to deploy. From sonos official, is there any similar solutions?


The only official way is to implement a UPnP based control point. Sonos follows that standard, with some proprietary additions, and is easily inspected with any UPnP scanner. However, it is overly complex for most minor tasks, and you need to keep track of states and handle events to get a fully functional API. My idea was to simplify that, primarily for crippled home automation systems that only handles simple HTTP calls.
There is an official api.

You can get it by signing up here
http://musicpartners.sonos.com/


thanks Chris, but looks like this is music api for providing music service. What I meant is the sonos control api, like what Jishi did for "https://github.com/jishi/node-sonos-http-api". But for this server it requires either a laptop or hardware gadget to deploy. From sonos official, is there any similar solutions?
Userlevel 7
Badge +22
There is an official api.

You can get it by signing up here
http://musicpartners.sonos.com/
does sonos has any official control api? or any gadget to route the control to cloud service?
Userlevel 4
Badge +14
Nice work, jshi! One question - do the Sonos APIs permit you to read current settings? For example, the current groupings and volume levels (including mute)? With this, a nice clean UI could be built to grab a snapshot of the current room settings to restore later.

If you could grab the current track name / artist / playlist and... dare I ask: album art?... then all kinds of nice UIs can be built for various devices.

Thank you in advance!
Philip


Hi, it's a bit unclear what you are asking, especially considering it is in this thread. Are you wondering if the Sonos players can be read directly for the stuff you asked? Some of the things are possible, through different "hacky" unsupported ways, but the main concept is the opposite: The players will inform you when stuff changes, if you ask for it. The follow a subscription pattern, where you will register an endpoint that will be called when the player deems appropriate. This is standard UPnP Eventing.

However, what I created, and this thread is mostly about, is the HTTP API bridge that I created, which do expose the stuff that you are asking about. It will keep track of the state of the players, and expose simple HTTP commands that you can query at any time, and you will receive a response. It also supports a "preset" function, where you can apply a preset according to your own setup, which includes grouping, preferred play source and volume levels.

And regarding UI, I have used the same underlying software to build a web based controller, as well as a web based "dashboard" that shows the currently playing song, you can see the examples here:

https://www.youtube.com/watch?v=_7Dke5LsTF0
https://www.youtube.com/watch?v=0x-Nhzd0ueg

Was that what you had in mind? The last video was using a Samsung signage display with a built-in computer, but it would be fairly simple to replicate that using a raspberry pi2 with the same setup, you are able to install a fairly recent version of Chromium and run that windowless on that ARM-platform. It might not be as smooth (the samsung screen had an atom processor I think) though.
Userlevel 2
Nice work, jshi! One question - do the Sonos APIs permit you to read current settings? For example, the current groupings and volume levels (including mute)? With this, a nice clean UI could be built to grab a snapshot of the current room settings to restore later.

If you could grab the current track name / artist / playlist and... dare I ask: album art?... then all kinds of nice UIs can be built for various devices.

Thank you in advance!
Philip
Userlevel 2
Hi jishi,

thanks a lot for your awsume package!!
I was looking for a possibility to remote control my Sonos Play 5 and came across your package.
My Play 5 is connected to a TV in my bedroom. So, I was "only" looking for a possibility to increase, decrease the volumne while watching TV.
I managed to install all this on a raspberry and it is just working great. 🙂
I even somehow managed with my basic knowledge to integrate a "shutdown" command on a key press of my remote. As my raspberry is connected via USB Y-cable to my television, I thought that this might be better than just switch off the power. :-)

Thanks a lot again for your work on this package. Keep going 🙂
Userlevel 2
All I am trying to do is stop my kids from messing with the other players in the house and a guest when they come over just be able to control their room and not mess with the other the best way o thought was to just make a call to the web program remove the list of other players in the page ( hide them) and allow control for that player only as per groups etc I wanted to keep it simple if it was part of a group and the room was called it would be removed from the group and work on its own options to add to a group and other fancy stuff really not needed just need to select fav play stop etc many thanks for getting back Regards

Robert
Userlevel 4
Badge +14
First thank you for all you amazing work could you be so kind to direct me to how to force a player via the command line such as the following:
call to your web interface

http://192.168.1.160:8080/index.htm#RINCON_000E5813DC720140

this way i can force a specific player thus locking the interface from a user messing with another player.

Can see where to set the var: ( ps not areal programmer just learning) Thank you Robert


Are you trying to lock it down using some sort of widget load of the web interface (where a user can't manually change the URL)? Because otherwise it will be kind of pointless. You also need to consider how you want it to act if that player is grouped to another one. Allow access or not?
Userlevel 2
First thank you for all you amazing work could you be so kind to direct me to how to force a player via the command line such as the following:
call to your web interface

http://192.168.1.160:8080/index.htm#RINCON_000E5813DC720140

this way i can force a specific player thus locking the interface from a user messing with another player.

Can see where to set the var: ( ps not areal programmer just learning) Thank you Robert
Badge
Sorry - I just posted a new thread. This is not related to your code, but I found it interesting that you experienced a similar problem as me with text to speech announcements repeating a little of the text.

Hi, I think you need to refresh my memory and explain what the repeating issue was, or explain the symptoms that you are seeing, and I'll see if I can help. You are using SonosPy, correct? So it's more of a network/logic issue than directly related to my libraries? Maybe you should create a new topic where we can discuss this, to not add off-topic discussions to this thread.
Userlevel 4
Badge +14
Jishi - did you ever solve for the repeating issue? Full disclosure - I am the author of a Sonos plugin for the Indigo home automation system. I have the same problem, but have been unable to figure out a solution.

Hi, I think you need to refresh my memory and explain what the repeating issue was, or explain the symptoms that you are seeing, and I'll see if I can help. You are using SonosPy, correct? So it's more of a network/logic issue than directly related to my libraries? Maybe you should create a new topic where we can discuss this, to not add off-topic discussions to this thread.
Badge
Jishi - did you ever solve for the repeating issue? Full disclosure - I am the author of a Sonos plugin for the Indigo home automation system. I have the same problem, but have been unable to figure out a solution.

Well, apart from the repeating issue, it still works the same way? I take it that the regrouping isn't an issue for you?
Userlevel 4
Badge +14
I just pushed an update to sonos-http-api with an attempt for a "announce everywhere" function, and then restore.

I know a few home automationers have been wanting this for a while, so try it out and see if it is useful.

I'll try and add a page later to control this or for "on the fly" announcements.
Userlevel 2
I added an "off" value that does it instead. Seemed more intuitive.


Thanks sleep() works super now.

And your "volume change hook" code is also upp and running.