skalnik / aqi-wtf

šŸ˜· WTF is the AQI near me right now?!
https://aqi.wtf
MIT License
44 stars 12 forks source link

App shows ā€œ-ā€ instead of AQI #74

Open kevin1 opened 2 years ago

kevin1 commented 2 years ago

Hi,

I noticed that aqi.wtf has been showing - for the AQI recently:

19945775-A6A7-433A-8F7B-605554444E1D

It is because the sensors are no longer returning the humidity:

https://github.com/skalnik/aqi-wtf/blob/03e5090f8af3d6bf7aea47cd27e9d089103a877f/app.js#L93

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.

skalnik commented 2 years ago

Oooh weird! Thanks for the report. It still works for me, so seems that some sensors don't return this. We should definitely fail a bit more gracefully!

kevin1 commented 2 years ago

@skalnik just for my own education, is it possible to do this calculation without humidity? Iā€™m wondering what a good solution would be.

danisyellis commented 2 years ago

It looks like the humidity is needed for the calculation using the EPA recommended corrections. But the AQandU function is still in the codebase. Perhaps the best option would be if the sensor doesn't return the humidity, use the AQandU calculation instead (and note that when displaying the results).

skalnik commented 2 years ago

I think that's reasonable! Another idea would be cutting down the list of sensors just to those that have humidity?