MMM-AQI is a module for MagicMirror² to display the Air Quality Index (AQI) using the World Air Quality Index project API.
|
|
|
|
cd ~/MagicMirror/modules
git clone https://github.com/ryck/MMM-AQI
cd MMM-AQI
npm installThe entry in config.js can include the following options:
| Option | Description |
|---|---|
token |
Required. Your private API token (see aqicn.org/data-platform/token/) Type: string |
city |
Required. Name of the city (e.g., Beijing), station id (e.g., A7397), or here to let WAQI infer your city via geolocation.Type: stringDefault: here |
iaqi |
Show individual AQI rows for pollutants (PM2.5, PM10, NO₂, CO, SO₂, O₃). Type: booleanDefault: true |
weather |
Include temperature, humidity, pressure, and wind rows (when provided by WAQI). Type: booleanDefault: false |
units |
Unit system for weather rows. Type: stringPossible values: metric, imperialDefault: metric |
maxEntries |
Maximum IAQI rows to render (useful if the API returns many pollutants). Type: integerDefault: 10 |
showLastUpdate |
Display the timestamp of the last successful update. Type: booleanDefault: true |
overrideCityDisplayName |
Force a custom label for the city instead of the API-provided name. Type: string | nullDefault: null |
updateInterval |
How often to refresh the AQI data (milliseconds). Type: integerDefault: 30 * 60 * 1000 (30 minutes) |
initialLoadDelay |
Delay the very first API request (milliseconds). Helpful when sharing API tokens between modules. Type: integerDefault: 0 |
animationSpeed |
Duration of DOM update animations (milliseconds). Type: integerDefault: 1000 |
debug |
Log detailed information (API URLs, responses, etc.) to the MagicMirror console. Type: booleanDefault: false |
Here is an example of an entry in config.js
{
module: "MMM-AQI",
position: "bottom_left",
header: "Air Quality Index (AQI)",
config: {
token: "YOUR_TOKEN",
city: "here",
iaqi: true,
weather: true,
units: "metric",
maxEntries: 6,
showLastUpdate: true,
overrideCityDisplayName: null,
updateInterval: 30 * 60 * 1000,
initialLoadDelay: 0,
animationSpeed: 1000,
debug: false
}
},The API is quite picky with the cities, so your best option is to use the keyword here or an id. To find your id, just enter this URL in your browser:
https://api.waqi.info/search/?token=TOKEN&keyword=CITY
Note: You need to replace TOKEN and CITY for your token (the same one you are using in the module works) and the city you are looking for, repectively.
- The World Air Quality Index project for providing the API.
- Michael Teeuw for the MagicMirror² framework that made this module possible.