itnassol
(Andrew)
1
I am trying to trigger an automation when a value of a sensor reaches 1.0 below that of the input number.
platform: template
value_template: >-
"{{ states('sensor.living_room_temperature_temperature') <
states('input_number.lr_upper_temp') | float - 1.0 }}
id: LR-Too-Cold
alias: LR-Below-Min-Temp
It works when the second half (i.e. after the <) is a fixed input number but I am struggle to work out how to do subtract 1.0 from it.
Thanks in advance.
Troon
(Troon)
2
You need to float
both parts of the sum, provide a default value to float
, and lose the double quote:
value_template: >-
{{ states('sensor.living_room_temperature_temperature')|float(0) <
states('input_number.lr_upper_temp')|float(0) - 1.0 }}
That will trigger whenever either entity changes and the living room temperature is less than the upper temperature minus 1 degree.
itnassol
(Andrew)
3
Perfect, thank you. Yeah double quotes were me trying things, thanks though make perfect sense that the equation needs to be balanced… Thanks again.
Troon
(Troon)
4
You need the double quotes on both ends only if you’re putting the template on a single line:
value_template: "{{ states('sensor.living_room_temperature_temperature')|float(0) < states('input_number.lr_upper_temp')|float(0) - 1.0 }}"
itnassol
(Andrew)
5
I didn’t know that, thank you.