Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 105601

If else statement in a value template

$
0
0

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.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 105601

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>