How can I do math with an input number. Like add one to it when a switch is turned on or Input boolean is turned on?
Simplest way would be to use a Service call:
Input number: Increment
You would need to setup the helper with the correct increment (step size)
As Charles noted the input_number.increment
and input_number.decrement
services are good for those basic functions. You can also use templates within an input_number.set_value
service call to access other math functions.
- alias: Increase by 5
service: input_number.set_value
target:
entity_id: input_number.x
data:
value: "{{ states('input_number.x') | float(0) + 5 }}"
- alias: Increase by 5 steps
service: input_number.set_value
target:
entity_id: input_number.x
data:
value: >
{{ states('input_number.x') | float(0) +
(5 * state_attr('input_number.x', 'step') ) }}
I used the increment thing but this actually works better for me because I can just stick another variable for how great the increment is which is super useful, thank you, didn’t know I can do that