SORRY,
WITH GOOGLE, I DID NOT PAY ATTENTION THAT THE TRANSLATION HAD BEEN AUTOMATIC…
SO:
Hello everyone
I have also been struggling for 2 weeks regarding the change in color of the icons depending on the state (on/off, value, etc.).
I have exhausted the lines of several forums and multiple discussion threads, without being able to obtain any results.
As stated, I “only” want to change the state color of an icon on my cards, on a case by case basis based on my needs for each (card and/or icon).
In my concrete case, I want the “fan 1” logo to turn green when “on”, and to stay at the original blue otherwise.
Currently, it is going through the usual HA state changes, from blue to yellow…
here are my relevant lines:
type: entities
entities:
- entity: switch.switch_pompe
name: 'POMPE '
type: custom:multiple-entity-row
state_color: true
show_state: false
state_header: true
last-changed: true
secondary_info: last-changed
entities:
- entity: switch.4_relais_vitesses_pompe_l1
name: ' '
toggle: true
tap_action:
action: toggle
haptic: light
icon: mdi:fan-speed-1
state_color: true
secondary_info: last-changed
last-changed: true
styles:
width: 25px
card_mod:
style: |
:host {
{% if (states('switch.4_relais_vitesses_pompe_l1')) == 'off' %}--paper-item-icon-color: pink;
{% else %}
green
{% endif %}
;
whether I integrate it at the end of coding or in the configuration lines of the targeted entity, same result.
with the same config, if I set “state_color:” to false, it no longer changes color depending on the state either:
if I add the quoted line “‘–paper-item-icon-color’: red” it does change the base color of the icon, but without taking into account the state changes of the icon itself.
styles:
width: 25px
'--paper-item-icon-color': red
card_mod:
style: |
:host {
{% if (states('switch.4_relais_vitesses_pompe_l1')) == 'off' %}--paper-item-icon-color: pink;
{% else %}
green
{% endif %}
;
on the other hand it changes all the other icons once the condition is met!! :
However, when I use this same coding in another card, I get what I am looking for:
type: glance
entities:
- entity: switch.switch_volet_immerge
name: VOLET
card_mod:
style: |
:host {
color: {% if states(config.entity) == 'on' %} red {% endif %};
}
:host {
{% if states(config.entity) == 'on' %}--paper-item-icon-color: red ; {% endif %};
}
I feel like I’ve tried everything, and can’t find my mistake.
Does anyone have an idea or even a solution?
Thanks in advance