Skip to content

Fix: Correct temperature conversion formula for 8 sensor fields#40

Merged
eman merged 1 commit intomainfrom
fix/temperature-conversion-formula
Nov 21, 2025
Merged

Fix: Correct temperature conversion formula for 8 sensor fields#40
eman merged 1 commit intomainfrom
fix/temperature-conversion-formula

Conversation

@eman
Copy link
Copy Markdown
Owner

@eman eman commented Nov 21, 2025

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

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
@eman eman requested a review from Copilot November 21, 2025 23:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 PentaCelsiusToF to DeciCelsiusToF with 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

@eman eman merged commit 39a970a into main Nov 21, 2025
10 checks passed
@eman eman deleted the fix/temperature-conversion-formula branch November 21, 2025 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants