button-card icon indicating copy to clipboard operation
button-card copied to clipboard

Add button_card_templates support to state oprator.

Open PavelD opened this issue 1 year ago • 1 comments

I want to use button_card_templates when state with operator option is defined.

This will keep me simple card buttons and complex card buttons inline and easy to update form one central point (button_card_templates object).

Hope this dummy example with show it better.

button_card_templates:
  alarm_color:
    color: var(--red-color)

square: false
type: grid
cards:
  - type: custom:button-card
     name: Not working
     icon: mdi:radiator
     color_type: card
     entity: input_select.cb_example
     state:
       - operator: template
          value: |
            [[[ return entity.state === 'choose1' ]]]
          name: 'Choice I - not working'
          template: alarm_color
       - operator: template
          value: |
            [[[ return entity.state === 'choose2' ]]]
          name: 'Choice II - working no template'
          color: '#ff0000'
  - type: custom:button-card
    name: Working
    icon: mdi:home-lightbulb
    color_type: card
    aspect_ratio: 2/1.1
    template: alarm_color

PavelD avatar Nov 15 '24 12:11 PavelD

There is workaround to use type: conditional and not use complex structures in button-card

PavelD avatar Nov 15 '24 12:11 PavelD

Templates are applied at card config level. To achieve what you wish, move the state: defintion to the template.

dcapslock avatar Aug 19 '25 04:08 dcapslock