Playing Sonos Favourites from script - where is the id?

So… as Radio Browser no longer plays 6 music, I’m trying to find other ways to do this. The Sonos integration has 6 music as a favourite and that plays fine manually, but I can’t see how to do it from a script. The docs say this:

action: media_player.play_media
target:
  entity_id: media_player.sonos_speaker1
data:
  media_content_type: "favorite_item_id"
  media_content_id: "FV:2/31"

… with no mention of how to find this info. I can’t see how you find the media_content_id; when the favourite is played from the Sonos card, the following is present in the State tab of Developer tools:

media_content_id: x-sonosapi-hls:stations%7eplayable%7e%7ebbc_6music%7e%7eurn%3abbc%3aradio%3anetwork%3abbc_6music?sid=325&flags=8488&sn=4

… which doesn’t work.

Anyone point me in the right direction? I’ve tried 'FV:2.2" (as I only have two favourites", but that give this:

I don’t use the Sonos integration, but the docs clearly state you should have a Sonos Favourites sensor available for every device.

Check your Sonoff Integration entities for that. If you can’t see it, double check if it’s disabled or hidden.

Edit: Right at the bottom of those docs, it states that the sensor is disabled by default. You just need to enable it.

Hi. Thanks - I’d already enabled it… wasn’t aware that I needed to look in the attributes for it to find the favourites listing (can’t see that anywhere in the documentation), so thanks for the pointer.

… but it still doesn’t work - script is as follows:

action: media_player.play_media
target:
  entity_id: media_player.big
data:
  media_content_type: "favorite_item_id"
  media_content_id: "FV:2/5: Radio 6 Music"

When running it I get the error:

The favourites isn’t available for every device, either? It’s a single one?

From the docs:
" When calling the media_player.play_media action, the media_content_type must be set to “favorite_item_id” and the media_content_id must be set to just the key portion of the favorite item."

Try this:

action: media_player.play_media
target:
  entity_id: media_player.big
data:
  media_content_type: "favorite_item_id"
  media_content_id: "FV:2/5"
1 Like

Thanks… FML, I tried that and it didn’t work, and now it does. Had an error about e status or similar previously. But now it seems to work, which is nice. :+1:

1 Like