Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ariston/nuos_split_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ async def async_set_water_heater_boost(self, boost: bool):
def _set_water_heater_temperature(self, temperature: float, reduced: float):
"""Set water heater temperature"""
self.api.set_nuos_temperature(self.gw, temperature, reduced, self.water_heater_target_temperature, self.water_heater_reduced_temperature)
self.data[NuosSplitProperties.PROC_REQ_TEMP] = temperature
# Mirror what the cloud now stores. The /temperatures endpoint sets
# `comfortTemp` and `reducedTemp`; `procReqTemp` is a separate,
# device-driven field. Writing to it here did not match what the
# `water_heater_target_temperature` getter reads back, so the
# optimistic cache update was invisible until the next refresh.
self.data[NuosSplitProperties.COMFORT_TEMP] = temperature
self.data[NuosSplitProperties.REDUCED_TEMP] = reduced

def set_water_heater_temperature(self, temperature: float):
Expand All @@ -163,7 +168,10 @@ async def _async_set_water_heater_temperature(
):
"""Async set water heater temperature"""
await self.api.async_set_nuos_temperature(self.gw, temperature, reduced, self.water_heater_target_temperature, self.water_heater_reduced_temperature)
self.data[NuosSplitProperties.PROC_REQ_TEMP] = temperature
# See note in `_set_water_heater_temperature`: the cloud /temperatures
# endpoint updates `comfortTemp` and `reducedTemp`, so the optimistic
# cache must mirror those fields, not `procReqTemp`.
self.data[NuosSplitProperties.COMFORT_TEMP] = temperature
self.data[NuosSplitProperties.REDUCED_TEMP] = reduced

async def async_set_water_heater_temperature(self, temperature: float):
Expand Down
13 changes: 11 additions & 2 deletions tests/test_device_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,21 @@ def test_nuos_split_properties_sync_async_and_missing_state_defaults(self):

device.set_water_heater_boost(False)
device.set_water_heater_temperature(60)
# The getter must reflect the requested target immediately, without
# waiting for the next cloud refresh (regression: setter used to write
# procReqTemp while the getter reads comfortTemp).
self.assertEqual(device.water_heater_target_temperature, 60)
self.assertEqual(device.data[NuosSplitProperties.COMFORT_TEMP], 60)
self.assertNotIn(NuosSplitProperties.PROC_REQ_TEMP, device.data)
device.set_water_heater_reduced_temperature(42)
device.set_water_heater_operation_mode("FAST")
device.set_min_setpoint_temp(35)
device.set_preheating(True)
device.set_heating_rate(5)
self.assertEqual(device.data[NuosSplitProperties.PROC_REQ_TEMP], 43)
self.assertEqual(device.data[NuosSplitProperties.COMFORT_TEMP], 43)
self.assertEqual(device.data[NuosSplitProperties.REDUCED_TEMP], 42)
self.assertEqual(device.data[NuosSplitProperties.MODE], NuosSplitOperativeMode.FAST.value)
device.api.set_nuos_temperature.assert_called_with("gw-1", 43, 42, 55, 40)
device.api.set_nuos_temperature.assert_called_with("gw-1", 43, 42, 60, 40)
device.api.set_velis_plant_setting.assert_called()

device.api.async_set_nous_boost = AsyncMock()
Expand All @@ -318,6 +324,9 @@ def test_nuos_split_properties_sync_async_and_missing_state_defaults(self):
async def set_values():
await device.async_set_water_heater_boost(True)
await device.async_set_water_heater_temperature(62)
self.assertEqual(device.water_heater_target_temperature, 62)
self.assertEqual(device.data[NuosSplitProperties.COMFORT_TEMP], 62)
self.assertNotIn(NuosSplitProperties.PROC_REQ_TEMP, device.data)
await device.async_set_water_heater_reduced_temperature(39)
await device.async_set_water_heater_operation_mode("GREEN")
await device.async_set_min_setpoint_temp(36)
Expand Down
Loading