button-card
button-card copied to clipboard
Add button_card_templates support to state oprator.
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
There is workaround to use type: conditional and not use complex structures in button-card
Templates are applied at card config level. To achieve what you wish, move the state: defintion to the template.