Skip to content

Add physics-based predicted room temperature & humidity (re-land #102) - #135

Merged
Bunton33 merged 8 commits into
betafrom
predicted-room-temp-humidity
Oct 16, 2026
Merged

Bunton33 merged 8 commits into
betafrom
predicted-room-temp-humidity

Conversation

@Bunton33

@Bunton33 Bunton33 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Version: 26.10.16.1

What does this implement/fix?

Re-lands @bharvey88's "Predicted Room Temperature & Humidity" work from #102. That PR was closed without merging and its fork branch was deleted, so it can't be reopened. This branch has Brandon's six commits unchanged, with authorship kept. Research and coefficient fitting are by Ellude (Apollo Discord).

The feature is already documented on the wiki: https://wiki.apolloautomation.com/products/air1/additional-info/predicted-room-temp-humidity/

What it adds, all in the new Integrations/ESPHome/Predicted_Room.yaml, which Core.yaml includes as a package. Everything is disabled_by_default: true.

  • Sensors: Predicted Room Temperature, Predicted Room Humidity. Both return NaN until uptime reaches 180 s, with a NaN-uptime guard, and return NaN when any input is NaN.
  • CONFIG numbers: Physics Multiplier P (0.5357, provisional), Baseline Offset (0 °C), SCD40 Temperature Offset (0), SCD40 Humidity Offset (0).
  • Exposes the SCD40 Temperature/Humidity and DPS310 Temperature entities (via !extend) so the lambdas can read them.

Changes on top of #102

  • Merged current beta (26.10.8.1). There were no conflicts. The only Core.yaml overlap is the new packages: key, which sits next to beta's new substitutions/OTA/channel/BLE-proxy blocks and doesn't touch them.
  • Bumped the version to 26.10.16.1 so beta-channel devices get offered the OTA.

Verification

  • All three variants (AIR-1, AIR-1_BLE, AIR-1_Factory) compile on ESPHome 2026.9.1 (stable), 2026.10.0b4 (beta) and 2026.11.0-dev, with no compiler warnings. Flash use is 90–93.5%.
  • I diffed the rendered config against beta for every variant. The changes are additive: 4 new numbers, 2 new template sensors, SCD40 temperature/humidity added, and the DPS310 temperature named and no longer internal. Everything else is identical, including the stock SEN55 Temperature/Humidity.

Known limitations (worth adding to the wiki)

  • The predictions need all of SEN55, DPS310 and SCD40. On a unit without an SCD40 (or if it fails), both predicted sensors stay unknown.
  • With Prevent Sleep off, the device only stays awake about 2 minutes per wake, so the 180 s hold never clears and the predicted sensors never publish. Prevent Sleep defaults to on.
  • Baseline Offset also moves Predicted Room Humidity (about 6.5 % of the reading per °C, e.g. +1 °C took 55.7 → 52.2 %RH on a real unit), because humidity is re-referenced to the predicted temperature. This is physically expected; see the hollymckay discussion in Add physics-based predicted room temperature & humidity #102.

Supersedes #102.

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

Compiles and validates on all variants and ESPHome versions. Hardware check on one AIR-1 (USB flash from 26.10.8.1, SCD40 fitted): settings preserved, predicted sensors held until uptime ≥ 180 s, then published; Baseline Offset +1 °C moved Predicted Room Temperature +1.01 °C.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added predicted room temperature and humidity readings, calculated from available sensor measurements after a three-minute startup period.
    • Added adjustable settings for prediction tuning and sensor offsets. These settings are disabled by default and persist across restarts.
    • Updated the ESPHome firmware version substitution.

bharvey88 and others added 8 commits June 25, 2026 19:12
Adds two template sensors that estimate true room temperature and
humidity, correcting for the Air-1 enclosure's self-heating:

- Predicted Room Temperature: weighted blend of SEN55/DPS310/SCD40
  temperatures with a thermal-gradient correction (Physics Multiplier P,
  Baseline Offset).
- Predicted Room Humidity: re-references each sensor's RH to the
  predicted room temperature via the Magnus formula, then blends by
  manufacturing tolerance.

Supporting additions, all additive (stock sensors and their defaults are
unchanged):
- New CONFIG numbers: Physics Multiplier P, Baseline Offset,
  SCD40 Temperature Offset, SCD40 Humidity Offset (all default to a
  neutral value).
- Expose SCD40 Temperature/Humidity and name the DPS310 Temperature
  sensor so the prediction lambdas can read them.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
These are advanced, opt-in sensors. Mark the two Predicted Room sensors,
their CONFIG tuning numbers, and the newly-exposed SCD40/DPS310 inputs as
disabled_by_default so the stock device page stays clean. The prediction
lambdas still read the on-device state regardless of HA enablement, so
functionality is unaffected when the entities are hidden.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Add attribution to Ellude (Apollo Discord), who did the research and
coefficient fitting. Note that the Physics Multiplier P default (0.5357)
is provisional pending a better fitted value.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Guard the warm-up gate against a NaN sys_uptime. sys_uptime is NaN until
  its first publish (~60s) and NaN < 180.0 is false, so the gate could let
  both prediction lambdas run before warm-up. Check isnan() first.
- Extend the temperature lambda's NaN check to the coefficient/baseline
  values so a bad restore can't slip a NaN through the arithmetic.
- Add isnan offset guards to the SCD40 temperature/humidity filters,
  matching the existing DPS310 pressure-offset pattern.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Swap 17.62/243.12 (Sonntag 1990) for 17.625/243.04 per review, and cite
the source in a comment. The formula is only used as a ratio, so the
difference in predicted RH is under 0.02 %RH either way; this just makes
the constants traceable to the cited paper.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Core.yaml now carries only a five-line packages include; all prediction
logic lives in the new Integrations/ESPHome/Predicted_Room.yaml:

- The four tuning CONFIG numbers and both Predicted Room template
  sensors moved over verbatim.
- The SCD40 temperature/humidity exposure (with offset filters) and the
  DPS310 temperature naming now extend the Core hardware blocks via
  id: !extend, so the stock sensor definitions in Core.yaml are
  untouched by this PR.

No functional change: all three variants validate and the rendered
config contains the same entities as before, still disabled by default.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the new-feature New feature label Oct 16, 2026
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 34cc8525-e856-42fe-b327-8c530c24aa16
📥 Commits

Reviewing files that changed from the base of the PR and between 798caf1 and 87ff16a.

📒 Files selected for processing: 2
  • Integrations/ESPHome/Core.yaml
  • Integrations/ESPHome/Predicted_Room.yaml

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Walkthrough

The ESPHome Core configuration updates its firmware version and includes a new predicted_room package. The package adds configurable offsets and coefficients, named SCD40 and DPS310 readings, and predicted room temperature and humidity sensors.

Changes

Predicted room sensors

Layer / File(s) Summary
Prediction settings and sensor inputs
Integrations/ESPHome/Predicted_Room.yaml, Integrations/ESPHome/Core.yaml
Adds persistent CONFIG settings and named sensor readings for prediction inputs. Core includes the package and changes the configured firmware version to 26.10.16.1.
Predicted room temperature
Integrations/ESPHome/Predicted_Room.yaml
Adds a temperature prediction that waits for 180 seconds of uptime and valid inputs, then blends three sensor readings and applies a configured gradient correction and baseline.
Predicted room humidity
Integrations/ESPHome/Predicted_Room.yaml
Adds a humidity prediction that adjusts SEN55 and SCD40 readings to the predicted room temperature, blends them, and clamps the result to 0–100%.

Priority: ➖ Normal

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

Change: Feature

Suggested reviewers: trevorschirmer

Merge Risk: ⚪ Minimal · up to 87ff1

No concrete issue remains that would prevent merging. Physical-device validation is still outstanding.

Pre-merge checks: Passed 5
Check name Status Explanation
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: adding physics-based predicted room temperature and humidity calculations. It is specific, concise, and related to the pull request objectives.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

I check the room and greet the breeze,
Three readings blend with hopping ease.
I tune the warmth and dampness too,
Then wait for steady readings through.
New settings settle, sensors shine,
I nibble greens and call them fine!

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

@Bunton33
Bunton33 merged commit b14918d into beta Oct 16, 2026
14 of 15 checks passed
@Bunton33
Bunton33 deleted the predicted-room-temp-humidity branch October 16, 2026 16:19
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.

2 participants