Skip to content

ryck/MMM-AQI

Repository files navigation

MMM-AQI

MMM-AQI is a module for MagicMirror² to display the Air Quality Index (AQI) using the World Air Quality Index project API.

Default layout
config: {
	iaqi: false,
	weather: false,
	showLastUpdate: false
}
IAQI breakdown
config: {
	iaqi: true,
	weather: false,
	showLastUpdate: false
}
Weather metrics
config: {
	iaqi: true,
	weather: true,
	showLastUpdate: false
}
Full on
config: {
	iaqi: true,
	weather: true,
	showLastUpdate: true
}

Installation

cd ~/MagicMirror/modules
git clone https://github.com/ryck/MMM-AQI
cd MMM-AQI
npm install

Config

The 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: string
Default: here
iaqi Show individual AQI rows for pollutants (PM2.5, PM10, NO₂, CO, SO₂, O₃).
Type: boolean
Default: true
weather Include temperature, humidity, pressure, and wind rows (when provided by WAQI).
Type: boolean
Default: false
units Unit system for weather rows.
Type: string
Possible values: metric, imperial
Default: metric
maxEntries Maximum IAQI rows to render (useful if the API returns many pollutants).
Type: integer
Default: 10
showLastUpdate Display the timestamp of the last successful update.
Type: boolean
Default: true
overrideCityDisplayName Force a custom label for the city instead of the API-provided name.
Type: string | null
Default: null
updateInterval How often to refresh the AQI data (milliseconds).
Type: integer
Default: 30 * 60 * 1000 (30 minutes)
initialLoadDelay Delay the very first API request (milliseconds). Helpful when sharing API tokens between modules.
Type: integer
Default: 0
animationSpeed Duration of DOM update animations (milliseconds).
Type: integer
Default: 1000
debug Log detailed information (API URLs, responses, etc.) to the MagicMirror console.
Type: boolean
Default: 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
		}
	},

Find your city

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.

Thanks To...

About

MagicMirror module to get the Air Quality Index (AQI)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5