- platform: template
sensors:
irrigation_duration_for_1m2_all_day:
friendly_name: "Sec/m² voor dag"
unit_of_measurement: 's'
value_template: "{{ '{0:,.2f}'.format((((states('sensor.verwachte_temp')|float + 30) ** 4)/75000) - (states('sensor.regen_verwacht')|float*16))}}"
Outer quotes should be different from inner quotes when the template is defined on the same line as the value_template
option.
The alternative is a multiline format like this which doesn’t require outer quotes.
- platform: template
sensors:
irrigation_duration_for_1m2_all_day:
friendly_name: "Sec/m² voor dag"
unit_of_measurement: 's'
value_template: |
{{ '{0:,.2f}'.format((((states('sensor.verwachte_temp')|float + 30) ** 4)/75000) - (states('sensor.regen_verwacht')|float*16)) }}
You should also supply float
with a default value. For example, float(0)
means it will use 0 if the entity’s value can’t be converted to a number.