jishi / node-sonos-http-api

An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.
http://jishi.github.io/node-sonos-http-api/
MIT License
1.83k stars 462 forks source link

Using the Presets file to play BBC Sounds Streams #834

Open planetWayne opened 2 years ago

planetWayne commented 2 years ago

Hi, Is it possible to get a preset file to play a BBC Sounds stream? I've tried creating a preset file that has the URI key in there with the results from a /state request when a BBC stream is playing thinking that may be enough but http-api ignores this preset file arguing about the json format. I'd quoted "" the URI as I would have thought it should be but no joy - I'm guess I'm missing something?

Thanks Wayne. (Such a pain that BBC has dropped off Tuned In and you can't store the channel as a factories on Sonos!... but hay ho)

jishi commented 2 years ago

If it complains about json syntax, you preset file is wrong. Please post example of the uri (as specified in json) and maybe someone can spot the error.

One shortcoming of the preset system is that you can't specify uri metadata which some services require for correct playback (at least, for getting the correct track info), so that might be a restricting factor for BBC.

On Sat, 16 Apr 2022, 16:20 planetWayne, @.***> wrote:

Hi, Is it possible to get a preset file to play a BBC Sounds stream? I've tried creating a preset file that has the URI key in there with the results from a /state request when a BBC stream is playing thinking that may be enough but http-api ignores this preset file arguing about the json format. I'd quoted "" the URI as I would have thought it should be but no joy - I'm guess I'm missing something?

Thanks Wayne. (Such a pain that BBC has dropped off Tuned In and you can't store the channel as a factories on Sonos!... but hay ho)

— Reply to this email directly, view it on GitHub https://github.com/jishi/node-sonos-http-api/issues/834, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYE2IZYBXYX2Q6KDZQ7YOTVFLED7ANCNFSM5TSOCDKA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

planetWayne commented 2 years ago

Hi Jishi, So a little bit of a 'my bad' - was using TextEdit (on a Mac) to edit the Json file, typically just been using TextWranger and noticed that some of the colours for the Json text didn't look right, turns out that the " that TextEdit uses was just wrong... I've corrected that now, so I don't get any complaints about the JSON being off, but still no joy with the URI... the result that comes back from calling the preset is a status 500... don't know if that helps ?

I've also tested this a little more with a TuneIn URI - same results...

So - Whilst I was typing this out, I've actually got the Sonos system to 'save' a favourite now for the BBC Sounds station - Am sure there was a way previously to tap on what was playing and store it to 'favourites' but if I now go seek and find the channel now I can add it to the Sonos 'My Sonos' list - to which the 'favourite' key now works again.... So, this issue, or at least what I was originally trying to do, is not a problem as such now, unless you want to still work on why the uri key doesn't invoke the stream?

All this being said, thank you for taking the time for a quick response, wasn't expecting that especially on a weekend! Cheers Wayne.

for reference, this is what I was getting back from calling a preset that had the uri set. { "status":"error", "error":"Got status 500 when invoking /MediaRenderer/AVTransport/Control", "stack":"Error: Got status 500 when invoking /MediaRenderer/AVTransport/Control at Object.invoke (/Node-Sonos/node-sonos-http-api-master/node_modules/sonos-discovery/lib/helpers/soap.js:99:10) at Player.setAVTransport (/Node-Sonos/node-sonos-http-api-master/node_modules/sonos-discovery/lib/models/Player.js:727:15) at /Node-Sonos/node-sonos-http-api-master/node_modules/sonos-discovery/lib/prototypes/SonosSystem/applyPreset.js:128:46 at processTicksAndRejections (node:internal/process/task_queues:96:5)", }

ashenshugarRET commented 2 years ago

Hello, You might want to also give the new BBC Sounds service within node-sonos-http-api a try, if you scroll to near the end of the readme file you'll find instructions on how to use it and the syntax for the station names. If you've managed to make the favourite functionality work for a station this bbcsounds/ command should work to :)

jishi commented 2 years ago

The 500 error is the sonos player responding that it doesn't allow or understand whatever is sent to it. So either the uri is wrong, or it needs additional info. Glad that a favorite works the other option would be to chain commands (preset, then setting BBC as source).

On Sat, 16 Apr 2022, 18:00 ashenshugarRET, @.***> wrote:

Hello, You might want to also give the new BBC Sounds service within node-sonos-http-api a try, if you scroll to near the end of the readme file you'll find instructions on how to use it and the syntax for the station names. If you've managed to make the favourite functionality work for a station this bbcsounds/ command should work to :)

— Reply to this email directly, view it on GitHub https://github.com/jishi/node-sonos-http-api/issues/834#issuecomment-1100697107, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYE2I3T65BZDARVF4AREW3VFLPYTANCNFSM5TSOCDKA . You are receiving this because you commented.Message ID: @.***>

planetWayne commented 2 years ago

Hi Both!, sorry for the delay, not had any compute time recently(!) day job getting in the way :( , since I managed to get the favourites (although its doesn't seem to be called a 'favourite' in the Sonos app now, which is what threw me off) its running back as it used to (flawlessly!) - I'm calling this the BBC's fault for forcing to move over to BBC Sounds app rather than stay with TuneIn :/

I must admit, for the URI, I was using the URI that gets returned from the '/state' page when a station is being played - so in the instance of the BBC Sounds station as an example x-sonosapi-hls:stations%7eplayable%7e%7ebbc_radio_two%7e%7eurn%3abbc%3aradio%3anetwork%3abbc_radio_two?sid=325&flags=288&sn=17 I guess that's not what what that refers to? (I've also tried the TrackURI which in that example is the same)

I must admit, I've got a homebridge plugin that uses your API to feed back to homebridge if a specific stream/ track is playing, so you could have a 'switch' that says that the 'Kitchen' is playing Radio 2 - so that for me, works well! Again, don't know if that was the intention for this but works great!

Thanks again.