custom-cards / decluttering-card

🧹 Declutter your lovelace configuration with the help of this card
MIT License
386 stars 30 forks source link

Error using template #19

Closed soloam closed 4 years ago

soloam commented 4 years ago

Hello, I have this template:

light_rgb_template:
  card:
    - type: custom:slider-entity-row
      entity: light.[[light_name]]
      style: |
        :host {
          color: {% if is_state('binary_sensor.[[light_name]]_autoon', 'on') %} green {% endif %};
        }
      toggle: true

And I use it like this:

            - type: custom:decluttering-card
              template: light_rgb_template
              variables:
                - light_name: hallway_tablelight

This is replacing my old config:

            - type: custom:slider-entity-row
              entity: light.hallway_tablelight
              style: |
                :host {
                  color: {% if is_state('binary_sensor.hallway_tablelight_autoon', 'on') %} green {% endif %};
                }
              toggle: true

In the Lovelace I get the error:

Cannot read property 'startsWith' of undefined
type: 'custom:decluttering-card'
template: light_rgb_template
variables:
  - light_name: hallway_tablelight

What I'm doing wrong? Or is this a bug?

Thank you

RomRider commented 4 years ago

the card property is not an array (it's call card not cards 😉 ):

light_rgb_template:
  card:
    type: custom:slider-entity-row
    entity: light.[[light_name]]
    style: |
      :host {
        color: {% if is_state('binary_sensor.[[light_name]]_autoon', 'on') %} green {% endif %};
      }
    toggle: true
soloam commented 4 years ago

Thank you, that was it!