Back

Version 47

6/27/2023
async function aqiNotifier() {
// The realtime Air Quality Index (AQI) for any location
const myAQI = await @stevekrouse.easyAQI({
location: "South Orange, New Jersey 07079",
});
const previousAQI = @me.databaseVal.pop();
let direction = "";
if (myAQI.aqi < previousAQI["AQI"]) {
direction = "improving";
}
else if (myAQI.aqi > previousAQI["AQI"]) {
direction = "getting worse";
}
else {
direction = "stable";
}
const messageText =
`The AQI is ${direction} at ${myAQI.aqi} which is categorized as ${myAQI.severity}. Previous Severity: ${previousAQI.severity}`;
@me.databaseVal.splice(0, @me.databaseVal.length);
const storeAQI = @me.databaseVal.push({
"AQI": Number(myAQI.aqi),
"severity": myAQI.severity,
"direction": direction,
});
if (
(previousAQI["severity"] == "Good" &&
myAQI.severity == previousAQI["severity"])
) {
return;
}
else {
console.email(messageText, messageText);
}
}
Updated: October 23, 2023