[apollo_air-1] Add configurable DPS310 pressure offset#77
[apollo_air-1] Add configurable DPS310 pressure offset#77
Conversation
WalkthroughVersion updated to 26.2.24.1. A new DPS310 Pressure Offset number entity was added with configurable range and initial value. The DPS310 sensor configuration was modified to apply this offset through a lambda filter for dynamic pressure adjustment. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 228-229: The DPS310 pressure offset filter uses the opposite sign
from the SEN55 offsets; change the filter in the DPS310 sensor's filters lambda
(the expression using id(dps310_pressure_offset).state) to subtract the stored
offset (matching the SEN55 pattern used by id(sen55_temperature_offset) and
id(sen55_humidity_offset)) so users apply offsets with the same sign convention
across sensors.
| filters: | ||
| - lambda: return x + id(dps310_pressure_offset).state; |
There was a problem hiding this comment.
Inconsistent sign convention vs. the existing SEN55 offsets.
Both SEN55 offsets subtract the stored value:
# lines 257, 263
- lambda: return x - id(sen55_temperature_offset).state;
- lambda: return x - id(sen55_humidity_offset).state;The new DPS310 filter adds:
- lambda: return x + id(dps310_pressure_offset).state;With the SEN55 convention, a user sets +2 to mean "the sensor reads 2 units too high — correct it down." With the additive convention here, the same user would need to set −2 to achieve the same downward correction — opposite intuition. Both approaches are functionally valid (the ±100 range covers both directions), but the inconsistency is a UX hazard for anyone who has already calibrated SEN55.
Consider aligning with the SEN55 convention:
🔧 Proposed fix
- - lambda: return x + id(dps310_pressure_offset).state;
+ - lambda: return x - id(dps310_pressure_offset).state;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@Integrations/ESPHome/Core.yaml` around lines 228 - 229, The DPS310 pressure
offset filter uses the opposite sign from the SEN55 offsets; change the filter
in the DPS310 sensor's filters lambda (the expression using
id(dps310_pressure_offset).state) to subtract the stored offset (matching the
SEN55 pattern used by id(sen55_temperature_offset) and
id(sen55_humidity_offset)) so users apply offsets with the same sign convention
across sensors.
|
Superseded by #78 (branch renamed to dps310-pressure-offset) |
Version: 26.2.24.1
What does this implement/fix?
Adds a user-configurable pressure offset (
DPS310 Pressure Offset) to the DPS310 sensor, following the same pattern already used for the SEN55 temperature and humidity offsets. The offset is exposed as anumberentity (CONFIG category, ±100 hPa range, 0.1 hPa step, persists across reboots). A lambda filter applies it to the reported pressure value.The SCD40's ambient pressure compensation source (
dps310pressure) automatically benefits from the corrected value.Types of changes
Checklist / Checklijst:
If user-visible functionality or configuration variables are added/modified:
Summary by CodeRabbit
New Features
Updates