Use case:
I’m using an IR blaster to control a fan with three steps of speed under one button(same code), i.e. in a sequence of OFF->ON in Low speed -> Med speed -> Hi speed -> OFF. So I am planning to put conditional actions with the following idea:
Use a numeric variable to store the button status. After studying various post, I found one way is to use input_slider like this:
input_slider:
fan_speed:
name: Fan Speed
initial: 0
min: 0
max: 3
step: 1
Then my question is how can I update this variable in a script for the following purpose:
Speed_up script:
execute IR code only if fan_speed is less than 3, and then add 1 into fan_speed
Speed_down script:
execute IR code only if fan_speed is greater than 1, and then minus 1 from fan_speed
Fan_off script:
execute IR code (fire the right number of code) based on the value of fan_speed.
I’m trying to write the fan_speed_up script below:
fan_speed_up:
alias: Fan Speed Up
sequence:
- condition:
condition: numeric_state
entity_id: input_slider.fan_speed
below: 3
- service: input_slider.select_value
value_template:
entity_id: “{{fstates.input_slider.fan_speed.state | float + 1}}”
- service: Send the IR code*
I know the above format is not correct and the fan_off script is even more difficult in my project. But the first thing I would like to get help is on how to manipulate a variable in that way with correct format in such kind of script.
Many thanks!