skalnik / aqi-wtf Goto Github PK
View Code? Open in Web Editor NEW😷 WTF is the AQI near me right now?!
Home Page: https://aqi.wtf
License: MIT License
😷 WTF is the AQI near me right now?!
Home Page: https://aqi.wtf
License: MIT License
On iOS, when launched from a homescreen bookmark, there's no chrome, so no reset button. As far as I can tell, the only way to force a reload is to kill the app.
I've hit the rate limit a lot. A custom error message for this would be nice
Someone requested we use the 10 minute average instead of the latest value. I think that'd be good, but I believe we'll need to poll ThingSpeak instead of PA for that. Unsure how hard that'd be to implement, but I wanted to make note of it.
Hi,
I noticed that aqi.wtf has been showing -
for the AQI recently:
It is because the sensors are no longer returning the humidity:
Line 93 in 03e5090
Console output:
> sensor.results[0]
{ID: 37185, Label: "NBN - Bushwick and McKibbin", DEVICE_LOCATIONTYPE: "outside", THINGSPEAK_PRIMARY_ID: "843861", THINGSPEAK_PRIMARY_ID_READ_KEY: "88BKCTH44MUS6WL9", …}
> sensor.results[0].humidity
undefined
the undefined humidity causes aqiFromPM to return a hyphen instead of the AQI calculation.
Related to #67 - Since we don't start off having even 2 minutes of data, I've been thinking about whether we might want to consider finding the 3 nearest sensors (ideally in different directions) and averaging them.
On mobile, the initial load presents a screen like
where the prompt hides the text that, on desktop, would explain what the prompt is for. Especially in combination with #69, it would be better to explain the prompt and have the user express their desire to use geolocation before calling the browser API.
I've started to get more reports (and some anecdotal experience too) that the rate limit is being hit more regularly. Unsure if it's related to #15 or something else. I think we can also move the refreshing up a bit, since I think the sensors just update once a minute based on the age
being in minutes in the API.
Since the messages appear well formed, we should be able to use a regex to check when an error is rate-limiting related and handle it ourselves.
Uhhh I gotta update some stuff again. I was able to at least generate an API key locked to the domains deployed to:
BA110377-679A-11EE-A8AF-42010A80000A
I had the app up while driving home today. Without a browser refresh, the app continued to show the AQI at my starting location, even though it updated every minute.
By the time we've gotten to the error page, we almost always have a lat/lon. We could at least throw a link to the purpleair map there.
We do some basic broken sensor detection now, but based on our communications with EPA folks, it seems like we should definitely improve these. Specifically, we should only consider the measurement is "valid if the A and B channel data are within 5 ug/m3 or 100%"
I haven't been able to reliably make this happen to debug this, but I have seen this happen to me a few times where it just stalls out on "Finding nearby sensors" and never progresses. Clearing the cache and reloading does nothing.
A result of #45, if you have the iPhone X series phone in landscape, the notch now cuts into the text. Less than ideal!
A friend in Seattle reported that aqi.wtf didn't match purpleair.
It appears that this sensor has one "degraded" channel, so it's only getting AQI data from the B sensor. I believe aqi.wtf is doing the wrong thing when averaging the good and bad channels.
The bad sensor is at https://www.purpleair.com/map?opt=1/i/mAQI/a0/cC1&select=20759#13.18/47.5699/-122.39299
Raw sensor data from what purpleair's map is currently seeing is inline below:
{
"mapVersion": "0.18",
"baseVersion": "7",
"mapVersionString": "",
"results": [
{
"ID": 20759,
"Label": "North Admiral",
"DEVICE_LOCATIONTYPE": "outside",
"THINGSPEAK_PRIMARY_ID": "644662",
"THINGSPEAK_PRIMARY_ID_READ_KEY": "R3BQTJCIEGGCCLW5",
"THINGSPEAK_SECONDARY_ID": "644665",
"THINGSPEAK_SECONDARY_ID_READ_KEY": "C9HWY21W209QHQAF",
"Lat": 47.586074,
"Lon": -122.383009,
"PM2_5Value": "0.0",
"LastSeen": 1599604445,
"Type": "PMS5003+PMS5003+BME280",
"Hidden": "false",
"DEVICE_BRIGHTNESS": "15",
"DEVICE_HARDWAREDISCOVERED": "2.0+BME280+PMSX003-B+PMSX003-A",
"Version": "6.01",
"LastUpdateCheck": 1599601323,
"Created": 1544041613,
"Uptime": "540598",
"RSSI": "-75",
"Adc": "0.0",
"p_0_3_um": "0.0",
"p_0_5_um": "0.0",
"p_1_0_um": "0.0",
"p_2_5_um": "0.0",
"p_5_0_um": "0.0",
"p_10_0_um": "0.0",
"pm1_0_cf_1": "0.0",
"pm2_5_cf_1": "0.0",
"pm10_0_cf_1": "0.0",
"pm1_0_atm": "0.0",
"pm2_5_atm": "0.0",
"pm10_0_atm": "0.0",
"isOwner": 0,
"humidity": "17",
"temp_f": "81",
"pressure": "1011.24",
"AGE": 1,
"Stats": "{\"v\":0.0,\"v1\":0.0,\"v2\":0.0,\"v3\":0.0,\"v4\":0.0,\"v5\":0.0,\"v6\":0.0,\"pm\":0.0,\"lastModified\":1599604445640,\"timeSinceModified\":119967}"
},
{
"ID": 20760,
"ParentID": 20759,
"Label": "North Admiral B",
"THINGSPEAK_PRIMARY_ID": "644666",
"THINGSPEAK_PRIMARY_ID_READ_KEY": "KQZOSQYCSX6TN5HK",
"THINGSPEAK_SECONDARY_ID": "644667",
"THINGSPEAK_SECONDARY_ID_READ_KEY": "TFLYCY302WYLGZHH",
"Lat": 47.586074,
"Lon": -122.383009,
"PM2_5Value": "53.98",
"LastSeen": 1599604445,
"Hidden": "false",
"Created": 1544041613,
"Adc": "0.00",
"p_0_3_um": "10503.0",
"p_0_5_um": "3068.66",
"p_1_0_um": "386.09",
"p_2_5_um": "24.43",
"p_5_0_um": "5.84",
"p_10_0_um": "0.39",
"pm1_0_cf_1": "61.27",
"pm2_5_cf_1": "81.91",
"pm10_0_cf_1": "85.59",
"pm1_0_atm": "40.12",
"pm2_5_atm": "53.98",
"pm10_0_atm": "66.71",
"isOwner": 0,
"AGE": 1,
"Stats": "{\"v\":53.98,\"v1\":54.53,\"v2\":54.97,\"v3\":56.62,\"v4\":55.3,\"v5\":29.27,\"v6\":9.6,\"pm\":53.98,\"lastModified\":1599604445641,\"timeSinceModified\":119967}"
}
]
}
Site is saying AQI is 30 rn, but it is very smoky in the SF Mission, and this is reflected on PurpleAir.
Either you're getting the wrong location (seems unlikely, geolocation seems to work correctly on other sites) or maybe you're not excluding indoor sensors?
Right now it’s just a few specific colors. Purple Air has the color change slowly over a gradient to reflect the AQI. This should too.
Can link straight to the map view with: https://www.purpleair.com/map?opt=1/i/mAQI/a10/cC4&select=<SENSOR_ID>#14/<LAT>/<LONG>
. 14
appears to be the zoom level.
Looking at the source code, it appears the geolocation is send to purpleair.com, making the claim that it never leaves your device rather deceiving.
At the very least it seems to code could try to round to whole degrees or something to not upload the exact location. But even then the current claim would still be wrong.
https://community.purpleair.com/t/discontinuation-of-the-json-and-data-json-urls/713
Looks like this will need to use an authenticated API key now, and the authenticated API endpoints.
It looks like you might not be filtering out indoor sensors - the nearest purpleair sensor to me is an indoor one and aqiwtf seems to show values from it, rather than the outdoor sensor 100 meters further away.
This morning in the East Bay, our numbers appeared to be wildly inflated. They looked to correlate with the uncorrected PurpleAir numbers.  I was seeing numbers in the 130s when I believe I should have been seeing numbers in the 90s. At this moment, they look good
Recently a coworker loaded up AQI.WTF and got an error! Turns out they're in the Caribbean and there's no sensors near them within the bounding box we've setup with #85.
We should handle this state a bit better by either:
Hey, there's no sensors within Nkm of you!
Right now it just errors on this line: https://github.com/skalnik/aqi-wtf/blob/main/app.js#L116
Hello, thanks for making this very useful tool.
Request: I'd really like to be able to pick a location or sensor manually rather than relying on the location API prompt.
Context:
I'm always leery of granting location API permission, even though the app says that it's only used on my device. It's possible that the nearest sensor to me isn't great — it may be poorly installed and not representative of the actual air quality nearby. I also want to use aqi.wtf with Flotato, to create a compact standalone app window, and Flotato doesn't support the location API.
This may surprise everyone, but our codes don't seem to be perfect. Occasionally errors occur! I often get screenshots of this but the error state really doesn't have much to go off of. Perhaps some more info like at least line number or maybe some dumped state would be helpful.
Reported from https://twitter.com/NathanMartz/status/1302813841647046656. Looks like sensors that haven't reported in ages are being detected as a nearest sensor to pull from, which isn't ideal.
Once the page is open and nearest sensor is found, it'd be great to live update
From https://fire.airnow.gov/#correction-equation it seems that the EPA recommended algorithm has been tweaked a bit! We should update to match.
Some cool kids told me how they prefer standard over prettier. I don't really care but they're cool and it seems like a nicer tool. Probably worth switching over the auto-formatter to that instead!
It'd be nice to not have a super bright loading page if we can detect the browser wants dark mode!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.