Fix: Correct temperature conversion formula for 8 sensor fields#40
Merged
Conversation
The v6.0.4 change incorrectly converted these fields from DeciCelsiusToF (÷10) to PentaCelsiusToF (÷5), causing temperatures to display ~100°F higher than expected. Fixed fields: - tank_upper_temperature, tank_lower_temperature (water sensors) - discharge_temperature, suction_temperature, evaporator_temperature, ambient_temperature (refrigerant sensors) - target_super_heat, current_super_heat (superheat values) Root cause: These fields use decicelsius encoding (tenths of a degree Celsius), not pentacelsius (fifths). The correct conversion formula is: (raw_value / 10.0) * 9/5 + 32 Impact: Temperature fields now display correct values: - Tank temps: ~120°F (was ~220°F) - Discharge temp: 120-180°F (was 220-280°F) - All values now in physically realistic ranges Changes: - Renamed PentaCelsiusToF -> DeciCelsiusToF with correct formula - Updated 8 field type annotations to use DeciCelsiusToF - Updated test to verify conversion (raw 489 -> 120°F) - Updated documentation in data_conversions.rst and device_status.rst - Updated CHANGELOG.rst with v6.0.5 entry
Contributor
There was a problem hiding this comment.
Pull request overview
This PR corrects a critical temperature conversion bug introduced in v6.0.4 where 8 sensor fields were incorrectly converted using pentacelsius (÷5) instead of decicelsius (÷10), causing temperatures to display approximately 100°F higher than expected.
Key Changes:
- Renamed
PentaCelsiusToFtoDeciCelsiusToFwith corrected formula (÷10 instead of ÷5) - Updated 8 temperature field type annotations to use
DeciCelsiusToF(tank sensors, refrigerant circuit sensors, superheat values) - Updated test case to verify correct conversion (raw 489 → 120°F instead of 250 → 122°F)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/nwp500/models.py |
Renamed converter function and type annotation, updated formula from ÷5 to ÷10, changed 8 field annotations |
tests/test_models.py |
Updated test function name and test data to verify decicelsius conversion (489 → 120°F) |
docs/protocol/device_status.rst |
Updated conversion type references from PentaCelsiusToF to DeciCelsiusToF for 8 affected fields |
docs/protocol/data_conversions.rst |
Updated conversion documentation with correct formula, example, and field descriptions |
CHANGELOG.rst |
Added v6.0.5 release notes documenting the critical bug fix and its impact |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The v6.0.4 change incorrectly converted these fields from DeciCelsiusToF (÷10) to PentaCelsiusToF (÷5), causing temperatures to display ~100°F higher than expected.
Fixed fields:
Root cause: These fields use decicelsius encoding (tenths of a degree Celsius), not pentacelsius (fifths). The correct conversion formula is:
(raw_value / 10.0) * 9/5 + 32
Impact: Temperature fields now display correct values:
Changes: