Skip to content

Instantly share code, notes, and snippets.

@zackfern
Created April 28, 2023 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackfern/c9aab7c65e0cbb16684155fc866da821 to your computer and use it in GitHub Desktop.
Save zackfern/c9aab7c65e0cbb16684155fc866da821 to your computer and use it in GitHub Desktop.
A Home Assistant script to make a Sonos speaker join whichever speaker is currently playing
# Add this to your scripts.yaml file
join_playing_sonos:
description: "Make a Sonos spaker join whichever speaker is current playing."
fields:
target:
description: "Entity ID of the Sonos which you'd like to make join the group"
example: "media_player.office"
variables:
group_owner: '{{ state_attr((integration_entities("sonos") | select("is_state", "playing") | first), "group_members") | first }}'
sequence:
- alias: "Join Sonos to currently playing group"
service: media_player.join
data:
group_members:
- "{{ target }}"
target:
entity_id: "{{ group_owner }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment