I am trying hard to assign a value to a sensor depending on the state of an entity (Delta T: if the pump runs = calc and 0 if the pump doesn’t run. This is what I did:
- platform: template
sensors:
delta_t_solar_heating:
friendly_name: Delta T
unit_of_measurement: °C
value_template: {% if is_state('switch.sonoff_1000bee815', 'on') %}
{{ (( states('sensor.sonoff_1000bee0f9_temperature') | float ) - ( states('sensor.sonoff_1000bee815_temperature') | float )
) | float | round(1) }}
{% elif %}
0.0
{% endif %}
it gives an error in the template tester, but can’t figure out what I should do. The calculation itself works without the if syntax.
Obviously I shuffled the syntax in all kind of ways but can’t find the right structure. I must be close but who can point where I go wrong …?