Capture Sonos volume change as trigger?

I’m beginning to feel in over my head… I have 2 sonos speakers in my basement. I want their volume to always stay in-sync. So my initial thought was that I wanted an automation that triggered on a change in volume, then set the unchanged speaker volume to == the changed speaker volume…

This opened a can of worms. I found this thread from early 2018 outlining a similar path to keeping sonos speaker volumes in sync. So it seems there’s no (or wasn’t in 2018) way to capture the trigger of a volume change, and new sensors need to be created. Is that still the case in mid 2021? If that is the case, could someone point me toward how to create those sensors? the OP of the 2018 post does have lines that seem to be creating volume and volume_changed sensors, but I’m apparently completely ignorant on how to create those within HA. I tried playing with the template developer tool, I tried adding the lines to my configuration file, I tried editing the lines and adding them to configuration (adding template:, - sensor:, -name:) but nothing has worked, resulting in logs that I have invalid config for template, extra keys not allowed @ data value_template for all 4 sensors I tried creating. Not incredibly surprising since I have no clue what I’m doing, but a bit frustrating still as I try to figure this out. Has anyone else done something similar to the 2018 OP, know of some new additions to HA to make this easier, or able to dumb it down for me enough to get the new sensors created?

1 Like

Hi. I had a similar case where I wanted to put my Sonos port into the pass-through mode so that it always outputs full level and then change the volume on a connected AVR whenever the volume (or rather the volume indicator) changed in the Sonos app similar to the “Works With Sonos” feature on some select AVRs (but not my old one). I am very new to HA, but my brother solved it for me, and the trigger was as easy as choosing “State”, as the trigger type, the Sonos Port (or speaker) as the entity, and “volume_level” as the attribute. The yaml code is

- id: "1651778856855"
  alias: Volume Change on Sonos Port
  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: media_player.pioneer_avr
  mode: single

This should work also in your case with the obvious modifications of names.