Hi all,
I have recently started with Home Assistant, switching over from OpenHAB. I am using card_mod to structure/color my dashboard entries. However, I struggle with one particular requirement. For my temperature sensors I would like to color the icon (which is easy via --card-mod-icon-color) and the value based on different values. The name however should remain in standard color. I have so far only managed to color icon and name (incl. value).
Here is the code I currently use:
- entity: sensor.aussenmodul_temperature.
name: Temperatur
icon: mdi:temperature-celsius
card_mod:
style: |
:host {
color:
{% if states.sensor.aussenmodul_temperature.state | int <= 3.0 %}
deepskyblue
{% elif states.sensor.aussenmodul_temperature.state | int <= 12.0 %}
darkcyan
{% elif states.sensor.aussenmodul_temperature.state | int <= 20.0 %}
olivedrab
{% elif states.sensor.aussenmodul_temperature.state | int <= 25.0 %}
goldenrod
{% elif states.sensor.aussenmodul_temperature.state | int <= 30.0 %}
peru
{% elif states.sensor.aussenmodul_temperature.state | int > 30.0 %}
coral
{% endif %}
;
--card-mod-icon-color:
{% if states.sensor.aussenmodul_temperature.state | int <= 3.0 %}
deepskyblue
{% elif states.sensor.aussenmodul_temperature.state | int <= 12.0 %}
darkcyan
{% elif states.sensor.aussenmodul_temperature.state | int <= 20.0 %}
olivedrab
{% elif states.sensor.aussenmodul_temperature.state | int <= 25.0 %}
goldenrod
{% elif states.sensor.aussenmodul_temperature.state | int <= 30.0 %}
peru
{% elif states.sensor.aussenmodul_temperature.state | int > 30.0 %}
coral
{% endif %}
;
}
What am I doing wrong or do I need to do differently? Happy for any help.