Skip to main content

Sonos with node.js, my attempt!

  • March 5, 2013
  • 391 replies
  • 109564 views

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.

391 replies

Forum|alt.badge.img+2
  • Lyricist III
  • November 26, 2013
Thank You .....!;)

Forum|alt.badge.img+2
  • Lyricist III
  • November 27, 2013
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..

Forum|alt.badge.img+14
  • Author
  • Headliner II
  • November 27, 2013
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.

Forum|alt.badge.img+2
  • Lyricist III
  • November 27, 2013
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

Forum|alt.badge.img+14
  • Author
  • Headliner II
  • November 27, 2013

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?

  • Lyricist III
  • November 27, 2013

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

Forum|alt.badge.img+14
  • Author
  • Headliner II
  • November 27, 2013
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?

  • Lyricist III
  • November 27, 2013
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!

Forum|alt.badge.img+2
  • Lyricist III
  • November 27, 2013
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

Forum|alt.badge.img+2
  • Lyricist III
  • November 27, 2013
OK so how would one create a preset to u group a group playing and stop all.....Thanks

Forum|alt.badge.img+14
  • Author
  • Headliner II
  • November 27, 2013
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)

Forum|alt.badge.img+2
  • Lyricist III
  • November 27, 2013
Yes and thanks that will work for now...

Forum|alt.badge.img+14
  • Author
  • Headliner II
  • November 27, 2013
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.

  • Trending Lyricist I
  • November 27, 2013
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....

  • Lyricist III
  • November 28, 2013

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.

Forum|alt.badge.img+2
  • Lyricist III
  • November 28, 2013
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.

  • Trending Lyricist I
  • November 28, 2013
Hi You have missed the "," after ""Acid Jazz Radio" } " I added it in the code above.

Thanks... I tried the "," after both new presets, didn't realize that you need to not have it after the last one.....

OK, so now the server is starting....

Connecting through a browser and using:

:5005/presets/Thiev/Play

Output on the screen:

code:

{ room: 'presets', action: 'AcidJazz', value: 'play' }
{ room: 'presets', action: 'Thiev', value: 'Play' }


But it's not doing anything to the players....

If I do the

code:

:5005/office/favorite/thievery corporation rdio radio


It was starting the stream.... with the current grouping. I was also able to stop it.

Thoughts?

Forum|alt.badge.img+14
  • Author
  • Headliner II
  • November 28, 2013
Thanks... I tried the "," after both new presets, didn't realize that you need to not have it after the last one.....

OK, so now the server is starting....

Connecting through a browser and using:

:5005/presets/Thiev/Play

Output on yeah,I think screen:

code:

{ room: 'presets', action: 'AcidJazz', value: 'play' }
{ room: 'presets', action: 'Thiev', value: 'Play' }


But it's not doing anything to the players....

If I do the

code:

:5005/office/favorite/thievery corporation rdio radio


It was starting the stream.... with the current grouping. I was also able to stop it.

Thoughts?


yaEah, I think you are sending in /play at the end of the URL,which yuou shouldn't, it confuses it.

only invoke /preset/thiev and you should be golden.

Forum|alt.badge.img+14
  • Author
  • Headliner II
  • November 29, 2013
Just to make sure, there can be no end slash either, or it will interpret the command incorrectly.

  • Trending Lyricist I
  • November 29, 2013
Just to make sure, there can be no end slash either, or it will interpret the command incorrectly.

Check.... no trailing slash... unless chrome is "auto" adding....

Sample:

:5005/presets/test2

Forum|alt.badge.img+14
  • Author
  • Headliner II
  • November 29, 2013
Check.... no trailing slash... unless chrome is "auto" adding....

Sample:

:5005/presets/test2


Well, it should be /preset/test2, it will parse it errorneous if you call it "presets", unfortunately.

Forum|alt.badge.img+2
  • Lyricist III
  • November 30, 2013
Player playing display.....I saw you created a page to display what is playing etc could you or would you send it our way to play with many thanks

Robert

PS rasberry on its way oh boy more confusion on my life thanks again really enjoying your stuff and learning slow but learning

Forum|alt.badge.img+14
  • Author
  • Headliner II
  • November 30, 2013
Player playing display.....I saw you created a page to display what is playing etc could you or would you send it our way to play with many thanks

Robert

PS rasberry on its way oh boy more confusion on my life thanks again really enjoying your stuff and learning slow but learning


Well, I can't really distribute it as is since it is both only Spotify centric (only works for spotify tracks because I download high-res covers from their web services), and because the font used is copyrighted. I will need some work to adjust this and have like a last.fm fallback for the cover arts or something.

Forum|alt.badge.img+2
  • Lyricist III
  • December 1, 2013
No worry could you just create a simple example showing how to display in simple formatted

the return from the http call ip/zone/state I am trying but getting no where fast .... thank you Robert

Forum|alt.badge.img+14
  • Author
  • Headliner II
  • December 2, 2013
I can't reproduce that error. What is Office playing when you try and request the state? What does http://192.168.1.50:1400/status/perf say as current track?