2.1 KiB
2.1 KiB
name, description
| name | description |
|---|---|
| sonos-media-playback | Play music on Sonos speakers via Home Assistant; when Spotify search or play_media fails, use Sonos source_list favorites. |
Sonos Media Playback
Play music (genre, playlist, artist, "50% volume") on a room Sonos via Home Assistant MCP.
Steps
- Find the room player:
homeassistant__ha_search_entitieswithdomain_filter="media_player"and the room name (German room names match, e.g. "bad" ->media_player.bad). Done when one media_player entity is found. - Set volume first with
ha_call_service(domain="media_player", service="volume_set", data={"volume_level": <0-1>})— this works even while the player is paused/idle. Percent requested / 100. - If the player is
pausedoridle, wake it withmedia_player.media_playso Spotify Connect may register it. - Resolve the requested music. Prefer, in order:
spotify__searchfor playlist/track URIs, then play via the Spotify MCPplaytool. Ifplayreturns 404 "No active device found": callspotify__get_devices, pick the room-matching device, and retryplaywith thatdevice_idexplicitly.- If Spotify search errors or no Spotify device is active: get the player state with
ha_get_stateand read itssource_list(Sonos favorites). Pick the favorite closest to the requested genre (e.g. dark techno ->ChilloutTechno, sets ->Fusion 2026 Sets), thenha_call_service(domain="media_player", service="select_source", data={"source": "<favorite>"}).
- Verify:
ha_get_stateon the entity showsplayingwithmedia_title/media_playlistand the requestedvolume_level. Report title and volume to the user; offer the nearest alternative favorite if the genre match is loose.
Do not retry
ha_call_service(media_player, play_media)with anyspotify:URI on Sonos: returns HTTP 500 regardless ofmedia_content_type(music/playlist) — skip it and go straight tosource_listfavorites.- Repeated retries of a failing
spotify__searchwith different arguments: the failure is server-side; fall back once, then use favorites.