hello,
i made an template sensor for my flood sensors, to convert 4xbinary swim sensors to one sensor with “speaking” states like “level0, level1, level2, level3, level4” and “Sensor Error!” what works quite well.
now i want to replace the last state “Sensor Error!” with a more detailed string. the idea was to have an state like this “Sensor error: 0111”, where i can see the actual state of the 4 sensors in a kind of binary number. i made an convert of 4 binary states into a “0” or “1” and then to concatenating them to one “message”…
that needs a second “stacked” if statement but i can´t get it run?
what did i do wrong? or isn´t it possible to stack if statements?
## FLOODLEVEL template Sensor Sickerschacht START
floodlevel_soakaway:
#unit_of_measurement: mm
value_template: >-
{% if is_state("binary_sensor.aqara_ws_95_water_leak", "off") and is_state("binary_sensor.aqara_ws_96_water_leak", "off") and is_state("binary_sensor.aqara_ws_97_water_leak", "off") and is_state("binary_sensor.aqara_ws_98_water_leak", "off") %}
Level0
{% elif is_state("binary_sensor.aqara_ws_95_water_leak", "on") and is_state("binary_sensor.aqara_ws_96_water_leak", "off") and is_state("binary_sensor.aqara_ws_97_water_leak", "off") and is_state("binary_sensor.aqara_ws_98_water_leak", "off") %}
Level1
{% elif is_state("binary_sensor.aqara_ws_95_water_leak", "on") and is_state("binary_sensor.aqara_ws_96_water_leak", "on") and is_state("binary_sensor.aqara_ws_97_water_leak", "off") and is_state("binary_sensor.aqara_ws_98_water_leak", "off") %}
Level2
{% elif is_state("binary_sensor.aqara_ws_95_water_leak", "on") and is_state("binary_sensor.aqara_ws_96_water_leak", "on") and is_state("binary_sensor.aqara_ws_97_water_leak", "on") and is_state("binary_sensor.aqara_ws_98_water_leak", "off") %}
Level3
{% elif is_state("binary_sensor.aqara_ws_95_water_leak", "on") and is_state("binary_sensor.aqara_ws_96_water_leak", "on") and is_state("binary_sensor.aqara_ws_97_water_leak", "on") and is_state("binary_sensor.aqara_ws_98_water_leak", "on") %}
Level4
{% else %}
{% if is_state("binary_sensor.aqara_ws_95_water_leak", "on")%}
{% set message95 = '1' | int %}
{% elif is_state("binary_sensor.aqara_ws_95_water_leak", "off")% }
{% set message95 = '0' | int%}
{% endif %}
{% if is_state("binary_sensor.aqara_ws_96_water_leak", "on")%}
{% set message96 = '1' | int %}
{% elif is_state("binary_sensor.aqara_ws_96_water_leak", "off")% }
{% set message96 = '0' | int%}
{% endif %}
{% if is_state("binary_sensor.aqara_ws_97_water_leak", "on")%}
{% set message97 = '1' | int %}
{% elif is_state("binary_sensor.aqara_ws_97_water_leak", "off")% }
{% set message97 = '0' | int%}
{% endif %}
{% if is_state("binary_sensor.aqara_ws_98_water_leak", "on")%}
{% set message98 = '1' | int %}
{% elif is_state("binary_sensor.aqara_ws_98_water_leak", "off")% }
{% set message98 = '0' | int%}
{% endif %}
{{ "Sensor error: " ~ message95 ~ message96 ~ message97 ~ message98}}
{% endif %}
## FLOODLEVEL template Sensor Sickerschacht END
Configuration warnings
Invalid config for 'template' from integration 'sensor' at sensor.yaml, line 496: invalid template (TemplateSyntaxError: unexpected '}') for dictionary value 'sensors->floodlevel_soakaway->value_template', got '{% if is_state("binary_sensor.aqara_ws_95_water_leak", "off") and is_state("binary_sensor.aqara_ws_96_water_leak", "off") and is_state("binary_sensor.aqara_ws_97_water_leak", "off") and is_state("binary_sensor.aqara_ws_98_water_leak", "off") %}\n Level0\n{% elif is_state("binary_sensor.aqara_ws_95_water_leak", "on") and is_state("binary_sensor.aqara_ws_96_water_leak", "off") and is_state("binary_sensor.aqara_ws_97_water_leak", "off") and is_state("binary_sensor.aqara_ws_98_water_leak", "of...
pls help! thanx in advance!
br
Frank