Hi all,
I’m using custom ui and i try to change the color and the icon of an entity based on its state.
I’ve tried the following code but it didn’t work:
sensor.nas01_status:
templates:
icon: >
if (state === 'good') return 'mdi:checkbox-marked-circle-outline';
else return 'mdi:close-octagon';
icon_color: >
if (state === 'good') return 'rgb(67,167,47)';
else return 'rgb(219,27,8)';
When I use an entity card to display the sensor I get the correct color and correct icon. When i change the
state to something else then good the color and the icon didnt change. When Im using a picture-glance card
I didnt even get the right color. Maybe someone of you can point me in a direction.
Thanks in Advance.