I think the issue is how you’re using style. Basically you’re saying: when the state of the entity
input_text.office_lights_current_scene
is scene_1
, use this styling: and then you style state with name: On
. But that is not a style.
Styles are things like colors, width, filters etc. The variable show_state: true
displays the actual state of the entity you list there. I believe you can’t change what state actually says. That’s kinda the whole use case of state, so it shows the acual state of the entity in HA. You should use label if you want to have something below the name that you can change.
Try:
- type: 'custom:button-card'
entity: input_text.office_lights_current_scene
show_label: true
label: 'Off'
show_state: false
icon: mdi:ceiling-light
name: 'Deckenlicht: Normal'
template: base_2x2
gridrow: 2
gridcol: 2 / 4
tap_action:
action: call-service
service: scene.turn_on
service_data:
entity_id: scene.buro_deckenleuchte_rechts_links_normal
styles:
card:
- box-shadow: >
[[[ return (entity.state === 'scene_1' || entity.state === 'home') ? '5px 10px 18px rgba(0, 0, 0, 0.8)' : '5px 10px 18px rgba(0, 0, 0, 0.0)'; ]]]
- color: >
[[[ return (entity.state === 'scene_1' || entity.state === 'home') ? 'rgba(0, 0, 0, 0.6)' : 'rgba(255, 255, 255, 0.2)'; ]]]
- background-color: >
[[[ return (entity.state === 'scene_1' || entity.state === 'home') ? 'rgba(255, 255, 255, 0.8)' : 'rgba(115, 115, 115, 0.2)'; ]]]
state:
- value: 'scene_1'
label: 'On'
styles:
What this basically tells the button to do is: put a label under the name as default with the text ‘Off’. But when the state of the entity input_text.office_lights_current_scene
changes to scene_1
then it will change the label to ‘Off’.
You can also add stylings (I put it at the bottom) there, so that icons, label, name etc changes colors for instance when the state has changed to scene_1
. Make sure you use the indents under there, just like you did on the main styles. If you don’t use styles there, it will just keep the default style on the state. This way you can create multiple states with variables (like icon, label, name) and styles that change based on the state of the entity.