Volume Condition Question

I have a Denon AVR that i am trying to automate the volume on source change. When using the apple tv the volume has to be turned up because apple tv’s are known for having lower volume output. When i change it back over to direct tv if i have not turned down the volume it is way to loud. What i have done is made an automation on source change. I have the automation working except when i add a condition. The other problem i have is it can have a delay if you use the remote so you still have the loud sound for a second or so. I’m not sure we are going to be able to address the second issue but can you let me know what is wrong with my condition.

  - alias: 'Normalize Sound'
    trigger:
    - platform: template
      value_template: "{{ is_state_attr('media_player.reciever', 'source', 'SAT') }}"
    condition:
      - condition: template
        value_template: "{{ state_attr('media_player.receiver','volume_level') > 0.49 }}"
    action: 
      - service: media_player.volume_set
        data_template:
          entity_id: media_player.receiver
          volume_level: 0.50

what’s the problem with the condition? Looks like it should work. It’s a bit odd that you are checking to see if the volume is above 0.49 and if it is set it to 0.50. I’d expect you to check if it’s above 0.50 and set it to 0.50.

Ya i guess your right on checking if its above 50 to set to 50.

Strange. I put the code back in and now its working. Im not sure why it was not working before but now it is. Thanks for looking

1 Like

One more question. How do i say > 50 and != 0. I set it to 0 when playing playstation since im using headphones.

well the automation should only run when it’s above 50, so it will never be equal to zero. You can omit that whole check.

No. With this automation it is when i am going back to satellite. The 2 times i would like it to run are if the volume is above 50 (coming from apple tv) or equal to 0 (coming from ps4). In both instances i would like it set to 50

ooh ok, yeah then do this:

"{{ state_attr('media_player.receiver','volume_level') > 0.50 or state_attr('media_player.receiver','volume_level') == 0 }}"
    

that worked great. Thanks

1 Like