Skip to content

Commit 39a970a

Browse files
authored
Merge pull request #40 from eman/fix/temperature-conversion-formula
Fix: Correct temperature conversion formula for 8 sensor fields
2 parents 4ec2ddf + e6d97cd commit 39a970a

5 files changed

Lines changed: 68 additions & 40 deletions

File tree

CHANGELOG.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,36 @@
22
Changelog
33
=========
44

5+
Version 6.0.5 (2025-11-21)
6+
==========================
7+
8+
Fixed
9+
-----
10+
11+
- **CRITICAL Temperature Conversion Bug**: Corrected temperature conversion formula for 8 sensor fields that were displaying values ~100°F higher than expected. The v6.0.4 change incorrectly used division by 5 (pentacelsius) instead of division by 10 (decicelsius) for these fields:
12+
13+
- ``tank_upper_temperature`` - Water tank upper sensor
14+
- ``tank_lower_temperature`` - Water tank lower sensor
15+
- ``discharge_temperature`` - Compressor discharge temperature (refrigerant)
16+
- ``suction_temperature`` - Compressor suction temperature (refrigerant)
17+
- ``evaporator_temperature`` - Evaporator coil temperature (refrigerant)
18+
- ``ambient_temperature`` - Ambient air temperature at heat pump
19+
- ``target_super_heat`` - Target superheat setpoint
20+
- ``current_super_heat`` - Measured superheat value
21+
22+
**Impact**: These fields now correctly display temperatures in expected ranges:
23+
24+
- Tank temperatures: ~120°F (close to DHW temperature, not ~220°F)
25+
- Discharge temperature: 120-180°F (not 220-280°F)
26+
- Suction, evaporator, ambient: Now showing physically realistic values
27+
28+
**Technical details**: Changed from ``PentaCelsiusToF`` (÷5) back to ``DeciCelsiusToF`` (÷10). The correct formula is ``(raw_value / 10.0) * 9/5 + 32``.
29+
30+
Changed
31+
-------
32+
33+
- **Documentation**: Updated ``data_conversions.rst`` and ``device_status.rst`` to reflect correct ``DeciCelsiusToF`` conversion for refrigerant circuit and tank temperature sensors
34+
535
Version 6.0.4 (2025-11-21)
636
==========================
737

docs/protocol/data_conversions.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ The device uses several encoding schemes to minimize transmission overhead:
2424
- Purpose: Converts raw values, which are in half-degrees Celsius, to Fahrenheit.
2525
- Example: Raw 122 -> (122 / 2) * 9/5 + 32 = 141.8°F
2626

27-
2. **Scaled Celsius to Fahrenheit** (PentaCelsiusToF)
28-
- Applied to refrigerant and evaporator temperatures.
29-
- Formula: ``displayed_value = (raw_value / 5.0) * 9/5 + 32``
30-
- Purpose: Converts raw values, which are scaled by a factor of 5, to Fahrenheit.
31-
- Example: Raw 250 -> (250 / 5) * 9/5 + 32 = 122°F
27+
2. **Decicelsius to Fahrenheit** (DeciCelsiusToF)
28+
- Applied to refrigerant circuit and tank temperature sensors.
29+
- Formula: ``displayed_value = (raw_value / 10.0) * 9/5 + 32``
30+
- Purpose: Converts raw values, which are in tenths of degrees Celsius, to Fahrenheit.
31+
- Example: Raw 489 -> (489 / 10) * 9/5 + 32 = 120.0°F
3232

3333
3. **Tenths Encoding** (div_10)
3434
- Applied to decimal precision values
@@ -97,11 +97,11 @@ Tank Temperature Sensors
9797
- Display Unit
9898
- Description
9999
* - ``tankUpperTemperature``
100-
- PentaCelsiusToF
100+
- DeciCelsiusToF
101101
- °F
102102
- **Upper tank sensor temperature**. Indicates stratification - hot water at top for quick delivery. Typically hottest point in tank.
103103
* - ``tankLowerTemperature``
104-
- PentaCelsiusToF
104+
- DeciCelsiusToF
105105
- °F
106106
- **Lower tank sensor temperature**. Indicates bulk tank temperature and heating progress. Typically cooler than upper sensor.
107107

