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 %};
}
This variable is not supported anymore.
Your options:
— use new variables (domain and device_class dependent)
— use direct access to DOM element and a standard “color” css property instead variables.
Hi IIdar, I can see that you struggled a lot in this space and then created a post with all the links (thanks for that) but I’m still struggling
Are you able to fix what should I replace this to right one ?. The domain is binary_sensor and device_class is ‘connectivity’
I’ve tried the following too
- entity: binary_sensor.tp_link_router_wan_status_2
name: Wan status
state_color: false
card_mod:
style: |
:host {
'--state-binary_sensor-on-color': red;
}
or
- entity: binary_sensor.tp_link_router_wan_status_2
name: Wan status
state_color: true
card_mod:
style: |
:host {
--state-binary_sensor-connectivity-on-color: '#009800'
}
I haven’t tried these new variables, cannot give you a ready solution…
Check a huge thread dedicated to new colors in the Configuration / Frontend section.
The problem is that :host will target all entities in the list. How should I do to target only the related entity without splitting them into different cards?
If you use config-template-card (CTC) for conditional card-mod styling ONLY - then this is absolutely useless. Card-mod supports jinja templates. No need to use CTC.
Because “:host” is not used on a card’s level to style a row.
Go to the huge card-mod thread for a right syntax.
This is for multiple-entity-row ONLY.
I wonder why it posted here.