Hey, I made energy sensor and I want to change the color of state and icon when the energy go up , so I success to change color of state and I changed color of icon separately but I dont know how to write it right together
this is state I changed
and this is the icon color I changed
this is the code of state color change
entities:
- entity: sensor.tsrykt_khshml_nvkkhyt
card_mod:
style: |
:host {
color:
{% if states(config.entity) | int <= 4000 %}
green
{% elif states(config.entity) | int <= 6000 %}
orange
{% elif states(config.entity) | int <= 8000 %}
red
{% endif %}
;
}
icon: mdi:lightning-bolt-circle
and this is the code of icon color change
card_mod: null
style: |
:host {
{% if states(config.entity) | int <= 4000 %}
--card-mod-icon: mdi:lightning-bolt-circle;
--card-mod-icon-color: blue;
{% elif states(config.entity) | int <= 6000 %}
--card-mod-icon: mdi:lightning-bolt-circle;
--card-mod-icon-color: orange;
{% elif states(config.entity) | int <= 8000 %}
--card-mod-icon: mdi:lightning-bolt-circle;
--card-mod-icon-color: red;
{% endif %}
;
}
How can I put in together to the code?
Thank you!!