Skip to content

[apollo_msr-2] Add configurable DPS310 pressure offset#62

Merged
bharvey88 merged 3 commits intobetafrom
dps310-pressure-offset
Mar 2, 2026
Merged

[apollo_msr-2] Add configurable DPS310 pressure offset#62
bharvey88 merged 3 commits intobetafrom
dps310-pressure-offset

Conversation

@bharvey88
Copy link
Contributor

@bharvey88 bharvey88 commented Feb 26, 2026

What does this implement/fix?

Adds a user-configurable DPS310 Pressure Offset (CONFIG, -100 to +100 hPa, 0.1 step, persists across reboots). The offset is applied in the existing pressure filter lambda before the delta-reporting check, with an isnan() guard for safety during startup.

Types of changes

  • New feature

Summary by CodeRabbit

  • New Features
    • Added a configurable "DPS310 Pressure Offset" setting to fine‑tune pressure readings; disabled by default, restores value on restart, initial 0.0, adjustable -100 to 100 hPa with 0.1 step, shown as a box control, and uses optimistic updates.
    • Pressure sensor readings now apply the configured offset; existing temperature offset behavior remains unchanged.

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 796b4f9 and 3fb5fba.

📒 Files selected for processing (1)
  • Integrations/ESPHome/Core.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • Integrations/ESPHome/Core.yaml

Walkthrough

Added a new ESPHome template sensor dps310_pressure_offset (disabled by default) and applied its value inside the DPS310 pressure sensor lambda to adjust reported pressure before existing reduction logic.

Changes

Cohort / File(s) Summary
ESPHome DPS310 Pressure Offset
Integrations/ESPHome/Core.yaml
Added template sensor dps310_pressure_offset (disabled_by_default, restore_value, initial 0.0, range -100.0..100.0 hPa, entity_category CONFIG, unit hPa, optimistic, step 0.1, mode box). Injected usage of id(dps310_pressure_offset).state into the DPS310 pressure sensor lambda to apply the offset (if not NaN) before existing reduction logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A little tweak to pressure's song,
A box to nudge the readings strong,
Disabled first, then quietly set,
Offset helps the numbers get—
Just right beneath the sky's wide dome. 🥕📉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a configurable DPS310 pressure offset parameter.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dps310-pressure-offset

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.

@github-actions github-actions bot added the new-feature New feature label Feb 26, 2026
@TrevorSchirmer
Copy link
Member

Beta

@bharvey88 bharvey88 force-pushed the dps310-pressure-offset branch from c3ab284 to 796b4f9 Compare February 27, 2026 20:13
@bharvey88 bharvey88 changed the base branch from main to beta February 27, 2026 20:13
@TrevorSchirmer
Copy link
Member

@CodeRabbit review

@coderabbitai
Copy link

coderabbitai bot commented Feb 28, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Integrations/ESPHome/Core.yaml`:
- Around line 361-364: The temperature lambda is incorrectly adding
id(dps310_pressure_offset).state (hPa) to the ESP internal temperature via the
variable current_value; remove that addition from the ESP temperature sensor's
lambda so the pressure offset is not applied to temperature. Locate the code
using current_value and id(dps310_pressure_offset) in the ESP temperature sensor
block and delete the offset application (or wrap it so it only runs in the
DPS310 pressure sensor lambda). Ensure the DPS310 pressure sensor's lambda
explicitly reads id(dps310_pressure_offset).state and applies it to pressure
values only.
- Around line 609-612: The pressure offset (id(dps310_pressure_offset)) is being
added to the LTR390 UV Index sensor via current_value, corrupting UV readings;
remove the addition of id(dps310_pressure_offset).state from the LTR390 sensor
code (the block that references current_value and id(dps310_pressure_offset)) so
the offset is only used in the DPS310 pressure sensor logic, not in the LTR390
UV Index handling.
- Around line 582-585: The LTR390 light sensor handler is incorrectly applying
the DPS310 pressure offset: remove the block that reads
id(dps310_pressure_offset).state and adds it to current_value inside the
LTR390/LTR390 update logic so lux readings are not modified; ensure the
dps310_pressure_offset is only read and applied in the DPS310 pressure sensor
code (look for references to id(dps310_pressure_offset), current_value, and the
LTR390 update function) and keep the offset application limited to the DPS310
pressure processing path.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between afa8570 and 796b4f9.

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

@TrevorSchirmer
Copy link
Member

@bharvey88 CodeRabbit found some bugs

dps310_pressure_offset was incorrectly applied to three sensors that
have no relation to barometric pressure: ESP internal temperature,
LTR390 light, and LTR390 UV Index. The offset is now applied only in
the DPS310 pressure sensor lambda where it belongs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bharvey88 bharvey88 merged commit 21084d1 into beta Mar 2, 2026
11 checks passed
@bharvey88 bharvey88 deleted the dps310-pressure-offset branch March 2, 2026 16:34
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