I have a slider (name = input_number.slider_fan; min = 0; max = 6; step = 1). If the slider is set to a different value, I want to use the difference between the previous and current value of the slider in a for loop in an automation. In fact, I need two different loops depending on whether dif > 0 and dif < 0.
For example, if the slider is on position 3, and next is set to position 6 (dif = 3), for loop A in the automation should run 3 times. Likewise, if slider is on position 6 and next set to position 2 (dif = -4), for loop B in the automation should run 4 times.
I found several examples in which trigger.from_state.state has been used, but I cannot figure out how to make this run (compute dif). Moreover, but I can be wrong in my understanding of trigger, the trigger for the automation should be any move in the slider, not a specific from.state.
Any help is appreciated. Let me know if more info is needed.
i want to run a for-loop for X times, where X is the difference between the current and previous value of the input (slider) (see my original question). Please let me know if that’s unclear.