Keep esphome rotary volume controller in sync with volume level

Hello,

I have created a rotary encoder volume controller for my Google home devices accuring to: https://devices.esphome.io/devices/Rotary-Encoder-Volume-Control
This all works fine, except for one thing: If I change the volume on the Google home speaker, the rotary encoder does not know this. Next time I touch the rotary encoder, it does not increase or decrease to the next step in volume but it jumps directly to the old volume level from the rotary knob.
I would like to change the rotary encoder value on the esphome board whenever the volume changes initiated from the Google home speaker or the HA dashboard.

And suggestions on how to achieve this?

Kind regards, Remco

I find it easier to just use the rotary encoder on_clockwise and on_anticlockwise to bump the volume up or down. In other words, the esp has no knowledge of the state of the volume.

2 Likes

Thanks for your fast response, I tried the Volume_up route but it only works in 10% increase/decrease steps. That is a bit to coarse for me. I like the 1% steps.

Gr. Remco

Try


    on_clockwise:
      - homeassistant.service:
          service: media_player.volume_set
          data_template:
            entity_id: media_player.whatever
            volume_level: "{{ state_attr('media_player.whatever', 'volume_level') + 0.01 }}"

Thanks,

That did the trick, this works perfect…

Gr. Remco

1 Like