R_A_L_F
December 5, 2024, 11:42am
1
Hello,
I am using the following tile card and would like to dynamically adjust the color of the tile card picture based on a template sensor value. Unfortunately, the color does not change and as a beginner I do not really know why it does not work?
Many thanks
JerryM
(JerryM)
December 5, 2024, 11:55am
2
Have you tried HACS and Button Card by RomRider?
type: custom:button-card
entity: sensor.anzahl_offener_fenster_und_turen
name: Fenster/Türen
icon: mdi:door-sliding-lock
styles:
card:
- background-color: >
[[[ return states[‘sensor.anzahl_offener_fenster_und_turen’].state > 0 ? ‘red’ : ‘grey’; ]]]
Thanks for the tip.
I have two questions:
a) why doesn’t it work directly in the Tile Card?
b) it doesn’t work that way either
I have found the solution:
type: tile
entity: sensor.anzahl_offener_fenster_und_turen
name: Fenster/Türen
icon: mdi:door-sliding-lock
vertical: true
hide_state: false
show_entity_picture: false
tap_action:
action: navigate
navigation_path: /lovelace/fenster-turen
icon_tap_action:
action: navigate
navigation_path: /lovelace/fenster-turen
card_mod:
style: |
ha-tile-icon {
--tile-color:
{% if states(config.entity) | int > 0 %}
red;
{% else %}
grey;
{% endif %}
}
1 Like