AmoebeLabs / swiss-army-knife-card

The versatile custom Swiss Army Knife card for Home Assistant allows you to create your unique visualization using several graphical tools, styling options and animations.
223 stars 19 forks source link

"Null" attributes throw and error (and do not load card) #247

Open Slalamander opened 4 months ago

Slalamander commented 4 months ago

Bug report notice

Before you file a bug, make sure that you did not make a configuration mistake. The Swiss Army Knife in its current state does not yet have full configuration sanity checks!

So make sure your problem is not related to that!

Swiss Army Knife version

V2.5.1

Bug description

When defining an attribute in an entity configuration, the entire card disappears if that attribute becomes null. This is for example the case for most attributes of a light when said light is turned off. The console shows an error message with TypeError: t is null. Using a convert statement in the entity config is a workaround to solving this. This is a possible fix for brightness values, but for example for effects of a light it is not.

To Reproduce

Steps to reproduce the behavior:

  1. Make a card, and define an entity, for example a light, with its attribute set to effect.
  2. Refresh the dashboard.
  3. Turn on the light and apply an effect. Refresh the page, the card should be showing correctly.
  4. Turn off the light.
  5. The card should now have disappeared from the dashboard.
  6. See error

Expected behavior

Show the card, passing a state of null or something similar to the connected tools.

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop browser (please complete the following information):

Additional context The error thrown in the browser's console:

Uncaught (in promise) TypeError: t is null
    _buildStateString swiss-army-knife-card.js:971
    set hass swiss-army-knife-card.js:927
    _createCard decluttering-card.js:192
    async*set hass decluttering-card.js:186
    value hui-view.ts:68
    value hui-view.ts:304
    value hui-view.ts:80
    r fire_event.ts:76
    h create-element-base.ts:127
    promise callback*7778/h/< create-element-base.ts:125
    h create-element-base.ts:213
    c create-element-base.ts:170
    f create-card-element.ts:102
    value hui-view.ts:66
    _cards hui-view.ts:288
    value hui-view.ts:287
    value hui-view.ts:216
    value hui-view.ts:132
    performUpdate reactive-element.ts:1327
    scheduleUpdate reactive-element.ts:1261
    _$Ej reactive-element.ts:1233
    requestUpdate reactive-element.ts:1208
    _$Eu reactive-element.ts:946
    b reactive-element.ts:931
    i hui-view.ts:45
    E scoped-custom-element-registry.js:385
    t scoped-custom-element-registry.js:236
    value hui-root.ts:963
    value hui-root.ts:681
    setTimeout handler*96151/r/< render-status.ts:2
    r render-status.ts:2
    value hui-root.ts:681
    _$AE reactive-element.ts:1378
    performUpdate reactive-element.ts:1343
    scheduleUpdate reactive-element.ts:1261
    _$Ej reactive-element.ts:1233
    requestUpdate reactive-element.ts:1208
    _$Eu reactive-element.ts:946
    b reactive-element.ts:931
    A lit-element.ts:115
    o hui-root.ts:103
    E scoped-custom-element-registry.js:385
    t scoped-custom-element-registry.js:236
    u lit-html.ts:1129
    g lit-html.ts:1543
    _$AI lit-html.ts:1384
    z lit-html.ts:2183
    update lit-element.ts:165
    performUpdate reactive-element.ts:1329
    scheduleUpdate reactive-element.ts:1261
swiss-army-knife-card.js:971:2629

(Optional): Suggested Solution

Any suggested solution to this bug.

github-actions[bot] commented 4 months ago

Thank you for creating your first issue for the Swiss Army Knife custom card!