@@ -121,27 +121,27 @@ These temperatures monitor the heat pump refrigerant circuit health and performa
121121
- Display Unit
122122
- Description
123123
* - ``dischargeTemperature``
124-
- PentaCelsiusToF
124+
- DeciCelsiusToF
125125
- °F
126126
- **Compressor discharge temperature**. Temperature of refrigerant exiting the compressor. Typically 120-180°F. High values indicate high system pressure; low values indicate efficiency issues.
127127
* - ``suctionTemperature``
128-
- PentaCelsiusToF
128+
- DeciCelsiusToF
129129
- °F
130130
- **Compressor suction temperature**. Temperature of refrigerant entering the compressor. Typically 40-60°F. Affects superheat calculation.
131131
* - ``evaporatorTemperature``
132-
- PentaCelsiusToF
132+
- DeciCelsiusToF
133133
- °F
134134
- **Evaporator coil temperature**. Where heat is extracted from ambient air. Typically 20-50°F. Lower outdoor air temperature reduces evaporator efficiency.
135135
* - ``ambientTemperature``
136-
- PentaCelsiusToF
136+
- DeciCelsiusToF
137137
- °F
138138
- **Ambient air temperature** measured at heat pump inlet. Directly affects system performance. At freezing (32°F), heat pump efficiency drops significantly.
139139
* - ``targetSuperHeat``
140-
- PentaCelsiusToF
140+
- DeciCelsiusToF
141141
- °F
142142
- **Target superheat setpoint**. Desired temperature difference between suction and evaporator ensuring complete refrigerant vaporization. Typically 10-20°F.
143143
* - ``currentSuperHeat``
144-
- PentaCelsiusToF
144+
- DeciCelsiusToF
145145
- °F
146146
- **Measured superheat value**. Actual temperature difference. Deviation from target indicates EEV (Electronic Expansion Valve) control issues.
147147

docs/protocol/device_status.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,37 +122,37 @@ This document lists the fields found in the ``status`` object of device status m
122122
- integer
123123
- °F
124124
- Temperature of the upper part of the tank.
125-
- PentaCelsiusToF
125+
- DeciCelsiusToF
126126
* - ``tankLowerTemperature``
127127
- integer
128128
- °F
129129
- Temperature of the lower part of the tank.
130-
- PentaCelsiusToF
130+
- DeciCelsiusToF
131131
* - ``dischargeTemperature``
132132
- integer
133133
- °F
134134
- Compressor discharge temperature - temperature of refrigerant leaving the compressor.
135-
- PentaCelsiusToF
135+
- DeciCelsiusToF
136136
* - ``suctionTemperature``
137137
- integer
138138
- °F
139139
- Compressor suction temperature - temperature of refrigerant entering the compressor.
140-
- PentaCelsiusToF
140+
- DeciCelsiusToF
141141
* - ``evaporatorTemperature``
142142
- integer
143143
- °F
144144
- Evaporator temperature - temperature where heat is absorbed from ambient air.
145-
- PentaCelsiusToF
145+
- DeciCelsiusToF
146146
* - ``ambientTemperature``
147147
- integer
148148
- °F
149149
- Ambient air temperature measured at the heat pump air intake.
150-
- PentaCelsiusToF
150+
- DeciCelsiusToF
151151
* - ``targetSuperHeat``
152152
- integer
153153
- °F
154154
- Target superheat value - the desired temperature difference ensuring complete refrigerant vaporization.
155-
- PentaCelsiusToF
155+
- DeciCelsiusToF
156156
* - ``compUse``
157157
- bool
158158
- None
@@ -307,7 +307,7 @@ This document lists the fields found in the ``status`` object of device status m
307307
- integer
308308
- °F
309309
- Current superheat value - actual temperature difference between suction and evaporator temperatures.
310-
- PentaCelsiusToF
310+
- DeciCelsiusToF
311311
* - ``heatUpperUse``
312312
- bool
313313
- None

