esjay
(Steven Jowell)
November 8, 2016, 8:29am
1
I have set up a slider to contro volume of myAVR with a slider. How do I get the slider to update if the volume is adjusted manually. In other words trigger an automation to set the value of the slider. My config for the slider control is as follows:
media_player:
platform: denon_avr
host: 192.168.1.101
name: Denon AVR
input_slider:
denon_volume:
name: Volume
initial: 0.3
min: 0
max: 1
step: 0.01
automation 4:
alias: Denon - Adjust Volume
trigger:
platform: state
entity_id: input_slider.denon_volume
action:
service: media_player.volume_set
data_template:
entity_id: media_player.denon_avr
volume_level: ‘{{ trigger.to_state.state }}’
1 Like
rpitera
(Robert Pitera)
November 8, 2016, 1:03pm
2
Please post your code properly so that any issues with formatting can be ruled out.
To post code with formatting intact, highlight the code blocks and then press the preformatted text option button as indicated in the image below.
esjay
(Steven Jowell)
November 8, 2016, 1:44pm
3
Thanks…completely new to this. Formatted code below. As I said, the code is working fine. It sthe next step of feeding back information to the slider where I don’t know where to begin.
media_player:
platform: denon_avr
host: 192.168.1.101
name: Denon AVR
esjay
(Steven Jowell)
November 8, 2016, 1:45pm
4
media_player:
platform: denon_avr
host: 192.168.1.101
name: Denon AVR
input_slider:
denon_volume:
name: Volume
initial: 0.3
min: 0
max: 1
step: 0.01
automation 4:
- alias: Denon - Adjust Volume
trigger:
platform: state
entity_id: input_slider.denon_volume
action:
- service: media_player.volume_set
data_template:
entity_id: media_player.denon_avr
volume_level: '{{ trigger.to_state.state }}'
Airpal
(Arijit Pal)
December 27, 2016, 10:29am
5
Any luck implementing the volume feedback to slider ?
Exactly trying to do this, but unable to find a suitable trigger.
devdelay
(devdelay)
January 9, 2017, 12:47am
6
- alias: Music Volume Select
trigger:
platform: state
entity_id: media_player.music
action:
service: input_slider.select_value
data_template:
entity_id: input_slider.music
value: >
{{ states.media_player.music.attributes.volume_level }}
1 Like
Stewface
(Stewart)
February 27, 2017, 10:47am
8
Has anyone had any luck getting this working with Sonos?
I have set it up but it will only update the volume at 1… and go back to 0, nothing in between (e.g. 0.1 - 0.3 etc where sonos needs the volume set)
volume:
name: Volume
initial: .2
min: 0
max: 1
step: 0.01
- alias: Kitchen Sonos Volume Slider
trigger:
platform: state
entity_id: input_slider.volume
action:
- service: media_player.volume_set
data_template:
entity_id: media_player.kitchen
volume_level: '{{ trigger.to_state.state | int }}'
Stewface
(Stewart)
February 27, 2017, 10:57am
9
I also tried it the way mentioned above but that didn’t work at all for me.
- alias: Kitchen Music Volume Select
trigger:
platform: state
entity_id: media_player.kitchen
action:
service: input_slider.select_value
data_template:
entity_id: input_slider.music
value: >
{{ states.media_player.kitchen.attributes.volume_level }}
input slider:
music:
name: Sonos Volume
initial: .2
min: 0
max: 1
step: 0.01
outrun
(Lukas Ecklmayr)
February 27, 2017, 11:29am
10
Hi @Stewface
I think you use the wrong trigger for your automation.
Your Automation must run, when the Volume is changed.
I’m using for my denon:
- alias: Denon Volume
trigger:
platform: state
entity_id: input_slider.volume_setpoint
action:
- service: media_player.volume_set
data_template:
entity_id: media_player.denon
volume_level: '{{ states.input_slider.volume_setpoint.state}}'
So for you it should like:
- alias: Kitchen Music Volume Select
trigger:
platform: state
entity_id: input_slider.sonos_volume
action:
- service: media_player.volume_set
data_template:
entity_id: media_player.kitchen
volume_level: '{{ states.input_slider.sonos_volume.state }}'
This is untested and maybe don’t work. But it should be something in this direction.
2 Likes
benjimatt
(Matthew Henry Marshall)
February 27, 2017, 12:28pm
11
input_slider.yaml
living_room:
name: Living Room
initial: 0.3
min: 0
max: 1
step: 0.01
kitchen:
name: Kitchen
initial: 0.3
min: 0
max: 1
step: 0.01
Automation.yaml
- alias: living_room - Adjust Volume
trigger:
platform: state
entity_id: input_slider.living_room
action:
- service: media_player.volume_set
data_template:
entity_id: media_player.living_room_speakers
volume_level: '{{ trigger.to_state.state }}'
- alias: kitchen - Adjust Volume
trigger:
platform: state
entity_id: input_slider.kitchen
action:
- service: media_player.volume_set
data_template:
entity_id: media_player.kitchen_speakers
volume_level: '{{ trigger.to_state.state }}'
# second part of volume
- alias: kitchen - Volume
trigger:
platform: state
entity_id: media_player.kitchen_speakers
action:
- service: input_slider.select_value
data_template:
entity_id: input_slider.kitchen
value: '{{ states.media_player.kitchen_speakers.attributes.volume_level }}'
- alias: living room - Volume
trigger:
platform: state
entity_id: media_player.living_room_speakers
action:
- service: input_slider.select_value
data_template:
entity_id: input_slider.living_room
value: '{{ states.media_player.living_room_speakers.attributes.volume_level }}'
this is working fine for me. Check the spaces though because I dont think im using the </> thing correctly.
3 Likes
Stewface
(Stewart)
February 28, 2017, 10:26am
12
@benjimatt - WORKING!!! WAHOOOO!!
I’ve been wanting to get this working for so long… THIS IS AMAZING!
2 Likes
Stewface
(Stewart)
February 28, 2017, 10:59am
13
It works perfect for Sonos… thank you so much…
Any ideas why the same script might not work with my sony bravia TV?
Interestingly I noticed even the volume control slider on the pop up dialog doesn’t work (only the clicking the volume icons will adjust the volume)
svente08
(Svente08)
July 13, 2017, 5:15am
14
Hi… Looking good but seems not working in Version 47?
Output looks good but nothing happens.
Sven
alias: wohnzimmer - Adjust Volume
trigger:
platform: state
entity_id: input_slider.sonos_lautstaerke_wohnzimmer
action:
service: media_player.volume_set
data_template:
entity_id: media_player.wohnzimmer
volume_level: ‘{{ trigger.to_state.state }}’
alias: wohnzimmer room - Volume
trigger:
platform: state
entity_id: media_player.wohnzimmer
action:
service: input_slider.select_value
data_template:
entity_id: media_player.wohnzimmer
value: ‘{{ states.media_player.wohnzimmer.attributes.volume_level }}’
input_slider:
sonos_lautstaerke_wohnzimmer:
name: Vol. Wohnzimmer
initial: 0.2
min: 0
max: 1
step: 0.01
good evening,
i try this in the HA v. 0.57.2
my Code work with 3x Sonos:
Input_number.yaml
sonos_lautstaerke:
name: Lautstärke
initial: 6
min: 1
max: 20
step: 1
automation.yaml
#### Sonos-Lautstärke
- alias: Sonos Lautstärke
trigger:
platform: state
entity_id: input_number.sonos_lautstaerke
action:
- service: media_player.volume_set
data_template:
entity_id:
- media_player.schlafzimmer
- media_player.wohnzimmer
- media_player.kueche
volume_level: '{{ trigger.to_state.state | multiply(0.1) }}'
- alias: living room - Volume
trigger:
platform: state
entity_id: media_player.schlafzimmer
action:
- service: input_number.set_value
data_template:
entity_id: input_number.sonos_lautstaerke
value: '{{ states.media_player.schlafzimmer.attributes.volume_level }}'
And this work, the volume change if i switch the slider… but one Problem:
the log say:
WARNING (MainThread) [homeassistant.components.input_number] Invalid value: 0.09 (range 1.0 - 20.0)
someone has an idea?
VDRainer
(🍻)
November 7, 2017, 8:10pm
16
What if you set the input_number min
value to 0?
it’s change automatic to 0, when i change the volume…
With this works now perfect!
input_number.yaml
sonos_lautstaerke:
name: Lautstärke
initial: 0.14
min: 0.01
max: 0.2
step: 0.01
automation.yaml
#### Sonos-Lautstärke
- alias: Sonos Lautstärke
trigger:
platform: state
entity_id: input_number.sonos_lautstaerke
action:
- service: media_player.volume_set
data_template:
entity_id:
- media_player.schlafzimmer
- media_player.wohnzimmer
- media_player.kueche
volume_level: '{{ trigger.to_state.state }}'
#volume_level: '{{ trigger.to_state.state | multiply(0.1) }}'
- alias: living room - Volume
trigger:
platform: state
entity_id: media_player.schlafzimmer
action:
- service: input_number.set_value
data_template:
entity_id: input_number.sonos_lautstaerke
value: '{{ states.media_player.schlafzimmer.attributes.volume_level }}'
2 Likes
Tribune
December 14, 2017, 6:40pm
19
Thanks for these two automations. However, I guess they sometimes can end up in some kind of feedback loop, where one automation is triggered since the other changed the slider. Whenever I change the volume from outside of HASS, I will get this feedback loop. Is there any way to not have the set volume automation triggered if the input_number was updated by the second automation?
1 Like
Just an FYI on Input_Number. When you look at the examples at the componants page you will see that the automations use "data_template: rather than “data:”. Hassio users like myself, will have to open your automations.conf file and manually edit the entry, changing “data:” to “data_template:” I beat my head against the wall for quite some time before I realized that.