Skip to main content
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!
Nothing is playing all q empty
Nothing is playing all q empty



That's not what I asked 🙂 I want you to do this:



Add a queue to a player (local tracks or something).



Play a Pandora favorite, does it say (queue not in use)?
got it ...sorry



no it does not .......

test steps

added something to q

entered localhost:5005/office/favorite/carlos



played fine then



tried to change to new fav and failed



hope that helps....
Perhaps I'm jumping into a sea where I don't know what I am doing, but the space between "r o" in "object.item.audioItem.audioBr oadcast" seems out of place. Perhaps this is just an artifact of a message text capture.
Yeah, I saw that too, but I think that's because the windows console doesn't word wrap correctly.



Robertboca, I want you to test what I said with the official app, not my stuff.
Step away from the thread for a few days.... wow... looks like I miss all kinds of changes...



So just for reference J.....



code:

websonos │ 0 │ fork │ 8405 │ online │ │ 0 │ 47h │ 46.367 MB │ /root/.pm2/logs/websonos-err.log

-rw-r--r-- 1 root root 0 Nov 11 20:48 websonos-err.log
-rw-r--r-- 1 root root 318495 Nov 22 16:55 websonos-out.log


This is interesting though:
./node-sonos-web-controller/
-rw-r--r-- 1 root root 22371372 Nov 22 16:55 notification.log




Been running on the linux vm (ubuntu 12.10) for 47 hours now straight. With average use around here.... Got only 46 megs in use right at this moment.... The log file.... isn't bad size anymore either.



Great job.... thus far. I think I'm on 0.4.x still since I haven't grabbed the git code since monday or tuesday.



I'll pull in the latest now, and see how it does.



BTW, since you suggested it... I've been finding that even running an npm update for the sonos-discovery manually, I still have needed to delete the directory and npm install.... Most of the other stuff, like socket.io and static don't need the extra work.
Yes got it it



It says Queue Not in use....



Sorry did not understand 😃
So I updated the version.... to the latest git from 5:00pm EST ....



When I go to use the favourites to start a stream out of rdio.... I find that it just sits there. No change. If I have the desktop controller open and visible, I see that it "flashes" for a second, but no change.



If I have one playing started through the desktop controller, I can start or resume the stream without issue.



I grabbed the pm2-service-out.log I'll pm it to you, since I don't have time right now to strip out the macs.....



Slacker seems to suffer the same issue.



Tuned in, or even the jazzradio/di.fm premium seem to work OK though.
I think I know what's going on. Just out of curiosity steelrat, did those favorite use to work?



I'll try and find a permanent fix for the radios when I get the time, now I have some more references to work with.
Captured on the windows xp netbook.... (it was easier)...



PM'd you J with the answer for the SetAvTransport.



If you need more from the stream let me know. I'll probably try to grab a slacker one tomorrow....
Thank you everyone for your feedback, I think I have resolved some of the radio problems now.



Make sure that you are using v 0.7.5 of the sonos-discovery module, and try again.



Regarding the notification.log and positioninfo.log, they are debuglogs that I have used, and will be removed when I feel like I don't need them anymore. You will have to live with them for a while longer 🙂
Looking very good ! Que seems to function well and the server sees no errors radio to local content and back 😉 will bang on it some more thank you...
Confirmed here too....



Both the rdio, and slacker streams are starting from the websonos favourites list.



Memory use seems to be 35->45 meg here.... over extended runs of 24->48 hours.



Just an FYI though.... I've seen this bug when forcing the sonos-discovery to reinstall after deleting the directory. No impact other then seeing it...



code:

node_modules# npm install sonos-discovery
npm WARN package.json sonos-web-controller@0.5.4 No repository field.
(next line is this)
npm http GET https://registry.npmjs.org/sax
(skipping some normal output)
.....
npm http 304 https://registry.npmjs.org/html-entities
npm http 200 https://registry.npmjs.org/xml2js
sonos-discovery@0.7.5 sonos-discovery
...
└── sax@0.5.5




Well done sir. This is definitely coming together....


npm WARN package.json sonos-web-controller@0.5.4 No repository field.

(next line is this)





Is it that one you are wondering about? Or the scrambled output from the sax install?
Just a Observation of the Index page not tablet friendly. Fav cannot be selected by touch group can not be moved etc. Aslo will you be updating the other lib to reflect the new que changes. Many thanks again...
Just a Observation of the Index page not tablet friendly. Fav cannot be selected by touch group can not be moved etc. Aslo will you be updating the other lib to reflect the new que changes. Many thanks again...



I will not make this layout tablet friendly, mainly because the layout itself isn't tablet friendly, nor the controls. The plan is to implement alternate layouts for mobile and tablet (/m, /t) with different behaviors. Hopefully they can be a bit more user friendly than the current mobile apps (which I think is a pain to use). I have already made a custom /dashboard version: http://upload.grabbarna.se/files/IMG_20131125_105225.jpg which runs on one of the screens here at work. It took me about 30 minutes to complete, because all of the backend is already in place. Most of the time was just to implement client-side interaction with Spotify to get high resolution images of the tracks.



And the queue changes doesn't affect the http-api atm. I'm not sure if a "seek" instruction should switch back to the queue and start playing it through a http API to be honest?
Bravo I agree and will await your plans......



As per the http-api the fav radio function seems to be broken when asking for a fav the server sees the request but nothing happens not even errors even when i sens the /fav it comes back empty. PS both servers running in windows as long as you start http first then web it seems happy .......
Bravo I agree and will await your plans......



As per the http-api the fav radio function seems to be broken when asking for a fav the server sees the request but nothing happens not even errors even when i sens the /fav it comes back empty. PS both servers running in windows as long as you start http first then web it seems happy .......




Well, they both use the same component, "sonos-discovery" so when I updated it for the web controller, I also fixed the favorites for the http api. Just delete the sonos-discovery folder under node_modules and run npm install again, and restart it. I might have introduced some bugs iin the http-api with the recent updates, I haven't tested it at all personally, but just let me know if you find any troubles and I will try and fix them.
Seems like your preset is broken?



It should look like this:



code:

{
"all":{
"players":[
{
"roomName":"Bathroom",
"volume":10
},
{
"roomName":"Kitchen",
"volume":10
},
{
"roomName":"Office",
"volume":10
},
{
"roomName":"Bedroom",
"volume":10
},
{
"roomName":"TV Room",
"volume":15
}
]
}
}

So I did a redesign of my TV dashboard template and created a video of it.



http://www.youtube.com/watch?v=0x-Nhzd0ueg&feature=youtu.be



It would be interesting to see how well it would look in a regular home consumer TV web browser, like samsung or whatever (or even a PS3/Xbox or similar).
Ok so where am I missing some thing this is my preset file and it bombs every time....Sorry to be ....Ps love the interface



{

"all":{

"players":[

{

"roomName":"Bathroom",

"volume":10

},

{

"roomName":"Family Room",

"volume":10

},

{

"roomName":"Office",

"volume":10

},

{

"roomName":"Bedroom",

"volume":10

},

{

"roomName":"Living Room",

"volume":15

}

],

"state": "stopped",

"favorite": "carlos",

"playMode": "normal"

}

}
Hm, yeah, it does seem correct. I will need to test it when I'm at home.
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>
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.
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.