Skip to content

Make CO2 auto calibration toggle work at runtime#58

Merged
TrevorSchirmer merged 2 commits into
ApolloAutomation:betafrom
bharvey88:co2-asc-toggle
Jun 11, 2026
Merged

Make CO2 auto calibration toggle work at runtime#58
TrevorSchirmer merged 2 commits into
ApolloAutomation:betafrom
bharvey88:co2-asc-toggle

Conversation

@bharvey88

@bharvey88 bharvey88 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Version: 26.6.10.1

What does this implement/fix?

Makes the CO2 auto calibration toggle actually work at runtime, and renames it for consistency with the other SCD40 products.

  • The existing "SCD40 Automatic Self Calibration" switch only set the scd4x component's in-memory flag, which is not written to the sensor until the next reboot. It was also hidden (disabled_by_default: true). The replacement "CO2 Auto Calibration" switch (same name as the new AIR-1/MSR-2/MTR-1 switch) is visible by default and takes effect immediately: the script stops periodic measurement, sends the ASC command over I2C, and restarts measurement. The saved choice is re-applied ~20 seconds after every boot.
  • The on_boot re-apply lambdas in R_PRO-1_W.yaml and R_PRO-1_ETH.yaml are removed; the restored switch state now handles boot re-apply through the same script (one mechanism instead of two).
  • automatic_self_calibration: true is now set explicitly instead of relying on the ESPHome default, so there is no calibration behavior change: ASC was already on by default for the R_PRO-1.
  • Version bumped to 26.6.10.1.

Migration caveat for release notes (why this is marked breaking): the entity rename breaks any automation or dashboard referencing the old switch entity, and means a previously saved switch state does not carry over; devices fall back to the default (on) after updating. Anyone who had the old hidden switch turned off needs to turn the new one off once. Small audience, since the old switch was hidden and required a reboot to act.

This is part of the same rollout as AIR-1, MSR-2, and MTR-1 (which flip ASC from off to on and gain the same switch). A wiki update covering all four products is ready to merge alongside the firmware releases.

Verification: esphome compile passes for R_PRO-1_W.yaml and R_PRO-1_ETH.yaml (ESPHome 2026.1.3). Not yet tested on hardware.

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

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@bharvey88, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 42 minutes and 33 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9022ed76-fa4a-4efc-9c33-cbb2d305ce32

📥 Commits

Reviewing files that changed from the base of the PR and between 80dca16 and 874d09a.

📒 Files selected for processing (3)
  • Integrations/ESPHome/Core.yaml
  • Integrations/ESPHome/R_PRO-1_ETH.yaml
  • Integrations/ESPHome/R_PRO-1_W.yaml
✨ 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 and usage tips.

Rename the hidden "SCD40 Automatic Self Calibration" switch to
"CO2 Auto Calibration" (visible by default) to match the other SCD40
products, and make toggling it take effect immediately. The old
implementation only set the component's in-memory flag, which is not
written to the sensor until the next reboot.

The new script stops periodic measurement, sends the ASC command over
I2C, and restarts measurement. The restored switch state re-applies
the user's choice after every boot, replacing the on_boot lambdas in
the device configs. Also set automatic_self_calibration explicitly
instead of relying on the ESPHome default.

Note: the entity rename means a previously saved switch state does not
carry over; devices fall back to the default (on) after updating.
@TrevorSchirmer TrevorSchirmer merged commit 96254de into ApolloAutomation:beta Jun 11, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants