thomasloven / lovelace-card-mod

🔹 Add CSS styles to (almost) any lovelace card
MIT License
1.12k stars 167 forks source link

Template variable warning: 'dict object' has no attribute 'entity' when rendering 'state-badge #149

Closed Mariusthvdb closed 2 years ago

Mariusthvdb commented 2 years ago

My Home Assistant version: 0.XX.X 2021.11 My lovelace configuration method (GUI or yaml): yaml What I am doing: adding a section to card-mod-theme for changing state color on certain domains What I expected to happen: no warning in the logs What happened instead: Warnings in the homeassistant.log

2021-11-04 10:09:43 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'entity' when rendering 'state-badge {
  {% if config.entity is match('(switch|automation|input_boolean|binary_sensor)', ignorecase=False) %}
    {% if is_state(config.entity, 'on') %} color: var(--primary-color)
    {% else %} color: steelblue
    {% endif %};
  {% endif %};
}'

Happening on each view change

Minimal steps to reproduce:

# The least amount of code possible to reproduce my error
  card-mod-row-yaml: |
    "*:first-child$": |
      state-badge {
        {% if config.entity is match('(switch|automation|input_boolean|binary_sensor)', ignorecase=False) %}
          {% if is_state(config.entity, 'on') %} color: var(--primary-color)
          {% else %} color: steelblue
          {% endif %};
        {% endif %};
      }
# End of code

Error messages from the browser console:


Not sure if this is related, but there is:

Unhandled Promise Rejection: AbortError: The operation was aborted.

without very much to go on unfortunately

fwiw: the card-mod seems to work as intended ;-)

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

Mariusthvdb commented 2 years ago

no longer used