INFO
Source code here: https://github.com/jishi/node-sonos-http-api
Sonos Web Controller draft (work in progress!): https://github.com/jishi/node-sonos-web-controller
Sonos IR control (requires lircd and IR reciever): https://github.com/jishi/node-sonos-remote-control
==============================================================
I know that there already is an attempt at this by this guy: http://forums.sonos.com/showthread.php?t=32643, but I found it to be a bit lacking in functionality so I decided to write up my own.
I have created a simple web-based API using what I have, which could be useful for integrating stuff with other applications. This web based API is inspired by other RESTful APIs, however I don't think it follows the correct guidelines to be called a REST API.
IT supports most basic features like:
play, pause, seek, next, prev, volume, mute, setAVTransportURI
It also supports these advanced fatures:
State of player as JSON, zone info as JSON, Play favorite item, presets (grouping, volume, avTransportURI)
You can read more in the README for each project.
To run it as a service under linux, I suggest using pm2 (https://github.com/Unitech/pm2). You need to run it in forked mode (-x)!
For Windows, you might try Winser http://jfromaniello.github.io/winser/
Cheers!
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.
Page 13 / 16
does sonos has any official control api? or any gadget to route the control to cloud service?
Hm, yeah, it does seem correct. I will need to test it when I'm at home.
There is an official api.
You can get it by signing up here
http://musicpartners.sonos.com/
You can get it by signing up here
http://musicpartners.sonos.com/
Userlevel 2
throwing this error
thank you
C:\sonos1>node server.js
binding SSDP to port 2188
scanning for players...
notification server listening on port 3500
module.js:485
throw err;
^
SyntaxError: C:\sonos1\presets.json: Unexpected string
at Object.parse (native)
at Object.Module._extensions..json (module.js:482:27)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at C:\sonos1\server.js:12:13
at Object.cb [as oncomplete] (fs.js:168:19)
C:\sonos1>
thank you
C:\sonos1>node server.js
binding SSDP to port 2188
scanning for players...
notification server listening on port 3500
module.js:485
throw err;
^
SyntaxError: C:\sonos1\presets.json: Unexpected string
at Object.parse (native)
at Object.Module._extensions..json (module.js:482:27)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at C:\sonos1\server.js:12:13
at Object.cb [as oncomplete] (fs.js:168:19)
C:\sonos1>
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 2
Jishi,
If you provide a template (unless it's there and I didn't notice 🙂 then I can test on PS3 to see how it acts.
If you provide a template (unless it's there and I didn't notice 🙂 then I can test on PS3 to see how it acts.
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
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
Seems like your presets.json contains some invalid syntax, you could try and verify the syntax in some online tool: http://jsonlint.com/ first
The second error is due to a change I did yesterday which I didn't foresee. I'll try and fix that later.
The second error is due to a change I did yesterday which I didn't foresee. I'll try and fix that later.
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.
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.
I'll definitely try to add some functionality as well. Unfortunately I'm not that good with javascipt but I'm working on it 🙂.
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 2
Thank You .....!;)
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!
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
Would really love to get the working.
Thanks
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?
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
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 2
Will give it try could it be names with a space I know that if you have a space in fav name it fails...
Thanks..
Thanks..
You could try disabling the firewall completely as a test. It might block the node process from opening a listening port.
Thanks..
It shouldn't, are you sure about that? I have a few favorites with spaces and never had a problem.
I've tried that, no luck 😞
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
Userlevel 2
I will double check and get back after i update the files but no all the rooms are correct but they do have spaces....will test and forward logs thank you again
ok here's the weird thing. If I reboot the Sonos so the queues are clear, then start the server.js, it shows this:
C:\Node>node server.js
no settings file found, will only us
info - socket.io started
http server listening on port 8888
As soon as I add songs to the queue with the official app, this get's added to the console
queue-changed { uuid: 'RINCON_000E5825AA6C01400' }
getqueue 0 600
loading-queue: 375.074ms
So it's definitely detecting something with regards to the player, but not showing this on the UI or allowing me to interact
C:\Node>node server.js
no settings file found, will only us
info - socket.io started
http server listening on port 8888
As soon as I add songs to the queue with the official app, this get's added to the console
queue-changed { uuid: 'RINCON_000E5825AA6C01400' }
getqueue 0 600
loading-queue: 375.074ms
So it's definitely detecting something with regards to the player, but not showing this on the UI or allowing me to interact
Yeah, since it got a uuid, I would assume that the events actually works. Do you get any errors in your console in the browser?
I have one SONOS PlayBar and it's no prblem to manage music/radio on it but I also would like to be able to switch to the TV sound (optical SPDIF).
In org SONOS i select TV input as a source "TV" the same way I do for Spotify, Rado etc.
Any clue?
Unfortunately you can't add a line-in as a favorite, and listing music library and line-ins aren't the priority for now. Great info though, since I don't have a playbar myself, wasn't aware of the different URI format for spdif line in.
I will probably finish presets before I start with music browsing, and in that case you will be able to specify "x-sonos-htastream:RINCON_000E5XXXXXXX01400:spdif" as a preset uri (you could be able to bind this to an IR remote if you get a IR receiver to your raspberry).
Doesn't the playbar have an auto line-in feature like all the other players though?
do you mean the UI in the browser? then no, i just see the UI with nothing populated in it
Page 13 / 16
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.