I have three ‘alarm clocks’ that I can set to turn on the lights and play an alarm tone. One in my bedroom, one in the kids’ room, and one in the living room. They all work perfectly. Each has two input sliders, one for the hour and one for the minute so you can set the time for the alarm to go off.
What I want to achieve is a ‘master switch’ so that I can set all 3 at the same time. I have set up a group with two input sliders on it, one for hour and one for minute. The idea is to set those and press a button to run a script, and the script will set the 3 alarm clocks to the value I have set on the master switch.
Here is the code for the script:
all_sync:
alias: Sync All Alarms
sequence:
- service: input_slider.select_value
data:
entity_id:
- input_slider.living_alarm_clock_hour
- input_slider.boys_alarm_clock_hour
- input_slider.masterbed_alarm_clock_hour
#########What should the value be????########
value: "{{states.input_slider.all_alarm_clock_hour.state}} | float"
- service: input_slider.select_value
data:
entity_id:
- input_slider.living_alarm_clock_minute
- input_slider.boys_alarm_clock_minute
- input_slider.masterbed_alarm_clock_minute
########What should the value be????########
value: "{{states.input_slider.all_alarm_clock_minute.state}} | float"
The problem is no matter what I try I get an error when I run the script. The errors vary a little with every combination I try, but they’re generally something like:
Invalid service data for input_slider.select_value: expected float for dictionary value @ data['value']. Got '{{states.input_slider.all_alarm_clock_minute.state}} | float'
I’ve tried losing the quotes, double quotes, putting |float inside the braces, using ‘value_template’ instead of ‘value’, removing |float completely and I just can’t get it to work! For info , putting {{states.input_slider.all_alarm_clock_minute.state}} in to the developer template thingy brings back the value I want to send to the receiving input_sliders.
Without quotes around it = config error, HA won’t start
Single quotes around = runtime error: Invalid service data for input_slider.select_value: expected float for dictionary value @ data['value']. Got '{{states.input_slider.all_alarm_clock_minute.state | float}}'
Double quotes around it = same error as above
Basically, if I pull the input slider alarm_clock_hour to 7 and alarm_clock_minute to 0 (for 7am) and then put {{{states.input_slider.all_alarm_clock_hour.state}} and {states.input_slider.all_alarm_clock_minute.state}} in to the developer thingy it shows 7 and 0. I then want to set the three alarm clock input sliders for hours to 7 and the sliders for minutes to 0 with the script, so I would’ve expected the above code to work. The first time I ran it I did not inlude the | float and it gave me the error message “expected float but got…” that I’m getting now, so I presumed it was returning an int or a string, I added |float to counteract that but the message is the same.
Setting the initial value of an input slider is as easy as typing the number you want it on, so surely sending it a number in input_slider.select_value is the same? Thusly, I should be able to set an input_slider based on the value of another?
With double quotes = runtime error: Invalid service data for input_slider.select_value: extra keys not allowed @ data[‘value_template’]. Got ‘{{states.input_slider.all_alarm_clock_minute.state | float}}’