src/nwp500/models.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ def _half_celsius_to_fahrenheit(v: Any) -> float:
4141
return float(v)
4242

4343

44-
def _penta_celsius_to_fahrenheit(v: Any) -> float:
45-
"""Convert value scaled by 5 to Fahrenheit."""
44+
def _deci_celsius_to_fahrenheit(v: Any) -> float:
45+
"""Convert decicelsius (tenths of Celsius) to Fahrenheit."""
4646
if isinstance(v, (int, float)):
47-
celsius = float(v) / 5.0
47+
celsius = float(v) / 10.0
4848
return (celsius * 9 / 5) + 32
4949
return float(v)
5050

@@ -53,9 +53,7 @@ def _penta_celsius_to_fahrenheit(v: Any) -> float:
5353
DeviceBool = Annotated[bool, BeforeValidator(_device_bool_validator)]
5454
Div10 = Annotated[float, BeforeValidator(_div_10_validator)]
5555
HalfCelsiusToF = Annotated[float, BeforeValidator(_half_celsius_to_fahrenheit)]
56-
PentaCelsiusToF = Annotated[
57-
float, BeforeValidator(_penta_celsius_to_fahrenheit)
58-
]
56+
DeciCelsiusToF = Annotated[float, BeforeValidator(_deci_celsius_to_fahrenheit)]
5957

6058

6159
class NavienBaseModel(BaseModel):
@@ -289,15 +287,15 @@ class DeviceStatus(NavienBaseModel):
289287
he_lower_off_diff_temp_setting: Div10
290288
recirc_dhw_flow_rate: Div10
291289

292-
# Temperature fields with 1/5 scaling
293-
tank_upper_temperature: PentaCelsiusToF
294-
tank_lower_temperature: PentaCelsiusToF
295-
discharge_temperature: PentaCelsiusToF
296-
suction_temperature: PentaCelsiusToF
297-
evaporator_temperature: PentaCelsiusToF
298-
ambient_temperature: PentaCelsiusToF
299-
target_super_heat: PentaCelsiusToF
300-
current_super_heat: PentaCelsiusToF
290+
# Temperature fields with decicelsius (÷10) to Fahrenheit conversion
291+
tank_upper_temperature: DeciCelsiusToF
292+
tank_lower_temperature: DeciCelsiusToF
293+
discharge_temperature: DeciCelsiusToF
294+
suction_temperature: DeciCelsiusToF
295+
evaporator_temperature: DeciCelsiusToF
296+
ambient_temperature: DeciCelsiusToF
297+
target_super_heat: DeciCelsiusToF
298+
current_super_heat: DeciCelsiusToF
301299

302300
# Enum fields
303301
operation_mode: CurrentOperationMode = Field(

tests/test_models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ def test_device_status_half_celsius_to_fahrenheit(default_status_data):
118118
assert status.dhw_temperature == pytest.approx(141.8)
119119

120120

121-
def test_device_status_penta_celsius_to_fahrenheit(default_status_data):
122-
"""Test PentaCelsiusToF conversion."""
123-
default_status_data["tankUpperTemperature"] = 250
121+
def test_device_status_deci_celsius_to_fahrenheit(default_status_data):
122+
"""Test DeciCelsiusToF conversion."""
123+
default_status_data["tankUpperTemperature"] = 489
124124
status = DeviceStatus.model_validate(default_status_data)
125-
assert status.tank_upper_temperature == pytest.approx(122.0)
125+
assert status.tank_upper_temperature == pytest.approx(120.0, abs=0.1)
126126

127127

128128
def test_device_status_div10(default_status_data):

0 commit comments

Comments
 (0)