[RELEASE] PurpleAir AQI monitoring driver

This driver uses the PurpleAir API to provide the air quality as reported by a selected sensor or by averaging the reports from sensors in the area you choose. There is a deprecated PurpleAir access method which some older drivers used, but I didn't see anything yet that uses this newer access method.

To begin using this driver you will need a free API key from PurpleAir which can be requested by sending an email to contact@purpleair.com.

Once you have your key just enter it and the driver will fetch all of the AQI reports in your area and report the average of them. The default search area is a square that extends 0.5 miles from the position reported by your Hub.

Alternatively, if you would like to choose a specific device to monitor you can find a device on map.purpleair.com and enter the device index. The device index can be found by selecting the device on the map and then looking for "Select=INDEX" in the URL. Currently only one device can be selected.

Below is the driver, please let me know if you have any questions or issues.

https://raw.githubusercontent.com/pfmiller0/Hubitat/main/PurpleAir%20AQI%20Virtual%20Sensor.groovy

4 Likes

Installed. Requested and input a new API from PurpleAir. I get this in the log:

`

dev:12432022-01-21 03:25:33.256 pm errororg.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No signature of method: user_driver_hyposphere_net_PurpleAir_AQI_Virtual_Sensor_1004.poll() is applicable for argument types: () values: []

`
UPDATE: I increased the search range and it found some sensors.

1 Like

I wasn't able to reproduce that error by decreasing my search area. I do already have a check for if no sensors are found in the specified area. When you got that error everything was using default values other than the key you entered?

I am thinking it may have been the newly issue API key was not yet active in their systems. Could that have cause the error ... if the API key used was not found?

I don't think that would cause it, there's a message about an http 403 error that should show up in the logs if the key is invalid. Adding a better error message for that is on my to-do list.

I've never seen your error in a few months of running this driver, hopefully you won't see it again!

Also I did just update the version in GitHub to a newer version I had on my Hubitat. Only real change is there's an option to average the devices found weighted by distance.

1 Like

Download the Hubitat app