The following code works fine to set the background-color static to yellow:
- type: state-icon
entity: light.kitchen_table
name: Küchentisch
icon: mdi:ceiling-light
style:
top: 16.5%
left: 74.7%
transform: translate(-50%, -50%)
width: 36px
height: 36px
border-radius: 50%
display: flex
align-items: center
justify-content: center
color: black
background-color: rgba(255, 215, 0, 0.8)
mdc-icon-size": 20px
When I try to set the background-color dynamic depending on the entity state nothing works. I´m clueless and hope somebody has a good Idea ![]()
- type: state-icon
entity: light.kitchen_table
name: Küchentisch
icon: mdi:ceiling-light
style:
top: 16.5%
left: 74.7%
transform: translate(-50%, -50%)
width: 36px
height: 36px
border-radius: 50%
display: flex
align-items: center
justify-content: center
color: black
background-color: |
[[[
if (states['light.kitchen_table'].state === 'on') {
return 'rgba(255, 215, 0, 0.8)';
} else if (states['light.kitchen_table'].state === 'off') {
return 'rgba(0, 0, 0, 0.3)';
} else {
return 'rgba(255, 215, 0, 0.8)';
}
]]]
mdc-icon-size": 20px


