Add air quality LED indicator#101
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
ChangesAir quality LED control
Sequence Diagram(s)sequenceDiagram
participant User
participant air_quality_led_source
participant update_air_quality_led
participant Interval10s as 10-second interval
participant nowcast_aqi
participant co2
participant sen55_voc
participant rgb_light
User->>air_quality_led_source: choose Off / NowCast AQI / CO2 / VOC Index
air_quality_led_source->>update_air_quality_led: on_value executes
Interval10s->>update_air_quality_led: execute every 10 seconds
alt Off
update_air_quality_led->>rgb_light: turn off
else NowCast AQI
update_air_quality_led->>nowcast_aqi: read value
update_air_quality_led->>rgb_light: set fixed RGB color
else CO2
update_air_quality_led->>co2: read value
update_air_quality_led->>rgb_light: set fixed RGB color
else VOC Index
update_air_quality_led->>sen55_voc: read value
update_air_quality_led->>rgb_light: set fixed RGB color
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Integrations/ESPHome/Core.yaml`:
- Around line 707-710: The 10-second interval is reapplying air-quality LED
updates unconditionally, which can override `statusCheck` and `testScript` while
they are already controlling `rgb_light`. Update the `interval` block and
`update_air_quality_led` flow so it only runs when no other script owns the LED,
or centralize all `rgb_light` writes through a single arbiter/guard that
`statusCheck`, `testScript`, and the air-quality updater all consult before
changing state.
- Around line 667-693: The source-selection logic in the metric update handler
leaves rgb_light unchanged when the chosen reading is NaN, so stale colors
persist after switching to a warming-up sensor. Update the branch handling in
the lambda that maps src values like "AQI", "CO2", and "VOC Index" to clear or
turn off rgb_light before each early return triggered by isnan(x), so the LED no
longer shows the previous metric until a valid sample arrives.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c55a1a98-dab8-4d91-9156-b189c0c36143
📒 Files selected for processing (2)
Integrations/ESPHome/AIR-1.yamlIntegrations/ESPHome/Core.yaml
update_air_quality_led now bails while statusCheck or testScript is running, so the 10s interval no longer overrides the button-press status flash or the boot self-test colors mid-display. The next interval restores the air-quality color after those scripts release the LED. Addresses CodeRabbit review on ApolloAutomation#101. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The NaN early returns in update_air_quality_led left the previous source's color lit, so switching to a warming-up source (or CO2 on a unit with no CO2 module, which stays unknown) showed a stale, misleading color. Turn rgb_light off on those returns so an unavailable source reads as off instead of the old metric's color. Addresses CodeRabbit review on ApolloAutomation#101. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The on_boot LED nudge ran at priority 500, before the esp32_rmt_led_strip light finished setup, so update_air_quality_led's light call faulted (store access fault in AddressableLight::schedule_show). Move the component.update + script.execute to a separate priority -100 on_boot entry so it runs after rgb_light is ready. Original boot actions stay at priority 500. Addresses crash reported on ApolloAutomation#101. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
4b1b952 to
3f7d21d
Compare
Even at on_boot priority -100 the addressable rgb_light isn't ready, so calling update_air_quality_led during boot still faulted (store access fault in AddressableLight::schedule_show). Drop the boot-time script call entirely; the 10s interval (which runs after setup) and Home Assistant own all LED writes. Keep the early component.update: scd40 so a CO2-selected device still has data by the first interval. Addresses crash reported on ApolloAutomation#101. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Drive the AIR-1's onboard RGB LEDs from air-quality readings. Everything lives in Core.yaml, so all variants pick it up via the core package. - "Air Quality LED Source" select (Off / NowCast AQI / CO2 / VOC Index), default Off. A selected source colors the LEDs on a six-step green->maroon severity scale; thresholds match each metric's range, and the VOC bands line up with the VOC Quality text sensor. - "Air Quality LED Brightness" slider (5-100%, default 100%). Event-driven: each source sensor's on_value fires the updater only when it is the selected source, so the LED tracks readings at their real cadence with no polling. Selecting Off clears the LED once, then leaves it for manual use. A millis() guard skips the early-boot window so the select's restore-publish can't write the light before it is initialized, and the updater defers while statusCheck/testScript own the LED. An unavailable source (NaN, e.g. CO2 with no module) clears the LED instead of showing a stale color. Bumps version to 26.6.25.1. Verified on hardware and with a full esphome 2026.6.2 compile. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
7b8c7a8 to
cc1b87c
Compare
Version: 26.6.25.1
Adds an air quality LED indicator that drives the onboard RGB LEDs from the AIR-1's own readings. Everything lives in
Core.yaml, so AIR-1 / BLE / Factory all get it via the core package.Adds:
Color thresholds:
Design notes:
on_valuefires the updater only when it's the selected source, so the LED tracks readings at their real cadence (AQI/VOC ~10s, CO2 60s) with no polling.RGB Lightcontrol still works.millis()guard skips the early-boot window so the select'srestore_valuepublish can't write the light before it's initialized; the updater also defers whilestatusCheck/testScriptown the LED.Fixes: N/A
Breaks: Nothing. New entities only, default Off.
Verified on hardware and with a full esphome 2026.6.2 compile.
Docs: ApolloAutomation/docs page updated (Air Quality LED Source / Brightness).
Checks:
(Version substitution lives in Core.yaml, which feeds AIR-1.yaml.)
🤖 Generated with Claude Code