How to play Sonos Favorites since 2022.05?

Since the removal of source_list attribute in Sonos media_player entity, and the introduction with 2022.05 of sensor.sonos_favorites, I can’t figure out how to play one of my sonos favorite playlist with media_player.

I used to simply call this:

service: media_player.select_source
target:
  entity_id: media_player.basement
data:
  source: SportsMotivation

and, as ‘SportsMotivation’ was in the media_player.basement source_list, it worked just fine.
But it does not work anymore.

The sensor.sonos_favorites looks like

items:
  FV:2/213: SportsMotivation
  FV:2/212: Favorite Tracks
unit_of_measurement: items
icon: mdi:star
friendly_name: Sonos Favorites

so how can I play the SportsMotivation playlist on my sonos (media_player.basement) is a mystery to me …

is it because you’re missing the quotes?

service: media_player.select_source
data:
  source: >-
    {{ ['Soft Jazz Sax', 'Disco Essentials', 'Chill House', 'Chill Synthwave',
    'Classical in Spatial Audio', 'Dinner Party', 'Electronic in Spatial Audio',
    'Good Vibes Only', 'Jazz in Spatial Audio'] | random}}
target:
  device_id: d0a7ecf729f5e419975ebddd8454ab16

Mine definitely works, I just tested it again to be sure.

2 Likes

The problem was indeed with quotes. I don’t know when/how the quotes were lost in the way. I put them in YAML (with Visual Studio Code or in UI) but they disappear after HA restart.

So I by-passed this using your templating method, but with only 1 entry

data:
  source: >-
    {{ ['SportsMotivation'] | random}}

and it does the trick.

Thanks for your help

1 Like