Is it possible to check sensor state in attribute templates?
For example after black out server was rebooted without internet connection
binary_sensor:
platform: template
sensors:
my_sensor:
value_template: >
{% if states.sensor.sensor2.state == 'unknown' or 'unavailable' or 'null' or 'none' %}
{{ 'unknown' }}
{% else %}
{% if states.sensor.sensor2.state|float == true %}
{{ true }}
{% else %}
{{ false }}
{% endif %}
{% endif %}
attribute_templates:
my_attribute1: >
{% if states.sensor.sensor2.state != 'unknown' or 'unavailable' or 'null' or 'none' %}
{{ true }}
{% endif %}
my_attribute2: >
{% if states.sensor.sensor2.state != 'unknown' or 'unavailable' or 'null' or 'none' %}
{{ true }}
{% endif %}
For value_template if
working, but for attribute_templates in log i got error: “TemplateError(‘TypeError: ‘NoneType’ object is not iterable’) while processing template”