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

Userlevel 2
Badge +2
Ok been testing presets in httpsonos and I believe we have a bug if error in preset file misspellings etc not in syntax the server needs to be rebooted other wise it will fail to read the next request for preset I see no errors in the log .but will keep looking.
Userlevel 2

code:

{
"all": {"players": [{ "roomName": "LittleRm", "volume": 23 },{ "roomName": "Living Room", "volume": 27 },{ "roomName": "Kitchen", "volume": 18 },{ "roomName": "Office", "volume": 22 },{ "roomName": "Master Bedroom", "volume": 17 },{ "roomName": "Rec Room", "volume": 0 }]},
"tv": {
"players": [{ "roomName": "Rec Room", "volume": 50 }],
"state": "stopped",
"uri": "x-rincon-stream:RINCON_0000000000001400"
},
"AcidJazz": {
"players": [{ "roomName": "Living Room", "volume": 27 },{ "roomName": "Kitchen", "volume": 18 },{ "roomName": "Office", "volume": 22 }],
"favorite": "Acid Jazz Radio"
},
"Thiev": {
"players": [{ "roomName": "Living Room", "volume": 27 },{ "roomName": "Kitchen", "volume": 18 },{ "roomName": "Office", "volume": 22 }],
"favorite": "Thievery Corporation Rdio Radio"
}
}




Hi You have missed the "," after ""Acid Jazz Radio" } " I added it in the code above.
New build of the web server seems to be working well.... Updated this afternoon, and just forced the replacement of the sonos-discovery....

Now onto the http-api.

Did a fresh git pull at the same time....

Now, when I load it... I'm getting this:

code:

binding SSDP to port 2594
scanning for players...
port in use 3500 trying new one
notification server listening on port 3501

module.js:485
throw err;
^
SyntaxError:[path]/node-sonos-http-api/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 [path]/node-sonos-http-api/server.js:12:13
at Object.cb [as oncomplete] (fs.js:168:19)


I figure I'm screwing up the presets.json, but I haven't quite figured how.

I took your sample, and removed all references to your players, and replaced with mine....

code:

{
"all": {"players": [{ "roomName": "LittleRm", "volume": 23 },{ "roomName": "Living Room", "volume": 27 },{ "roomName": "Kitchen", "volume": 18 },{ "roomName": "Office", "volume": 22 },{ "roomName": "Master Bedroom", "volume": 17 },{ "roomName": "Rec Room", "volume": 0 }]},
"tv": {
"players": [{ "roomName": "Rec Room", "volume": 50 }],
"state": "stopped",
"uri": "x-rincon-stream:RINCON_0000000000001400"
},
"AcidJazz": {
"players": [{ "roomName": "Living Room", "volume": 27 },{ "roomName": "Kitchen", "volume": 18 },{ "roomName": "Office", "volume": 22 }],
"favorite": "Acid Jazz Radio"
}
"Thiev": {
"players": [{ "roomName": "Living Room", "volume": 27 },{ "roomName": "Kitchen", "volume": 18 },{ "roomName": "Office", "volume": 22 }],
"favorite": "Thievery Corporation Rdio Radio"
}
}


I'm going to go back a few pages in the thread, and try that "test your file" link you posted J, and see if there's anything it complains about....
Userlevel 4
Badge +14
Yes for sure. It's a LG midrange smart TV launced this year 2013, I think it use some derivate of Chrome. At startup i looks real nice, but after a while some texts is overlayed but all functions works fine.
[edit] Checked and the scrollbars won't work, but the whole screen will scroll instead. Then Track, Artist, Album strings gets to long they will not do CR/LF instead they will move under the album picture and owerlaying the QUEUE text information.

I found if I don't display the "mini TV frame" in the smart TV browser the TV sound will automatically return then i quit the smart TV browser and start watching TV. Works perfect for me!


Yeah, I've heard that modern LG and Samsung is using a version of WebKit, but not sure which one. WebKit do however have some issues with my design because of the expected fixed window size. But for a TV, it would be better to create another UI which suits the format better, and which might be possible to control using the D-pad on the remote and similar. Unfortunately I don't have a smart-TV myself so I can't do any real testing. Next step is to try and create a mobile web UI which will be totally different than the official app, assuming that you can use the touch in an intuitive manner from a phone browser.
Userlevel 2
Badge +2
Yes and thanks that will work for now...
Userlevel 4
Badge +14
OK so how would one create a preset to u group a group playing and stop all.....Thanks

Ungroup all players? That's not possible with one preset today, you need to create one preset for each player.

If you just want to stop all of them, you can just send a pause signal for any player in the group (I assume you are talking about the HTTP API now)
Userlevel 2
Badge +2
OK so how would one create a preset to u group a group playing and stop all.....Thanks
Userlevel 2
Badge +2
Well my hats is off to you sir looking very good and As per the space thing I guess I was to blame will bang it more and let u know whats up but first blush and we are smiling Nice job
Userlevel 2
did the TV Browser work with this GUI?

Yes for sure. It's a LG midrange smart TV launced this year 2013, I think it use some derivate of Chrome. At startup i looks real nice, but after a while some texts is overlayed but all functions works fine.
[edit] Checked and the scrollbars won't work, but the whole screen will scroll instead. Then Track, Artist, Album strings gets to long they will not do CR/LF instead they will move under the album picture and owerlaying the QUEUE text information.

I found if I don't display the "mini TV frame" in the smart TV browser the TV sound will automatically return then i quit the smart TV browser and start watching TV. Works perfect for me!
Userlevel 4
Badge +14
Thanks for your quick answer.
Yes the PlayBar could be configured to autoswitch to SPDIF then the TV will output signal on the SPDIF.

My current solution is to switch the TV off and on. Also becuse it's a smart TV (not so smart att all) I like to control my music on the PlayBar from the TV browser.

For sure I will use the Raspberry Pi IR functions.
/Palle


did the TV Browser work with this GUI?
Userlevel 2

Doesn't the playbar have an auto line-in feature like all the other players though?


Thanks for your quick answer.
Yes the PlayBar could be configured to autoswitch to SPDIF then the TV will output signal on the SPDIF.

My current solution is to switch the TV off and on. Also becuse it's a smart TV (not so smart att all) I like to control my music on the PlayBar from the TV browser.

For sure I will use the Raspberry Pi IR functions.
/Palle
Userlevel 4
Badge +14

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?
Userlevel 2
Badge +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
Userlevel 4
Badge +14
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..


It shouldn't, are you sure about that? I have a few favorites with spaces and never had a problem.
Userlevel 2
Badge +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..
Userlevel 2
Badge +2
Thank You .....!;)
Userlevel 4
Badge +14
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.
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.
Userlevel 2
Badge +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>
Userlevel 4
Badge +14
Hm, yeah, it does seem correct. I will need to test it when I'm at home.
Userlevel 2
Badge +2
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"
}
}
Userlevel 4
Badge +14
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).
Userlevel 4
Badge +14
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
}
]
}
}
Userlevel 4
Badge +14
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.
Userlevel 2
Badge +2
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 .......