Get air quality readings from PurpleAir sensors.

Dependencies: perl, curl, jq
A purpleair config block looks like this:
[purpleair]
label=
command=$SCRIPT_DIR/purpleair
interval=60
SENSOR_ID=78305
#TYPE=US_AQI
#COLORS=#85df56,#fbcf4b,#f28c33,#dd4d3c,#cf79e0,#9b2f6a
#NO_COLOR=true
If you do not own a PurpleAir sensor, there may be one near you that you can query. Here's how to find a sensor ID:
If you own a PurpleAir sensor, use its ID. If your sensor is configured to be private, see the PurpleAir FAQ for extra access requirements. If your sensor is public and you do not know its ID, see the instructions above to find it.
There is one required parameter, along with some optional ones:
Parameter | Description --------- | ----------- SENSOR_ID | Required: The PurpleAir sensor to query TYPE | Optional: The air quality computation to perform. Default: US_AQI COLORS | Optional: Comma-separated list of color hex values to use in place of the default colors NO_COLOR | Optional: Any non-empty value causes color to be suppressed
The valid values for TYPE are:
Type | Description ------- | ----------- US_AQI | United States Air Quality Index EU_AQI | European Air Quality Index CA_AQHI | Canada Air Quality Health Index IMECA | Índice MEtropolitano de la Calidad del Aire IAS | Índice de Aire y Salud
The COLORS parameter should be specified without spaces or quotes.
Good: COLORS=#ffffff,#aaaaaa,#888888
Bad: COLORS="#ffffff,#aaaaaa,#888888"
Bad: COLORS=#ffffff, #aaaaaa, #888888
If fewer colors are specified than the TYPE uses by default, a warning will be printed to stderr. Also, any color index higher than the maximum index given will be reduced to the maximum index.
The NO_COLOR parameter suppresses colors, so the output will use the default output color of the bar.
Any non-empty value will trigger its effect, but by convention it should be specified NO_COLOR=true.