question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Card-mod-icon broken in 3.1.5

See original GitHub issue

Home Assistant Core 2022.6.1 Home Assistant Supervisor 2022.05.3 Home Assistant OS 8.1 Home Assistant OS running on VMWare VM on Windows 11

My lovelace configuration method (GUI or yaml): GUI (created card via GUI but then used “show code editor” to edit card yaml)

What I am doing: Using card-mod to change light entity icon based on state.

What I expected to happen: Light entity icon to change based on state (on or off).

What happened instead: Worked correctly in 3.1.4 but broken in 3.1.5. Tested switching back and forth between the versions and clearing browser cache.

Minimal steps to reproduce:

  1. Update to card-mod version 3.1.5
  2. Create a button card (in my case is within a grid) and link to an entity such light using provided code above.
  3. Save and view card. Try toggling the card entity. Note that the icon does not change.
# The least amount of code possible to reproduce my error
show_name: true
show_icon: true
type: button
tap_action:
  action: toggle
entity: light.kitchen_bar
card_mod:
  style: |
    :host {
      --card-mod-icon:
        {% if is_state(config.entity, 'on') %} mdi:ceiling-light-multiple
        {% else %} mdi:ceiling-light-multiple-outline
        {% endif %}
    }
# End of code

Error messages from the browser console:

DevTools failed to load source map: Could not load content for chrome-extension://pccckmaobkjjboncdfnnofkonhgpceea/js/hls.js.map: System error: net::ERR_BLOCKED_BY_CLIENT

Not sure if this is relevant since card-mod loads version 3.1.5 just fine.


By putting an X in the boxes ([]) below, I indicate that I:

  • Understand that this is a channel for reporting bugs, not a support forum (https://community.home-assistant.io/).

  • Have made sure I am using the latest version of the plugin.

  • Have followed the troubleshooting steps of the “Common Problems” section of https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins.

  • Understand that leaving one or more boxes unticked or failure to follow the template above may increase the time required to handle my bug-report, or cause it to be closed without further action.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ildar170975commented, Jun 8, 2022

Use triple “`” to format your code. Otherwise it looks like a “каша”.

0reactions
Mariusthvdbcommented, Dec 9, 2022

still having reliability issues with the card-mod-icon, now using HA 2022.12 and card-mod 3.2.0

even though the mod I set seems to have been noticed by the Browser:

Scherm­afbeelding 2022-12-08 om 10 07 16

The wrong icon regularly peeps through, and it’s a random process when it finally succeeds. refresh, reload, clear cache, stop and re-open browser etc etc

Scherm­afbeelding 2022-12-08 om 10 07 10
    card-mod-root-yaml: |

      paper-tab[aria-label='Verwarming'] ha-icon$: |
        ha-svg-icon {
          --card-mod-icon: {% set action = state_attr('climate.front_room','hvac_action') %}
                           {{'mdi:radiator' if action == 'heating' else
                             'mdi:radiator-disabled' if action == 'idle' else
                             'mdi:radiator-off'}};
          color: {% set action =  state_attr('climate.front_room','hvac_action') %}
                 {% set mapper = {'Off':'black',
                                  'Heating':'red',
                                  'Cooling':'blue',
                                  'Auto':'darkgreen'} %}
                 {{mapper[action] if action in mapper else ''}};
        }

Ive also tried with some different style templates:

      paper-tab[aria-label='Verwarming'] ha-icon$: |
        ha-svg-icon {
          --card-mod-icon: {%- set action = state_attr('climate.front_room','hvac_action') -%}
                           {%- set icon = {'heating':'radiator','idle':'radiator-disabled'} -%}
                           mdi:{{icon.get(action,'radiator-off')}};
          color: {% set action =  state_attr('climate.front_room','hvac_action') %}
                 {% set color = {'off':'black','heating':'maroon',
                                  'cooling':'dodgerblue','auto':'darkgreen'} %}
                 {{color.get(action,'')}};
        }

and they do work in dev tools template, but still are a no show in the menu bar. Aware the aria-label might soon be taken out, Id love to keep modding those view icons.

Thomas is there an obvious error we’re making here? or:

roll back to 3.1.4 still saves the day:

Scherm­afbeelding 2022-12-09 om 09 31 56

and I still see the header classes I defined in card-mod-theme. Fingers crossed they will stay like that (and are not in cache somehow)

Read more comments on GitHub >

github_iconTop Results From Across the Web

WTH can't I specify on and off icons for toggle helpers?
Card-mod-icon broken in 3.1.5. opened 12:59AM - 04 Jun 22 UTC. Nerwyn. Home Assistant Core 2022.6.1 Home Assistant Supervisor 2022.05.3 Home ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found