If I do this via the media player card, I don’t see where the event is logged. “Amy Winehouse Radio” is a favorite on my Sonos device, and I’ve seen suggestions that it’s trivial if it’s a Sonos favorite. It’s trivial from the card, but trying to wire this up to a smart button.
1 Like
The behaviour of the SONOS favourites has changed in 2022.4, instead of calling select_source
you now need to call play_media
, however, select_source
still works.
This should work:
- Go to:
- Under “Listen to events”, in the “Event to subscribe to” text field, enter
call_service
and click “START LISTENING” - Play your favourite in the SONOS App or via the frontend card.
- An event should now show up, looking like this:
{
"event_type": "call_service",
"data": {
"domain": "media_player",
"service": "play_media",
"service_data": {
"entity_id": "media_player.room_a",
"media_content_id": "FV:2/56",
"media_content_type": "favorite_item_id"
}
},
"origin": "LOCAL",
"time_fired": "2022-04-26T09:59:10.679020+00:00",
"context": {
"id": "6936fb11c237aebf521454340b4feefa",
"parent_id": null,
"user_id": "2e3068a7a91e3ea7e0daf434e1682718"
}
}
- Take note of the
service
andservice_data
, this is the data you need to call theplay_media
service.
I don’t know how the FV:2/56
string is constructed, but it seems like it’s just an incrementing number.
Personally, I’m in the process of migrating towards directly calling the URL I want to play like documented here.
2 Likes
You can use the “Play media” action in the script/automation editor. You can browse directly to the favorite and behind the scenes it will build out a media_player.play_media
service call with all the necessary parameters. Hit “Edit in YAML” and you can re-use the service call elsewhere:
3 Likes
I think the easiest way is:
- Use your Sonos app to play something on your Sonos device e. g. named “mysonos”
- in Homeassistant, go to Developer Tools/States
- find entity media_player.mysonos and click on it
- YAML Field above will show all data including media_content_type and media_content_id