Skip to content

Labels and template love

Compare
Choose a tag to compare
@RomRider RomRider released this 29 Apr 16:44
· 266 commits to master since this release
56a8fac

New features

  • New option label: can be used for anything, if template is needed, use label_template. Both are also available per state. Fixes #112, Fixes #120

  • New option show_label: default is false. To display the label or label_template field

  • New layout: icon_label to display the label on the right side of the icon

  • templating support 🎉 in label_template and state with the template operator. For more advanced templates, please use the config-template-card. The next version of config-template-card (available soon) will fix the issue you all had in the past.

    • In label_template:
      Home_Assistant
      - type: "custom:button-card"
        color_type: icon
        entity: light.test_light
        label_template: >
          var bri = states['light.test_light'].attributes.brightness;
          return 'Brightness: ' + (bri ? bri : '0') + '%';
        show_label: true
        size: 15%
        style:
          - height: 100px
      - type: "custom:button-card"
        color_type: icon
        entity: light.test_light
        layout: icon_label
        label_template: >
          return 'Other State: ' + states['switch.skylight'].state;
        show_label: true
        show_name: false
        style:
          - height: 100px
    • value with template operator
      - type: "custom:button-card"
        color_type: icon
        entity: switch.skylight
        show_state: true
        show_label: true
        state:
          - operator: template
            value: >
              return states['light.test_light'].attributes
              && (states['light.test_light'].attributes.brightness <= 100)
            icon: mdi:alert
          - operator: default
            icon: mdi:lightbulb
      - type: "custom:button-card"
        color_type: icon
        entity: light.test_light
        show_label: true
        state:
          - operator: template
            value: >
              return states['input_select.light_mode'].state === 'night_mode'
            icon: mdi:weather-night
            label: Night Mode
          - operator: default
            icon: mdi:white-balance-sunny
            label: Day Mode

Fixes

  • Blank card was not following the specified width