Play a web radio station via REST API

I’m trying to extend my Volumio set-up using the REST API to remote control various bits. So far I’ve got the basics in place, but web radio is eluding me.

At the moment I’ve got toggling play/pause working via http://192.168.0.220/api/v1/commands/?cmd=toggle plus various other of the commands listed in the API page.

However I’m struggling a bit with web radio stations. I’ve got a few set up and working fine in my web radio via the web GUI, but I’d like to be able to remotely switch between them. I’m presuming the command I want is http://192.168.0.220/api/v1/replaceAndPlay but I’m not sure what the relevant payload would be and how to add that to the command.

At the moment I’m sending the commands using either a simple batch file (using curl) or via a Python3 script. It’s working fine for the toggle commands, but can someone give me an example of what the correct command for replaceAndPlay would be (or if there’s a better way of doing this)?

It may not be what you want but…If I remember correctly (I’ll need to check…) I have saved playlists with the web radio and call the playlist via REST API.

Thanks. That’s an interesting workaround (which works with individual playlists for each station).

I’d still be interested to know if it’s possible with replaceAndPlay, so know what the actual command would be.

@DarrenHill,

as i am playing with remote control right now, i got it working
KEY_COMPOSE 1 curl -i --header "Content-Type: application/json" localhost:3000/api/v1/replaceAndPlay --data '{"service": "webradio", "type": "webradio", "title": "Bayern3", "uri": "http://opml.radiotime.com/Tune.ashx?id=s14991"}'

Just replace the KEY… with your desired Key and change the uri to your favorite radio station.

AxLED

@AxLED - thanks :smiley:

The playlist route actually worked better, as I can also use the next/previous keys on the remote to switch between stations, rather than going the original route I was thinking to have preset “favourite” keys for each individual station.

But I’ll certainly make a note of your method too for future use in case I do want to go that way for specific stations in the future. It’s all working nicely though, routing stuff via Home Assistant and using some Ikea Tradfri remotes to control my Volumio Pi’s.