Glance Card - Different State Icons

Hello

i ve a problem with my code

type: glance
title: Hühnerstall
entities:
  - entity: binary_sensor.huhnerstall_klappe_contact
    name: Klappe
    icon: >-
          {% if is_state('binary_sensor.huhnerstall_klappe_contact', 'closed') %}
          'mdi:window-shutter'
          {% if is_state('binary_sensor.huhnerstall_klappe_contact', 'open') %}
          'mdi:window-shutter-open'
state_color: true
show_icon: true
show_name: true
show_state: true

OR

type: glance
title: Hühnerstall
entities:
  - entity: binary_sensor.huhnerstall_klappe_contact
    name: Klappe
    icon: >-
          {% if is_state('binary_sensor.huhnerstall_klappe_contact', 'on') %}
          'mdi:window-shutter'
          {% if is_state('binary_sensor.huhnerstall_klappe_contact', 'off') %}
          'mdi:window-shutter-open'
state_color: true
show_icon: true
show_name: true
show_state: true

HA will not show a Icon.

You cant use templates in standard Lovelace.

There are two custom cards that can enable the ability to use templates in Lovelace:

JavaScript

Jinja

I highly recommend the JavaScript version as it will put much less of a load on your system.