Need help with volume slider

I have a volume slider in my frontend controlling the volume of my Chromecast Audio.
Sometimes the volume starts jumping up and down. Not only visual, the audio geting high, low, high, low…
This is how my automation looks like.

#Volymslider>chromecast väggen
 - alias: volume slider vaggen
   hide_entity: true
   trigger:
     platform: state
     entity_id: input_slider.volume_vaggen

   action:
     service: media_player.volume_set
     data_template:
       entity_id: media_player.vaggen
       volume_level: '{{ trigger.to_state.state }}'
#Chromecast>Volymslider
 - alias: vaggen volume slider
   hide_entity: true
   trigger:
     platform: state
     entity_id: media_player.vaggen

   action:
     service: input_slider.select_value
     data_template:
       entity_id: input_slider.volume_vaggen
       value: '{{ states.media_player.vaggen.attributes.volume_level }}'

Logbook:

15:30
Volym changed to 0.14999984204769135
15:30
vaggen volume slider has been triggered
15:30
volume slider vaggen has been triggered
15:30
Volym changed to 0.1999998390674591
15:30
vaggen volume slider has been triggered
15:30
volume slider vaggen has been triggered
15:30
Volym changed to 0.14999984204769135
15:30
vaggen volume slider has been triggered
15:30
volume slider vaggen has been triggered
15:30
Volym changed to 0.1999998390674591
15:30
volume slider vaggen has been triggered
15:30
vaggen volume slider has been triggered
15:30
Volym changed to 0.14999984204769135
15:30
vaggen volume slider has been triggered
15:30
volume slider vaggen has been triggered
15:30
Volym changed to 0.1999998390674591
15:30
vaggen volume slider has been triggered
15:30
volume slider vaggen has been triggered

This is what i get in my log sometimes.

17-05-31 15:31:40 ERROR (MainThread) [homeassistant.core] Invalid service data for input_slider.select_value: expected float for dictionary value @ data['value']. Got ''

Any thoughts?

I do the same for my sonos playbar, but I have a condition as well.

################################## 
### Sonos Volume Slider Control ##         
##################################           


  - alias: "Playbar - Volume Link (Device > Slider)"
    trigger:
      - platform: state
        entity_id: media_player.sonos_playbar
    condition:
      - condition: template
        value_template: "{{ not is_state_attr('media_player.sonos_playbar', 'volume_level', states('input_slider.playbar_volume')|int / 100) }}"
    action:
      - service: input_slider.select_value
        data_template:
          entity_id: input_slider.playbar_volume
          value: "{{ trigger.to_state.attributes.volume_level | multiply(100) | int }}"

  - alias: "Playbar - Volume Link (Slider > Device)"
    trigger:
      - platform: state
        entity_id: input_slider.playbar_volume
    condition:
      - condition: template
        value_template: "{{ not is_state_attr('media_player.sonos_playbar', 'volume_level', states('input_slider.playbar_volume')|int / 100) }}"
    action:
      - service: media_player.volume_set
        data_template:
          entity_id: media_player.sonos_playbar
          volume_level: "{{ states('input_slider.playbar_volume')|int / 100 }}"   

I also multiply or divide by 100 so the slider can read as a percent

1 Like

Thank you.
I tried it but can’t get it working.
I changed my input_slider to:
Min: 1
Max: 100
Steps: 1
The Chromecast Audio volume steps is in 0.01 - 1.0
But if i raise my volyme from the chromecast i small bit the input_select change it back.
What can i change to make this work?

Have you tried steps: 10?

No.
Wouldn’t it give me even bigger steps?
Now it feels like if I make a small volume change, it is to small to move the input_select and that is why the intput_select-automation change the volume back.
This is how the volume state looks like for the Chrome Cast:

volume_level: 0.05999999865889549

How about these settings:

  initial: 0.5
  min: 0
  max: 1
  step: 0.05

These seem to work across my Chromecast devices.

Hmm isn’t one automation triggering the other all the time, why not disable the other while updating then re-enable when finished, do that for both and it might solve the problem?

My setting for the input slide is:

  min: 0
  max: 1
  step: 0.01

If 0.05 works, shouldn’t 0.01 work?

Yes this is what’s going on.
But it isn’t always.
Only sometimes this happens.
How to turn off the other automation?
Action:
Homeassiatant_turnoff
The other automation
Update state
Homeaasostant_turnon
The other automation
Not the cleanest way but it should work? Right?
Any other suggestions?

Not sure, maybe it’s too granular.

Yep, use …

service: automation.turn_off/turn_on

The problem disapeared now for a while.
Right now, I’m trying 0,05 steps for the slider.
If it doesn’t solve it i will turn the other automation off, then on after state change.

Thanks guys.

1 Like