Sonos Binding - Start Apple Music Playlist

Hi all,

I’m on the release of 2.5 via OpenHABian and am trying to get a playlist to start on the Sonos. I can get commands to execute, but can’t get a playlist - created in Apple Music and added to the Sonos App - to play. I can’t get a radio station that is added to work either.

rule "Play Plalist"
when Item V_Sonos_Test received command
then 
logInfo("Test", "Playlist")
sendCommand(SonosKitchen_PlayURI,""). // this successfully stops whatever playing
sendCommand(SonosKitchen_ClearQueue,ON)
// sendCommand(SonosKitchen_Radio,"Easy 99.1")
sendCommand(SonosKitchen_PlayPlaylist,"Morning Options"). // no change in Sonos app 
sendCommand(SonosKitchen_Volume, "8") // this works
sendCommand(SonosKitchen_PlayQueue, ON)  // no change in Sonos app
end

I’ve spent some time searching and testing combos but can’t get it to work. Any ideas?

Did you add it in a Sonos playlist having the name “Morning Options” ?
Maybe you rather add it as a Sonos favorite ?
Enable DEBUG logs to see what is reported: log:set DEBUG org.openhab.binding.sonos

Thanks for the reply, Lolodomo… I will try tonight!

I haven’t honed my debugging skills/settings yet, so this will force me to do that!

No luck…

2020-01-04 21:06:02.092 [nt.ItemStatePredictedEvent] - SonosKitchen_PlayPlaylist predicted to become Morning Options

2020-01-04 21:06:02.101 [nt.ItemStatePredictedEvent] - SonosKitchen_Volume predicted to become 8

2020-01-04 21:06:02.111 [nt.ItemStatePredictedEvent] - SonosKitchen_PlayQueue predicted to become ON

2020-01-04 21:06:02.127 [vent.ItemStateChangedEvent] - SonosKitchen_PlayPlaylist changed from BBC to Morning Options

==> /var/log/openhab2/openhab.log <==

2020-01-04 21:06:02.163 [DEBUG] [s.internal.handler.ZonePlayerHandler] - Playlist 'Morning Options' not found

any additional thoughts?

If I add the AM playlist to a new Sonos Playlist, and use that, the songs play. It seems there must be some type of identifier for the Apple Music playlists that do not show up in the logs, but I’m not a coder so who knows…

The playlist channel is to play Sonos playlists.
So finally it works as expected?

I can do what I want to do, but not how I want to do it. I’d like to be able to modify playlists in Apple Music and have them visible to the Sonos binding, but it appears that the binding can only play Sonos playlists. Thus I need to go into the Sonos app, select the Apple Music playlist and add it to a Sonos playlist. Good enough for now.

This post was flagged by the community and is temporarily hidden.

Do you have a solution? I add something as a Sonos favorite and use items and rules like this:

// Items
String SonosKitchen_PlayFavorite “[%s]” { channel=“sonos:PLAY1:RINCON_XXXXXXXXXXXX01400:favorite” }

//Rule
sendCommand(SonosKitchen_PlayFavorite,“Morning Options”)

1 Like

Thanks for the post @to.bi - exactly what I was looking for.

The inability to add an Apple Music Station to a Sonos Playlist appears to be a hard limit of that integration.

There seems to be a number of other interesting/odd limitations on how things work with as @alfista2600 mentioned above.

As you pointed out though, marking the Apple Music Station as a Sonos Favorite does the trick, and allows playing the station with OpenHab.

Wow… while driving to work today, I thought that I should post my workaround to this problem…and having forgot I was reminded when you replied.

If you have the Amazon Echo Control binding in your ecosystem, you can update the ‘TextCommand’ channel with what would be a spoken word command (e.g. Play disco hits in the kitchen’) and Alexa silently does your bidding.

I then use the Sonos control script to enable other speakers as needed.