Start Spotify Radio with Sonos binding

With Spotify it’s possible to start a radio station using any song as a starting point. Would it be possible to trigger this with the Sonos binding? Maybe mark a song a as a favorite and use this a as parameter to a start radio function? Might be a long shot but would be useful for me :smiley:

I don’t understand your idea… do you want to get the name of a song or artist from Sonos binding and want to create a playlist in Spotify?

No, Spotify has this functionality where you can start a ‘radio station’ based on a song. This starts playing songs like the song you selected, but without a predetermined playlist. That’s what I want to start from the binding.

Spotify has a web api for that and there are already apps and services using it for doing that.

What I would try is to define the radio “playlist” as Sonos favorite and start this one using OpenHab. I haven’t tried it myself but according to the doku it should work.


1 Like

Cool, that actually works! :slight_smile: Didn’t know it was possible to add a station to favorites in the Sonos app. I can now start the station by sending ‘My Song Radio’ to the favorite item. Thanks!

sounds cool - do you have a code snippet for that?

Sure… I’ve added a selection item to my sitemap that makes it possible to easily play a radio station, Spotify playlists and now also Spotify radio stations on a Sonos speaker. I’ve added the stations/playlists/Spotify radio station to my favorites and used the names of those in the rules below.


Selection item=Sonos_Ensuite_Preset label="Preset" mappings=[1="DeepFM", 2="Zen FM", 50="All Out 80's", 51="All Out 90's", 52="I'm Gonna Be (500) Miles) Radio"]


Number	Sonos_Ensuite_Preset	
String	Sonos_Ensuite_Favorite		(Sonos)		{sonos="[ensuite:favorite]"
String	Sonos_Ensuite_Radio		(Sonos)		{sonos="[ensuite:radio]"}


import org.eclipse.xtext.xbase.lib.*

val Functions$Function2 sendPreset = [ int preset, String item |
	var String station = ""; 
	switch (preset) {
		case 1: {
			station = "DeepFM"
		case 2: {
			station = "Zen FM"	
		// and so on
	sendCommand(item, station)

val Functions$Function2 sendFavorite = [ int favorite, String item |
	var String fav = ""; 
	switch (favorite) {
		case 50: {
			fav = "All Out 80's"
		case 51: {
			fav = "All Out 90's"
		case 52: {
			fav = "I'm Gonna Be (500) Miles) Radio"
	sendCommand(item, fav)

rule "Preset Ensuite"
	Item Sonos_Ensuite_Preset received update
	var Integer preset = (Sonos_Ensuite_Preset.state as DecimalType).intValue
	if (preset < 50) 
		sendPreset.apply(preset, "Sonos_Ensuite_Radio")
		sendFavorite.apply(preset, "Sonos_Ensuite_Favorite")

thank you very much - will try

Today I enabled the sonos 2.1 binding. I do not see all these channels described in the link above:

I have heard that sonos changed something their last release. Does Selecting favorites still work?

Hit the More button in the upper right. Though I’ve been unable to get Favorites to work:

@lukics I can confirm that Favorite does work in OH2. I had a typo in my rule.

for me it does work