Since creating this fork to add support for the EPA's wildfire smoke AQI calculation, the original author of the integration has made a significant update to not only add support for the EPA's updated AQI calculation but also added support for PurpleAir's personal API key credentials which are required going forward to access the API.
This repo will no longer be maintained and you should use the latest version of the original repo.
A quick and dirty integration for Home Assistant to integrate PurpleAir
air quality sensors. This will create an air_quality
sensor with the
relevant data and create an additional AQI sensor
for ease-of-use.
Simply copy the /purpleair
directory in to your config's
custom_components
directory (you may need to create it), restart Home
Assistant, and add the integration via the UI (it's simple!).
To find a sensor to integrate:
- Look at the PurpleAir Map.
- Find and click an available outdoor station (indoor won't do you any good).
- In the station pop up, click on "Get This Widget".
- Right-click the "JSON" link at the bottom of the black box and copy the link. (Copy Link Location, et al.)
- Go to Home Assistant and go to the Integrations Page.
- Add the PurpleAir integration.
- Paste the link and finish.
You'll have two entities added: an air_quality
entity and a sensor
entity. The air quality fills out all available values via the state
dictionary, and the sensor entity is simply the calculated AQI value,
for ease of use. (The AQI also shows up as an attribute on the air
quality entity as well).
Sensor data on PurpleAir is only updated every two minutes, and to be nice, this integration will batch its updates every five minutes. If you add multiple sensors, the new sensors will take up to five minutes to get their data, as to not flood their free service with requests.
This component is licensed under the MIT license, so feel free to copy, enhance, and redistribute as you see fit.
This was a very single-day project, so it works for outdoor sensors that report an A and B channel. It should work with a single channel sensor as well, but I didn't test that.
This should work with both public and private (hidden) cloud devices. I
don't have any local devices, so this will not currently work with
sensors on your internal network. It should be simple to add it, but I
have no way to test it. It sounds like the payload is slightly different
and the URL is private. This code simply extracts the given sensor ID to
batch the /json
requests (the site is hard-coded too, I just use the
full URL to start).
- Adds support for private hidden sensors and indoor sensors. Fixes #3 and #4.
Initial release (after versioning)