I want an automation to step the volume of my chromecast audio.
This is working but i want to control the size of the steps.
Now it jumps 0,1 up for example.
This is to much to find a comfortable volume. 0,05 would be nice.
Is there a way to do this?
Not sure if you can adjust the default step. You can probably just use the volume_set service with a value_template and get current plus whatever amount you want.
Untested:
script:
volume_up:
sequence:
service: media_player.volume_set
entity_id: media_player.YourPlayer
data_template:
volume_level: '{{ states.media_player.YourPlayer.attributes.volume_level + 5 }}'
Thank you.
Works great.
Really like this about Home Assistant.
There is always a solution.
Thanks again.
Thanks for the advice.
Here is what I had to setup to get this code to work on my system:
data_template:
volume_level: '{{ states.media_player.basement_office.attributes.volume_level - 0.02}}'
entity_id: media_player.basement_office
service: media_player.volume_set
I hope this helps someone. I used it on a Russound MCA-88.
I had to use this method too with my sonos speakers. Now the max possible value for volume is 1, so adding “5” gave me errors.
Thanks for the tip!
I have also been struggling with this issue. I encountered an error with the format. It was resolved using state_attr
. The YAML code for the script is as follows:
alias: vol++
sequence:
- service: media_player.volume_set
data:
volume_level: "{{ state_attr('media_player.wlan_box', 'volume_level') + 0.05 }}"
target:
entity_id: media_player.wlan_box
mode: single
icon: mdi:volume-plus
Hi, how did you get this to work?
I created a script with this but I got:
Failed to perform the action script/vol. Error rendering data template: TypeError: unsupported operand type(s) for +: ‘NoneType’ and ‘float’
OK So eventually this version worked, however only when the Chromecast is on.
alias: vol++
sequence:
- data:
volume_level: "{{ state_attr('media_player.chromecast_dining_room', 'volume_level') + 0.1 }}"
target:
entity_id: media_player.chromecast_dining_room
action: media_player.volume_set
mode: single
icon: mdi:volume-plus
description: ""
If it’s off, it throws the error “Failed to perform the action script/vol. Error rendering data template: TypeError: unsupported operand type(s) for +: ‘NoneType’ and ‘float’”