brunosabot / streamline-card

Streamline your Lovelace configuration with with a card template system.
MIT License
25 stars 2 forks source link

Handle default value #15

Closed Pulpyyyy closed 1 month ago

Pulpyyyy commented 1 month ago

Thanks for closing https://github.com/brunosabot/streamline-card/issues/12

Here is another one ;) As soon as card define a default variable, rendre is broken

  floor_cover_void_img:
    default:
      type: volet
      etg: rdc
    element:
      type: image
      entity: sensor.[[type]]_[[area]]
      style:
        top: 50%
        left: 50%
        width: 100%
      image: /local/images/empty.png
      tap_action:
        action: none

According to logs :

create-element-base.ts:219 element custom:streamline-card TypeError: (e.default ?? []) is not iterable
    at getVariables (streamline-card.js?hacstag=839495072008:223:81)
    at evaluateVariables (streamline-card.js?hacstag=839495072008:239:13)
    at evaluateConfig (streamline-card.js?hacstag=839495072008:245:11)
    at t.parseConfig (streamline-card.js?hacstag=839495072008:311:22)
    at t.setConfig (streamline-card.js?hacstag=839495072008:320:42)
    at r (create-element-base.ts:125:11)
    at create-element-base.ts:146:12
    at h (create-element-base.ts:252:12)
    at c (create-element-base.ts:209:12)
    at d (create-hui-element.ts:25:10)

Regards

andreasbrett commented 1 month ago

You need to define the default values as list:

  floor_cover_void_img:
    default:
      - type: volet
      - etg: rdc
    element:
      type: image
      entity: sensor.[[type]]_[[area]]
      style:
        top: 50%
        left: 50%
        width: 100%
      image: /local/images/empty.png
      tap_action:
        action: none
Pulpyyyy commented 1 month ago

OK, so this a breaking change versus decluttering-card. Correct ?

brunosabot commented 1 month ago

I'm working on the support for objects in both default and variables. It will be available soon, but until then you need the array. I can't tell if it's breaking change, I always used the array in decluttering card

Pulpyyyy commented 1 month ago

Fine. I changed every card default with list (only few were define as objet) and everything is fine Thanks