Icon Template doesn't change actual value, works on template editor

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 ?

Try
{% if is_state(‘cover.garage_door.attributes[“door_state”]’, ‘open’) %}

Thanks for your reply, it didn’t help solve this issue

OK, so what do you get when you put the above in the dev-tools templating tool?

That’s the strange part, I get the expected value but yet the icon doesn’t change

When you say you got the expected value you mean it evaluates to true when it’s “open”?

it evaluates to mdi:door-open when it’s open and mdi-door-closed when it’s closed

Can you show what you are looking at in the frontend?

I’m not sure what you mean, I hope this will answer : link1, link2

Very odd :frowning: 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 %}