Hi all,
despite countless attempts, I canât get anywhere, although I hate to ask. I want an icon to rotate 45 degrees when the light is on. It does, but only if I leave out the button template. Until now, I assumed that with multiple templates, the last defined rules would prevail. But in my code, the states clash.
Without template button_light
:

With template button_light
:

And hereâs my code:
button_basis:
template: farbschema_dunkel
aspect_ratio: 1/1
color-type: icon
color: auto
styles:
card:
- border: none
- border-radius: 5px
- '--mdc-ripple-color': lightyellow
- '--mdc-ripple-press-opacity': 0.5
name:
- font-size: 12px
- font-weight: 700
state:
- font-size: 10px
label:
- font-size: 10px
state:
- value: unavailable
styles:
card:
- color: '[[[ return variables.basis_unavailable_color ]]]'
- background-color: '[[[ return variables.basis_unavailable_bg ]]]'
icon:
- color: '[[[ return variables.basis_unavailable_icon ]]]'
.
.
button_licht:
template: button_basis
tap_action:
action: toggle
haptic: success
hold_action:
action: more-info
haptic: selection
show_last_changed: false
show_state: false
styles:
card:
- color: '[[[ return variables.licht_card_color ]]]'
- background-color: '[[[ return variables.licht_card_bg ]]]'
state:
- value: 'on'
styles:
card:
- -webkit-box-shadow: 0 0 0.95rem 0.2rem var(--button-card-light-color)
- box-shadow: 0 0 0.95rem 0.2rem var(--button-card-light-color)
- transition: all 2s ease
icon:
- filter: drop-shadow(0 0 0.75rem var(--button-card-light-color))
- transition: 2s ease
name:
- color: var(--button-card-light-color)
- operator: default
show_label: true
label: |
[[[
if (entity.state == 'on') return 'Helligkeit: ' + (Math.round(entity.attributes.brightness / 2.55)) + '%';
]]]
.
.
- type: 'custom:button-card'
template:
- button_licht
entity: light.hue_iris
icon: |
[[[
if (entity.state == 'on') return 'mdi:wall-sconce-round-variant'; return 'mdi:flower-outline';
]]]
state:
- value: 'on'
styles:
icon:
- transform: rotate(45deg)
Maybe someone will be so kind and take pity on me 