Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New API #82

Merged
merged 3 commits into from
Jun 11, 2022
Merged

New API #82

merged 3 commits into from
Jun 11, 2022

Conversation

skalnik
Copy link
Owner

@skalnik skalnik commented Jun 11, 2022

PurpleAir updated their API! It's new and shiny, and much like the old, but slightly not. This PR updates AQI WTF to use it.

@vercel
Copy link

vercel bot commented Jun 11, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
aqi-wtf ✅ Ready (Inspect) Visit Preview Jun 11, 2022 at 1:42AM (UTC)

@obra
Copy link
Collaborator

obra commented Jun 11, 2022

Is it Kosher to stick your api key in version control like this? if so, I’m +1 to merge

@skalnik
Copy link
Owner Author

skalnik commented Jun 11, 2022

Is it Kosher to stick your api key in version control like this? if so, I’m +1 to merge

🤷 This app is all client side so it'll be in accessible to end users easily, no matter what. I'm leaning on yolo yes and see what happens. It is, at least, read only, which helps.

for (const sensor of json.data) {
// Ignore sensors which are either indoor or updated over 5 minutes ago
if (sensor[fields["indoor"]] === 0 && sensor[fields["age"]] < 5) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now done server side, via location_type=0&max_age=300 appended to the full sensor list API requests 🎉

announceState("Calculating AQI");

for (const subsensor of sensor.results) {
if (!bustedSensor(subsensor)) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We get a lot less information from PurpleAir now, making this check a lot simpler, so I brought it inline. If we ever want, we can request more data from them and bring this back.

@obra
Copy link
Collaborator

obra commented Jun 11, 2022

works for me.

@obra obra merged commit 1ac73cb into main Jun 11, 2022
@obra obra deleted the new-api branch June 11, 2022 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants