Increment media_player volume

I am attempting to increment the volume of a Google home mini device by doing something like:

service: media_player.volume_set
data:
  volume_level: {{ state_attr('media_player.master_bedroom_speaker', 'volume_level') + (1 /100)}}
target:
  entity_id: media_player.master_bedroom_speaker

However, it doesn’t do anything when called from the Services tab to test it out.
Note: I used (1/100) because attempting to use something like .1 gave me:

TemplateSyntaxError: unexpected ‘.’

So then I attempted to create a script:

service: media_player.volume_set
  data_template:
    entity_id: media_player.office_speaker
    volume_level: {{ state_attr('media_player.office_speaker', 'volume_level') + .1 }}

But when trying to save out the script I get:

Message malformed: template value is None for dictionary value @ data[‘sequence’][0][‘data’]

Am I doing something wrong? I have seen other examples with similar solutions… (e.g. https://community.home-assistant.io/t/media-control-volume-steps/190309/2?u=rtbrown560)

Were you able to fix it?

Nope. I just been using the “increment volume” service call to the media player (iterated on 4-5 times or while volume is below 40%). It works, but isn’t smooth at all.

Shouldn’t you just put the template between double quotes?

"{{ ... }}"

And use 0.1 instead of .1

Thank you so much! That did solve it:

service: media_player.volume_set
data:
  volume_level: "{{ state_attr('media_player.office_speaker', 'volume_level') + 0.1 }}"
target:
  entity_id: media_player.office_speaker

Note: the google home mini in my case doesn’t have the volume attribute unless it is already playing something

1 Like