EPA Air quality data

Begonnen von Prof. Dr. Peter Henning, 03 Juni 2024, 09:28:00

Vorheriges Thema - Nächstes Thema

Prof. Dr. Peter Henning

I have started this new thread to discuss access to the EPA (Environmental Prtotection Agency) air quality data for the US. For convenience, here are the necessary steps:

The EPA Air Quality API is described here https://aqs.epa.gov/aqsweb/documents/data_api.html

Given the power of FHEM, this is really easy.

1. Signup with the EPA, get the proper api key.
2. Determine the location you want to get data for. In my opinion, it would be best to define a rectangular box in terms of latitude/longitude.
3. Set up an HTTPMOD device in FHEM, which passes the current (or any other) date, the key, your mail address and this bounding box as parameters into the HTTP request. The easiest way to do so is to define attributes like
Zitatattr <devicename> replacement100Mode text
attr <devicename> replacement100Regex %mail%
attr <devicename> replacement100Value <your mail address>
attr <devicename> replacement101Mode text
attr <devicename> replacement101Regex %key%
attr <devicename> replacement101Value <your key>

and then simply use
in the URL for getting the data.

Example, which returns around 1000 data items:

4. Set the attribute extractAllJSON of this device to "1" - which automatically generates readings for any data item received, but _not_ the attributes for the HTTPMOD device necessary to sort out the readings you really need. Experiment with the parameters of the REST call until you get only the necessary data.
5.After you have sucessfully determined the parameters that give you the desired results, set extractAllJSON to "2" - which generates all the necessary attributes for HTTPMOD. And then throw out the readings you do not need, and rename those you need in a more convenient manner.




After experimenting a while I came to the realization that the EPA AQS site is for long term data. I thought the AirNow data was included with this, but it is separate. AirNow is available as an RSS feed, and as "file products". There is also an AirNow app for anyone that wants to take the easy road.

The AirNow site requires you to create an account and requests a phone number, not just an email, but hey! it is the US government, what can go wrong....

I've set up my account, I'll report my progress here. It won't be better than the app, just FHEMinized.