Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
substitutions:
name: apollo-air-1
version: "26.7.1.1"
version: "26.7.15.1"
device_description: ${name} made by Apollo Automation - version ${version}.
# Default OTA password. Override in your device YAML by re-declaring
# `substitutions: { ota_password: !secret <name>_ota_password }` so each
Expand Down Expand Up @@ -71,6 +71,10 @@ globals:
restore_value: no
type: bool
initial_value: "false"
- id: noxPassed
restore_value: no
type: bool
initial_value: "false"


i2c:
Expand Down Expand Up @@ -575,6 +579,7 @@ script:
then:
- lambda: "id(runTest) = false;"
- lambda: "id(testCycleCount) = 0;"
- lambda: "id(noxPassed) = false;"
- while:
condition:
- lambda: "return id(testCycleCount) < 5;"
Expand All @@ -597,11 +602,33 @@ script:
- lambda: "id(runTest) = false;"
- delay: 1s
- lambda: "id(testCycleCount) += 1;"


# 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
Comment on lines +606 to +613

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.

- if:
condition:
- lambda: "return !isnan(id(sen55_nox).state);"
then:
- lambda: "id(noxPassed) = true;"
- logger.log:
format: "TEST: NOX OK - SEN55 confirmed (nox index %.1f)"
args: ["id(sen55_nox).state"]
level: INFO
else:
- logger.log:
format: "TEST FAIL: NOX unavailable - SEN55 is reporting as SEN54"
level: ERROR

#Check If Test Passed To Trigger Lights
- if:
condition:
- lambda: "return id(dps310Passed);"
- lambda: "return id(dps310Passed) && id(noxPassed);"
then:
- lambda: "id(runTest) = false;"
- light.turn_on:
Expand Down