From a7bed4d0c61c7474dcfcf74ab06e0336e055cb43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Sat, 30 Dec 2023 23:23:29 +0000 Subject: [PATCH] Typo in code. Fix #333 --- src/patch/ha-icon.ts | 4 ++-- test/views/4_templates.yaml | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/patch/ha-icon.ts b/src/patch/ha-icon.ts index c615395..b0581b8 100644 --- a/src/patch/ha-icon.ts +++ b/src/patch/ha-icon.ts @@ -30,7 +30,7 @@ const bindCardMod = async (el, retry = 0) => { el._boundCardMod = await findParentCardMod(el); // If no card-mod was found in any parent element, then retry with increased interval - if (!el._cardMod?.size && retry < 5) + if (!el._boundCardMod?.size && retry < 5) return window.setTimeout(() => bindCardMod(el, retry + 1), 100 * retry); for (const cm of el._boundCardMod) { @@ -72,7 +72,7 @@ function joinSet(dst: Set, src: Set) { async function findParentCardMod(node: any, step = 0): Promise> { let cardMods: Set = new Set(); - if (step == 10) return cardMods; + // if (step == 10) return cardMods; if (!node) return cardMods; if (node._cardMod) { diff --git a/test/views/4_templates.yaml b/test/views/4_templates.yaml index 9775cf3..c47d818 100644 --- a/test/views/4_templates.yaml +++ b/test/views/4_templates.yaml @@ -123,3 +123,27 @@ cards: entities: - input_number.x_pos - input_number.y_pos + + - type: vertical-stack + cards: + - <<: *desc + content: | + ## Icon template + Icon should change when light is turned on or off. + [Github issue](https://github.com/thomasloven/lovelace-card-mod/issues/333) + + - type: entities + show_header_toggle: false + entities: + - entity: light.bed_light + card_mod: + style: | + :host { + --card-mod-icon: {% if is_state('light.bed_light', 'on') %} mdi:star {% else %} mdi:star-outline {% endif %}; + } + - entity: light.bed_light + card_mod: + style: | + :host { + --card-mod-icon: {% if is_state(config.entity, 'on') %} mdi:star {% else %} mdi:star-outline {% endif %}; + }