I'm using Music Assistant and have a Sonos system with 6 speakers including a soundbar. I need an automation to unjoin the soundbar from the player group and transfer its queue to the other players when the TV is turned on. Specifically:
Retrieve the list of group_members for the Soundbar
Check if the Soundbar is the master player (first member) in the group_members attribute
If it is, transfer the queue to the next member of the group and then join back the remaining players (which get unjoined when the queue is transferred)
If the Soundbar was not the master player then simply unjoin it from the group
I understand the Actions to perform these functions but my yaml and jinja2 skills are pretty bad so could use some help getting started with the script that retrieves and iterates through the member attribute list. Thanks.
I ended up solving this myself as it was much simpler than I expected. Again, the purpose is to remove the Sonos Soundbar from the media player group that it is a member when the TV is turned on. If the soundbar was the master, then transfer the queue to the next player in the member list and add the previous members back. This is necessary since either removing the master or transferring the queue destroys the player group.