Get email alerts when AQI is unhealthy near you.
- Sign up or login to Val Town
- Click
Fork
- Change
location
(Line 2) to describe your location (it accepts fairly flexible English descriptions) - Click
Run
This val uses nominatim's geocoder to get your lat, lon, and air quality data from OpenAQ. It uses EPA's NowCast AQI Index calculation and severity levels. Learn more: https://www.val.town/v/stevekrouse.easyAQI
Readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
export async function aqi(interval: Interval) {
const location = "brooklyn navy yard"; // <-- change to place, city, or zip code
const data = await stevekrouse.easyAQI({ location });
if (!interval.lastRunAt) {
console.email(
`You will now get Air Quality alerts for ${location} if it's unhealthy. It is now ${data.aqi} which is ${data.severity}.`,
`AQI Alerts for ${location} setup!`,
);
}
if (data.severity.includes("Unhealthy")) {
console.email(
"Air Quality: " + data.severity,
`AQI in ${location} is ${data.aqi}`,
);
}
}
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.