Air quality index card
Who it’s for
Dashboard authors monitoring outdoor air quality stations, smart city sensors, or indoor ventilation systems ask “is the air quality acceptable right now, or does it need attention?” They want a card that shows the answer at a glance, without requiring anyone to look up a scale.
What it does
A sensor reporting 45 shows a green icon and a green value — Good air quality. The same card turns deep red at 175 — Unhealthy — without any conversion or manual lookup.
- Color-coded icon and value that both change across six AQI severity bands, from Good to Hazardous, so the reading is readable without the number
- Auto-scaling layout that fits any card size
- Last-updated timestamp showing how long ago the reading arrived
- Configurable icon, label, and color ranges
- Shows one AQI reading at a time; it does not chart history or compare multiple sensors
How to set up
Data keys
| Key | Role | Type | Description |
|---|---|---|---|
huiair | Main value | Timeseries | Numeric AQI reading; change the key name to match your device’s telemetry key |
The widget ships with a simulated function datasource key labeled Air Quality Index, so it draws random values until you point the datasource at a device and rename the key.
To point it at your own device: open the dashboard in edit mode, open the widget’s Datasources, pick the entity or entity alias, and replace the function key with the key your device reports.
The card shows the value in AQI units with one decimal place. If the key has never reported, the card displays the label and icon with an empty value, not an error.
Value ranges
| Range | Level | Color |
|---|---|---|
| 0–50 | Good | Green |
| 50–100 | Moderate | Orange |
| 100–150 | Unhealthy (sensitive) | Orange |
| 150–200 | Unhealthy | Red |
| 200–300 | Very Unhealthy | Purple |
| 300+ | Hazardous | Maroon |
How to customize
- To use your own AQI color bands — edit Icon color ranges and Value color ranges; set the same boundaries in both so the icon and the number always agree on the severity.
- To change the icon — set Icon to any Material or MDI icon name.
- To resize the icon — change Icon size.
- To reposition the label — change Label position to top, bottom, left, or right.
- To hide the label, icon, or timestamp — turn off Show label, Show icon, or Show date.
- To switch to an absolute timestamp — turn off Last update ago in the date format settings.
- To match your dashboard’s fonts — set Value font and Label font.
Tips
- Keep Icon color ranges and Value color ranges on the same boundaries so the icon and the number always show the same severity level.
- The default upper range starts at 300 with no upper limit. The card colors the value correctly even when a reading goes above 500.
Share Your Widget with the Community
Built a custom widget? Export it as a JSON from ThingsBoard and publish it to the IoT Hub through a simple 4-step wizard (Upload, Listing, Readme, Review & Submit). Share it with thousands of ThingsBoard developers worldwide and get featured in the catalog.