jishi/node-sonos-http-api

Using the Presets file to play BBC Sounds Streams

planetWayne opened this issue · 5 comments

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

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)",
}

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

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.