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
Quality of life and other (somewhat major) updates for AirGradient Outdoor and DIY Pro #17
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Make initial_aqi_delay configurable. I've arbitrarily chosen 4h here, and have some ideas how to make it better in the future because I like seeing numbers and can trust myself to know it's not particularly accurate before 24h. - Turned on the captive portal (fallback hotspot is kind of useless without it) - Included a section for Home Assistant API and encryption key (stored as a secret) - Separated AQI into pm2.5, pm10.0, and a generic AQI that matches whichever value is highest. Only the “best of” AQI values are sent to Home Assistant by default. - Set a bunch of the values to disabled_by_default: true so only the combined/average values show up by default in Home Assistant. - Extended the AQI calculations to the maximum of 500 if particle readings are REALLY bad (hello west coast wildfiles … I know some people who were caught in areas “above 500”). - Tried to clean up the AQI calculations (both numeric and text) to be easier to read/maintain. - Switched around a few of the icons: - mdi:blur seems to be a popular one for particle count - Home Assistant seems to use the plain mdi:thermometer icon for temperatures - Use mdi:weather-windy-variant for AQI, which matches Home Assistant's use of it for the air_quality integration.
I now have a better understanding if AQI, and see why it's something that needs to be a "once/day" calculation. To that end, I've added NowCast calculations, which require keeping track of the hourly averages. This actually paves the way for storing the values in flash so they can be restored across reboots and speed up re-calculation (though we'll need to track the hours that each avg comes from so we can age out too-old values). - Rewrite AQI calculation based on official standards. - No more separate 2.5 and 10 variants. AQI is AQI, and there is no reason to provide the separate pseudo-AQI calculations. Plus, it was a lot of duplcated code for little benefit. - Document why we use 18 hours not 24: the official spec allows for calculations once we hit 75% data availability. - Note: This calculation still differs from the official AQI , which is apparently calculated midnight-to-midnight rather than a 24h rolling average. - Add NowCast. This is a 12h version of AQI weighted to the most recent hour, and is a better fit for what a lot of people want from AQI: a measurement of air quality during short-term quality issues like wildfire smoke. - Add sensors to report on the number of minutes remaining before AQI and NowCast are available. - Update some sensors to report 1 accuracy decimal instead of 0. - Changes around a few icons. - Fixes some math and timing values. - More inline comments/documentation.
Tests identified that things just weren't firing at the right time and AQI calculations failed to manifest when they were expected. It turns out the interval timers and sensor updates don't correspond consistently with each other, so this has been rewritten to account for that by: - Attempting calculations after every new value, rather than relying on an interval that may (or more often, may not) line up with the availability of sensor data. - Updating scripts to be able to handle missing pm2.5 or pm10 data, and using `mode: restart` to allow us to simply trigger the calculations after each sensor value without worrying about needing one or both values before attempting the calculation. In this case, "the last write wins," and the last write (script execution) will be the most likely to have both values available. - Updating "minutes remaining" when we fail to be able to calculate a value. This is mostly just a quality of life improvement to avoid situations where we've counted down to zero but still don't have sensor data. This could still happen, but that window is smaller. I've also added some log messages, which may or not be helpful (but they are for debugging).
- Spent way too much time looking for a better font and screen layouts. - Ubuntu is by far the best-looking font at all sizes. - Updated layout is much more readable, especially from a distance. - Update icons to be consistent with AirGradient Open Air config - Include sgp4x platform for VOC and NOx, commented out by default - Ability to display temperatures in C and F - Clean up formatting - Document why formaldehyde sensor is commented out - Add home assistant encryption key (via !secret)
This allows for use of the Statistic card in HA
Adding state_class to average values
Now also includes |
This is apparently now required with the latest esphome firmware
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Outdoor / Open Air
Detailed discussion about these changes is also documented at https://forum.airgradient.com/t/outdoor-monitor-esphome-configuration/823, including a sample lovelace card used to display the information
I fail the challenge from @KarolKozlowski to get the AQI calculations to persist across reboots. However, the main reason for this is that I've learned the persistent flash storage on these devices is only good for about 10k writes, which means it would basically wear out after 416 days. I'd be curious to work on getting these calculations integrated into upstream home assistant rather than a bunch of disparate scripts. It feels like something they'd want to have included. That would also be easier to do proper "midnight to midnight" AQI calculations, too.
DIY Pro: