I’m trying to change the icon color based on active or non-active state of the sensor using card-mod.
My current solution does work but that is not based on card-mod
type: entities
entities:
- entity: binary_sensor.ping_google
name: Ping Google
icon: mdi:router-network
- entity: binary_sensor.tp_link_router_wan_status_2
name: Wan status
state_color: false
style: |
:host {
{% if states(config.entity)=='on' %}
--paper-item-icon-color: red;
{% endif %};
}
I’ve gone through 🔹 Card-mod - Add css styles to any lovelace card - #4155 by catchdave
but could find the solution. Also been advised that --paper-item-icon-color
is deprecated, although it still works. There is no example of this simple example in GitHub - thomasloven/lovelace-card-mod: 🔹 Add CSS styles to (almost) any lovelace card
Can someone please guide me how to replace above configuration using card-mod ?
This doesn’t work
type: entities
entities:
- entity: binary_sensor.ping_google
name: Ping Google
icon: mdi:router-network
secondary_info: last-changed
- entity: binary_sensor.tp_link_router_wan_status_2
name: Wan status
state_color: false
card_mod:
style: |
:host {
--card-mod-icon-color:
{% if states(config.entity)=='on' %}
red
{% endif %}
green
}
Do I have to use ifelse or it it be just active and non-active state icon based statement ?