ohadbenita
(Ohad Benita)
1
I have the following template sensor
garage_status:
friendly_name: 'Garage Door Status'
value_template: >-
{% if states.cover.garage_door %}
{% if states.cover.garage_door.attributes["door_state"] == "open" %}
Open
{% elif states.cover.garage_door.attributes["door_state"] == "closed" %}
Closed
{% elif states.cover.garage_door.attributes["door_state"] == "opening" %}
Opening
{% elif states.cover.garage_door.attributes["door_state"] == "closing" %}
Closing
{% else %}
Unknown
{% endif %}
{% else %}
n/a
{% endif %}
icon_template: >-
{%-if states.cover.garage_door.attributes["door_state"] == "open" -%}
mdi:door-open
{%- else -%}
mdi:door-closed
{%- endif -%}
For some reason the icon remain as door-closed all the time, no matter the evaluation of the value in the icon template, any ideas ?
keithh666
(Keith Hull)
2
Try
{% if is_state(‘cover.garage_door.attributes[“door_state”]’, ‘open’) %}
ohadbenita
(Ohad Benita)
3
Thanks for your reply, it didn’t help solve this issue
keithh666
(Keith Hull)
4
OK, so what do you get when you put the above in the dev-tools templating tool?
ohadbenita
(Ohad Benita)
5
That’s the strange part, I get the expected value but yet the icon doesn’t change
keithh666
(Keith Hull)
6
When you say you got the expected value you mean it evaluates to true when it’s “open”?
ohadbenita
(Ohad Benita)
7
it evaluates to mdi:door-open when it’s open and mdi-door-closed when it’s closed
keithh666
(Keith Hull)
8
Can you show what you are looking at in the frontend?
ohadbenita
(Ohad Benita)
9
I’m not sure what you mean, I hope this will answer : link1, link2
keithh666
(Keith Hull)
10
Very odd Yours hasn’t changed at all, since that’s mdi-door not -open or -closed, which means the icon template is not being evaluated at all I think.
I wonder if it’s this…
{% else %}
n/a
{% endif %}