Sonos Get Speaker Volume and Set Grouped Speakers to Same Volume

Don’t want to use the Sonos App to turn the volume up on all active / grouped speakers. Try an Automation

When Volume Up or Volume Down are clicked on the Apple TV remote, or the LG TV remote, only the Sonos Beam Sound Bar volume goes up.

I set an Automation that is triggered when the volume_level state changes on the Livingroom Sonos Beam. The automation passes off the livingroom speaker’s volume to a script. The script takes the livingroom’s current volume level and sets all of the currently grouped speakers to that same volume. This way when the volume goes up on the main livingroom speaker, the volume goes up on all of the other 5 - 7 speakers (depending on if you currently have them grouped / playing).

With this setup, people who come over do not have to download the Sonos app to change the volume on all of the grouped Sonos speakers. Without this automation, when someone pushes volume up on the TV, only the livingroom speaker volume goes up. The other 5-7 speakers stay at a quieter volume. Worse yet, when they are trying to turn the volume down the volume on the other speakers is loud and unchanged. With this automation, they just turn up the volume and the volume goes up on all of the other grouped speakers as expected.

For any home setup, it is good when people don’t have to think about how to work a device. People just want to pick up a remote without any teaching or frustration. With this setup, they are able to use the Sonos speaker functionality with a mostly positive experience. For now, this does what I need it to do, and allows my wife / friends to enjoy all of the speakers and not just the one speaker that the remote can control by default.

In the future, it could be useful to make improvements. When the livingroom volume goes up or down, the other grouped speakers could go up or down by that same amount. This could allow people to set the left speaker to be a bit quieter and the right speaker to be a bit louder proportionally. This could be useful when sitting closer to a speaker and want to keep that volume a bit lower than the primary speaker, but still want it to turn up or down when the primary speaker is adjusted. For instance, when this automation is turned off, I tend to set each of the speakers to a specific volume based on how far they are from people in the house at that time. Then I adjust the volume of the group and it adjusts the volume proportionally for all of the other speakers.

Automation

alias: Livingroom_SyncVolume_to_Group_Members
description: ""
trigger:
  - platform: state
    entity_id: media_player.living_room
    attribute: volume_level
condition: []
action:
  - service: media_player.volume_set
    data:
      volume_level: "{{state_attr('media_player.living_room','volume_level')}}"
    target:
      entity_id: "{{state_attr('media_player.living_room','group_members')}}"
mode: single

Script

alias: sonos_set_volume
fields:
  sonos_id:
    description: ID of Sonos
sequence:
  - condition: template
    value_template: "{{ state_attr(sonos_id, 'sonos_group') | count > 1 }}"
  - delay:
      milliseconds: 200
  - service: media_player.volume_set
    target:
      entity_id: "{{ state_attr(sonos_id, 'sonos_group') }}"
    data:
      volume_level: "{{ state_attr(sonos_id, 'volume_level') }}"
mode: single
icon: mdi:volume-equal
1 Like

The script appears to require a small correction because instead of referencing the Media Player attribute named group_members it references sonos_group.

Thanks for your assistance here. Also, as far as I can tell, when I went to update this in the script, I found out that the script portion is not actually needed. All that is needed for this is the automation.

This still helped me to better understand how the Automation works. While looking at your suggestion, I noticed that the script had not ran in months, and the volume automation is working just fine without it.

made an account just to say thanks for this automation!

I have a beam and 2 bookshelf speakers from ikea and when linked in surround sound, they sound weird - so i’ve been juggling volumes with the app and a zigbee remote but inevitably my kids end up with one speaker so much louder than the others and I got to kill it with the app.
I tried homekit, an esp ir receiver to mimic the tv remote (turns out my tv uses CEC/RF), looked into my tvs native mqtt server but the cert situation was a barrier - and here you go with a native HA automation! So elegant!
Thanks a million for this as i’ve been revisiting every few months when i leave the speakers on way to loud and my kids turn on the TV at 7am on a saturday and the the TV remote only turns down the beam and I’m scrambling to turn down the other speakers in the sonos app so my wife doesn’t wake up screaming about how i have no control over our “computerized home”. Today you were the John Connor to my wife’s Skynet and I thank you for it.