With the new state colour released in 2022.12 I had the idea to change the colour of a template sensor based on its sign (-‘ve, +’ve).
This mini graph card displays a template sensor which is a simple sign reversal of the original sensor, but setting the config to show the state colour just shows the original blue of the sensor. I’d like to change it red for negative values, i.e. when the battery is losing charge to help the family see that they’re using more power than is being supplied by solar.
The template config in template.yaml is:
- sensor:
- name: my_home_battery_power_neg
state: "{{ - ( states('sensor.my_home_battery_power') | float ) }}"
unit_of_measurement: W
I was thinking to add a line to the config such as:
state_color: if … return: red
etc.
Does anyone have feedback on how this new state colour can be used by us mere mortals?