I am trying to change color on icons depending on state.
I have this in customize.yaml
I got this working for a sensor for text:
sensor.tesla_charger:
friendly_name: Tesla charger
templates:
icon_color: >
if (state == 'Charging') return 'blue';
if (state == 'Connected') return 'yellow';
if (state == 'Available') return 'green';
return 'normal';
But when I try to do the same thing with values, it does not work:
sensor.charger_current_p1:
friendly_name: Phase 1
templates:
icon_color: >
if (state < 20 ) return 'normal';
if (state > 25) return 'red';
if (state > 20) return 'yellow';
return 'black';
Any ideas?