Glance Card Icon Not Showing with Conditional Template

Hi everyone,

I’m having a strange issue with a glance card where the icon disappears as soon as I add any kind of conditional template to the icon property. The icon in the card will just disappear. As long as the icon is static, then yes.

Here’s my simplified glance card configuration:

type: glance
entities:

- entity: light.living_room_light
    name: Living Room Light
    show_state: true
    icon: >-
      {% if is_state(‘light.living_room_light’, ‘on’) %}
        mdi:lightbulb-on-outline
      {% else %}
        mdi:lightbulb-outline
      {% endif %}

As soon as I put in the if statement, the icon just dissappears. There’s no error whatsoever.

I also tried something simpler:

type: glance
entities:

- entity: light.living_room_light
    name: Living Room Light
    show_state: true
    icon: >-
      {% if true %}
        mdi:lightbulb-on-outline
      {% endif %}

But it also doesn’t work.

Any idea how I can change the icon of a glance card based on the state of another entity?

Thanks!

You cannot change an icon by a template since Glance card does not support templates.
Consider using card-mod, ask in the main card-mod thread.