Files
mop-skills/skills/sonos-media-playback/SKILL.md
T

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

  1. Find the room player: homeassistant__ha_search_entities with domain_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.
  2. 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.
  3. If the player is paused or idle, wake it with media_player.media_play so Spotify Connect may register it.
  4. Resolve the requested music. Prefer, in order:
    • spotify__search for playlist/track URIs, then play via the Spotify MCP play tool. If play returns 404 "No active device found": call spotify__get_devices, pick the room-matching device, and retry play with that device_id explicitly.
    • If Spotify search errors or no Spotify device is active: get the player state with ha_get_state and read its source_list (Sonos favorites). Pick the favorite closest to the requested genre (e.g. dark techno -> ChilloutTechno, sets -> Fusion 2026 Sets), then ha_call_service(domain="media_player", service="select_source", data={"source": "<favorite>"}).
  5. Verify: ha_get_state on the entity shows playing with media_title/media_playlist and the requested volume_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 any spotify: URI on Sonos: returns HTTP 500 regardless of media_content_type (music/playlist) — skip it and go straight to source_list favorites.
  • Repeated retries of a failing spotify__search with different arguments: the failure is server-side; fall back once, then use favorites.