Hi!
I’m trying to change the Co2 icon color based on the value. I tried everything I could but could not get it.
Here’s my code:
# CO2
- platform: template
sensors:
co2:
value_template: >
{{ state_attr('sensor.eco2_exterior','battery')|round }}
friendly_name: 'CO2'
unit_of_measurement: 'mmp'
device_class: carbon_dioxide
icon_template: >-
{% set co2 = states('sensor.eco2_exterior')|float(0) %}
{% if quality > 15000 %}
red
{% elif 15000 >= co2 > 5000 %}
orange
{% elif 5000 >= co2 > 2500 %}
yellow
{% elif 2500 >= co2 > 2000 %}
Zeer Ongezond
{% elif 2000 >= co2 > 1500 %}
green
{% elif 1500 >= co2 > 650 %}
green
{% elif 650 >= co2 > 400 %}
green
{% elif 400 >= co2 > 0 %}
green
{% else %}
green
{% endif %}
What am I doing wrong?