Volume Adjustment in Smaller Increments

I’m currently using this script to adjust the volume of the speakers connected to my Chromecast Audio:

alias: AllHome Volume Down
  - service: media_player.volume_down
      entity_id: media_player.allhome
    data: {}
icon: mdi:volume-minus

There is another script for Volume Up and they both work fine, in principle.

But I’m looking for a solution to adjust the volume in smaller increments than the 10% steps that the standard volume_up/volume_down service seems to offer.

I could probably retrieve the current absolut volume value, calculate what the value for a 5% increase would result in, and push it with a media_player.volume_set final step.

I’m wondering, though, if there’s a simpler solution, maybe similar to what I’m using for my thermostat:

alias: A/C S&W One Down
  - data_template:
      entity_id: climate.lyric_gerstmeyers_thermostat
      temperature: >-
        {{ state_attr('climate.lyric_gerstmeyers_thermostat', 'temperature')|int - 1 }}
    service: climate.set_temperature

I’m looking for a solution that I can implement with e.g. an icon in a glance card, not an input_number slider - that’s way too fidgety on a phone.

Anybody got any great ideas?

I’m not sure you could considering:

If the service only supports 0.1 increments you cant use it to push 0.05 increments.

That’s why I was thinking about retrieving the current value and pushing the new one rather than dealing with the limitation that comes with using the increments of the media_player.volume_down service.

Figured it out, though.

My issues were - once again - with the indentations and quotes when using a template:

  - service: media_player.volume_set
      entity_id: media_player.allhome
      volume_level: '{{ state_attr(''media_player.allhome'', ''volume_level'') - 0.05 }}'
mode: queued
1 Like

@chairstacker This helped me since I have a similar issue with the 10% increments on my Anthem receiver. Thanks for posting your solution.

But, I’m also finding that I cannot seem to get a Volume Up and Down script to both load. All I’m changing is the name, alias, and sign of the increment in the template, but after reloading Scripts, I only see one of them under services. Did you run into this as well?

Not sure what you mean with ‘to both load’ - my scripts both show up in the dashboard at /config/script/dashboard

I got it to work. I think I had an indentation error from copy/pasting.

Now that I have it working though, I’m much more aware that one of my receivers has a linear volume response while the other seems to be a 4th order polynomial. It should be logarithmic, but not so.

1 Like

this worked for my Samsung Q700B soundbar system, changed to 1% increments “0.01”

1 Like