Skip to content

Commit

Permalink
Typo in code. Fix #333
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasloven committed Dec 30, 2023
1 parent 0db6026 commit a7bed4d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/patch/ha-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -72,7 +72,7 @@ function joinSet(dst: Set<any>, src: Set<any>) {

async function findParentCardMod(node: any, step = 0): Promise<Set<CardMod>> {
let cardMods: Set<CardMod> = new Set();
if (step == 10) return cardMods;
// if (step == 10) return cardMods;
if (!node) return cardMods;

if (node._cardMod) {
Expand Down
24 changes: 24 additions & 0 deletions test/views/4_templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 %};
}

0 comments on commit a7bed4d

Please sign in to comment.