Skip to content

Add SEN54/NOX detection to AIR-1 factory test#113

Closed
bharvey88 wants to merge 1 commit into
ApolloAutomation:betafrom
bharvey88:sen54-nox-factory-check
Closed

Add SEN54/NOX detection to AIR-1 factory test#113
bharvey88 wants to merge 1 commit into
ApolloAutomation:betafrom
bharvey88:sen54-nox-factory-check

Conversation

@bharvey88

@bharvey88 bharvey88 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Version: 26.7.15.1

What does this implement/fix?

A customer's AIR-1 showed no NOX value. Logs:

[sen5x:125]: Type: SEN54
[sen5x:139]: NOx requires a SEN55

The SEN5x component reads the product-name register straight off the chip.
When it reads "SEN54" it nulls the NOX sensor, so NOX never publishes. That
means a mislabeled or wrong-part sensor ships with no NOX and the factory
test never catches it (testScript only checked DPS310 pressure).

testScript now also validates NOX after the DPS310 loop:

  • Waits up to 30s for id(sen55_nox) to report a value. A SEN54 (or a chip
    reporting itself as one) leaves it NaN forever; a healthy SEN55 publishes
    a NOX index within a couple of update cycles. The wait returns as soon as
    a value arrives, so a good unit isn't slowed down.
  • LED goes green only when DPS310 AND NOX pass; either failure flashes red.
  • Logs "TEST FAIL: NOX unavailable - SEN55 is reporting as SEN54" so the
    flash station can pull the unit.

AIR-1 is the only Apollo product with a SEN55, so no other repos are affected.

Types of changes

  • Bugfix (fixed change that fixes an issue)
  • New feature (thanks!)
  • Breaking change (repair/feature that breaks existing functionality)
  • Dependency Update - Does not publish
  • Other - Does not publish
  • Website of github readme file update - Does not publish
  • Github workflows - Does not publish

Checklist / Checklijst:

  • The code change has been tested and works locally
  • The code change has not yet been tested

If user-visible functionality or configuration variables are added/modified:

  • Added/updated documentation for the web page

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved device self-tests by validating NOX sensor readings.
    • Devices now indicate a successful test only when both pressure and NOX checks pass.
    • Added clearer handling for sensors that fail to provide valid NOX data.
  • Maintenance

    • Updated the ESPHome version used by the device configuration.

The SEN5x component drops the NOX sensor when the chip reports itself
as a SEN54, so a mislabeled or wrong-part unit ships with no NOX data
and nothing in the factory test catches it.

testScript now waits up to 30s for a NOX reading after the DPS310
check and only lights the LED green when NOX reports a value. A unit
whose NOX stays NaN flashes red and logs "SEN55 is reporting as
SEN54" for the flash station.

Bumps version to 26.7.15.1.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@bharvey88 bharvey88 added the new-feature New feature label Jul 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

ESPHome Core updates its version substitution and extends the device self-test with a NOX sensor validation. The passed LED now requires both DPS310 and NOX checks to succeed.

Changes

ESPHome self-test

Layer / File(s) Summary
NOX state and self-test validation
Integrations/ESPHome/Core.yaml
Updates the ESPHome version, adds the noxPassed flag, validates a non-NaN sen55_nox reading within 30 seconds, and requires both sensor checks before lighting the passed LED.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: bugfix

Poem

I’m a rabbit with sensors bright,
NOX now joins the test tonight.
DPS and NOX must both agree,
Then the passed light shines for me! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding SEN54/NOX detection to the AIR-1 factory test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 606-613: Increase the timeout in the SEN54/SEN55 NOX wait_until
block from 30 seconds to at least 45–50 seconds so testScript accommodates the
sensor’s documented warm-up period. Keep the existing
!isnan(id(sen55_nox).state) condition unchanged.
🪄 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: eb3aa062-1644-4f1b-871b-ac178e3114c5

📥 Commits

Reviewing files that changed from the base of the PR and between 1b86a0c and 91726e4.

📒 Files selected for processing (1)
  • Integrations/ESPHome/Core.yaml

Comment on lines +606 to +613
# SEN54 detection: when the SEN5x chip reports itself as a SEN54 the
# component nulls the NOX sensor, so its state stays NaN forever. A
# healthy SEN55 publishes a NOX index within a couple of update cycles,
# so wait up to 30s for a value before deciding.
- wait_until:
condition:
- lambda: "return !isnan(id(sen55_nox).state);"
timeout: 30s

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Increase NOX timeout to account for the sensor's warm-up period.

The SEN55 datasheet specifies that both VOC and NOX index values require a 45-second warm-up period after power-on before they return valid data (outputting 0x7FFF, translated to NaN by ESPHome, in the meantime).

Since testScript runs on boot (via AIR-1_Factory.yaml), the device will have been powered on for just a few seconds. The maximum 5-second wait for the DPS310 plus this 30-second NOX timeout totals around 35 seconds. This falls short of the 45-second hardware warm-up time, meaning the factory test will likely time out and falsely fail healthy SEN55 units.

Please consider increasing the timeout to at least 45-50 seconds.

🕒 Proposed timeout fix
           - wait_until:
               condition:
                 - lambda: "return !isnan(id(sen55_nox).state);"
-              timeout: 30s
+              timeout: 45s
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# SEN54 detection: when the SEN5x chip reports itself as a SEN54 the
# component nulls the NOX sensor, so its state stays NaN forever. A
# healthy SEN55 publishes a NOX index within a couple of update cycles,
# so wait up to 30s for a value before deciding.
- wait_until:
condition:
- lambda: "return !isnan(id(sen55_nox).state);"
timeout: 30s
# SEN54 detection: when the SEN5x chip reports itself as a SEN54 the
# component nulls the NOX sensor, so its state stays NaN forever. A
# healthy SEN55 publishes a NOX index within a couple of update cycles,
# so wait up to 30s for a value before deciding.
- wait_until:
condition:
- lambda: "return !isnan(id(sen55_nox).state);"
timeout: 45s
🤖 Prompt for 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.

In `@Integrations/ESPHome/Core.yaml` around lines 606 - 613, Increase the timeout
in the SEN54/SEN55 NOX wait_until block from 30 seconds to at least 45–50
seconds so testScript accommodates the sensor’s documented warm-up period. Keep
the existing !isnan(id(sen55_nox).state) condition unchanged.

@bharvey88 bharvey88 closed this Jul 15, 2026
@bharvey88
bharvey88 deleted the sen54-nox-factory-check branch July 15, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant