custom-cards / decluttering-card

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

Bug with booleans #8

Closed kloggy closed 4 years ago

kloggy commented 5 years ago

see here for background https://community.home-assistant.io/t/lovelace-decluttering-card/118625/74

The specific case referenced there is a custom button card based on a de-clutterring template. The template includes a default defined boolean for lock of false which is ignored if it is not passed anything. The lock still appears.

First the view itself,

cards:
  - type: vertical-stack
    cards:

      - type: horizontal-stack
        cards:

          - type: custom:decluttering-card
            template: simple_header
            variables:
              - label: -- Hall --

          - type: custom:button-card
            color_type: blank-card
            styles:
              card:
                - width: 2px

          - type: custom:decluttering-card
            template: simple_header_options_button

          - type: custom:button-card
            color_type: blank-card
            styles:
              card:
                - width: 2px

then the de-cluttering templates,

  #==================
  #=== Simple Header
  #==================
  simple_header:
    card:
      type: custom:button-card
      label: '[[label]]'
      show_label: true
      aspect_ratio: 9/1
#      color_type: label-card
      styles:
        card:
          - height: 50px
          - background: linear-gradient(to right, var(--paper-card-background-color) 0%, rgba(255,255,255,0.55) 60%, rgba(255,255,255,0) 90%)
          - --ha-card-box-shadow: 'none'
#          - background-color: var(--paper-card-background-color)
        label:
          - justify-self: start
          - padding-left: 20px
          - font-size: 24px

  #=================================
  #=== Simple Header Options Button
  #=================================
  simple_header_options_button:
    default:
      icon: mdi:settings
      lock: false
      lock_color: var(--primary-text-color)
      tap_action: more-info
    card:
      type: custom:button-card
      icon: '[[icon]]'
      show_name: false
      tap_action: 
        action: '[[tap_action]]'
      lock: '[[lock]]'
      styles:
        card:
          - border-radius: 50%
          - height: 50px
          - width: 50px
          - background: rgba(255,255,255,0.45)
        lock:
          - color: '[[lock_color]]'
        icon:
          - color: gray
          - width: 35px
RomRider commented 4 years ago

default is an array. In your case it's an object. The correct syntax is:

  simple_header_options_button:
    default:
      - icon: mdi:settings
      - lock: false
      - lock_color: var(--primary-text-color)
      - tap_action: more-info