I had a terrible time figuring out how to get the gauge component to display the six colors indicating the various air quality ranges (as described by airnow). Now that I have it working using card_mod, I thought I’d share the configuration so others can benefit. I’m also interested if others have stumbled on better configurations; if you have a configuration for this data please share!
I’m using this card with the airnow integration, but it should work with any air quality integration that provides an AQI number in a sensor entity.
image:
yaml:
type: gauge
entity: sensor.airnow_aqi
min: 0
max: 300
name: AQI
unit: ' '
card_mod:
style:
ha-gauge$: |
.value {
--gauge-color:
{% if states.sensor.airnow_aqi.state | int < 51 %}
#00e400
{% elif states.sensor.airnow_aqi.state | int < 101 %}
#ffff00
{% elif states.sensor.airnow_aqi.state | int < 151 %}
#ff7e00
{% elif states.sensor.airnow_aqi.state | int < 201 %}
#ff0000
{% elif states.sensor.airnow_aqi.state | int < 301 %}
#8f3f97
{% else %}
#7e0023
{% endif %};
}