Linking the volume of two speakers

Hi,

I want to link two HEOS devices so that when the volume is changed on one (using the hardware controls) this is picked up in HA and the other device mirrors the volume.

I have done this fairly easily with an automation however I can only make it work if I set a pre-determined value for the mirrored device. I want to read the volume_level attribute from the device that has been changed and apply it to the other device however I cannot make it work.

alias: Pair Bedroom Speaker Volumes
description: ''
trigger:
  - platform: state
    entity_id: media_player.bedroom
    attribute: volume_level
condition: []
action:
  - service: media_player.volume_set
    data:
      volume_level: {{ state_attr('media_player.bedroom','volume_level') }}
    target:
      entity_id: media_player.dining_room
mode: parallel
max: 10

This is my automation. Can anyone help me achieve this? Is it possible?

Many thanks in advance.

Is that not working?
It seems correct to me.

Thanks for the response.

The automation is triggered however the volume of the second device is not changed. If I set it to a static value rather than reading the attribute it works correctly.

I’m stumped.

volume_level: {{ state_attr('media_player.bedroom','volume_level') | float }}

When I get stumped, it’s usually a filter that is missing.

I have something that does same, i took it from Petro AV setup. You’ll need to strip the specific on the devision and rounding, but the trigger.to_state is the hint i suppose

  action:
    service: media_player.volume_set
    data_template:
      volume_level: '{{ (1.0 + trigger.to_state.state | float / 100.0 ) | round(2)
        }} '
      entity_id: media_player.yamaha_receiver

you’re missing quotes around the volume_level template. Use the double quote "

1 Like

Thanks for the responses. It was the double quotes that fixed it. I also used the float filter.

Greatly appreciated.

the float filter is not needed.

Thank you. I will remove it.

I was able to use this thread to sync my speakers. Wouldn’t have been able to do it without this. Thank u!