I am trying to implement both ideas here. It took a bit but I got the jest of themes, As for the template example, this works well with any of my door/window sensors ‘included’ into HA. What I am having problems with is how to do the same with my (zigbee) “virtual sensors” which are not part of HA and I update these sensors externally.
These -vsensors are defined as:
patio_door:
friendly_name: "Patio"
value_template: "off"
I have tried to modify the value_template but have not been able to get any way to make it work. For example I have tried
sumppumproom_door:
friendly_name: "Sump Pump Room"
value_template: >-
{% if states.sensor.sumppumproom_door.state == 'off' %}
Closed
{% elif states.sensor.sumppumproom_door.state == 'on' %}
Open
{% else %}
n/a
{% endif %}
icon_template: >
{% if states.sensor.sumppumproom_door.state == 'off' %}
mdi:circle-outline
{% elif states.sensor.sumppumproom_door.state == 'on' %}
mdi:check-circle
{% else %}
mdi:help
{% endif %}
Obviously HA does not like if states.sensor.sumppumproom_door.state
Is there a means I can get this approach to work or do I have to define 2 sensors such as:
sumppumproom_door:
friendly_name: "to be Hidden"
value_template: "off"
sumppumproomdoor2:
friendly_name: "Sump Pump Room"
value_template: >-
{% if states.sensor.sumppumproom_door.state == 'off' %}
Closed
{% elif states.sensor.sumppumproom_door.state == 'on' %}
Open
{% else %}
n/a
{% endif %}
icon_template: >
{% if states.sensor.sumppumproom_door.state == 'off' %}
mdi:circle-outline
{% elif states.sensor.sumppumproom_door.state == 'on' %}
mdi:check-circle
{% else %}
mdi:help
{% endif %}