Skip to content
Closed
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
8 changes: 6 additions & 2 deletions ariston/ariston_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,15 @@ def set_lydos_mode(self, gw_id: str, value: LydosPlantMode) -> None:
},
)

def set_nuos_mode(self, gw_id: str, value: NuosSplitOperativeMode) -> None:
def set_nuos_mode(
self, gw_id: str, value: NuosSplitOperativeMode, old_value: int
) -> None:
"""Set Velis Nuos mode"""
self._post(
f"{self.__api_url}{ARISTON_VELIS}/{PlantData.Slp.value}/{gw_id}/operativeMode",
{
"new": value.value,
"old": old_value,
},
)

Expand Down Expand Up @@ -743,13 +746,14 @@ async def async_set_lydos_mode(self, gw_id: str, value: LydosPlantMode) -> None:
)

async def async_set_nuos_mode(
self, gw_id: str, value: NuosSplitOperativeMode
self, gw_id: str, value: NuosSplitOperativeMode, old_value: int
) -> None:
"""Async set Velis Nuos mode"""
await self._async_post(
f"{self.__api_url}{ARISTON_VELIS}/{PlantData.Slp.value}/{gw_id}/operativeMode",
{
"new": value.value,
"old": old_value,
},
)

Expand Down
12 changes: 8 additions & 4 deletions ariston/nuos_split_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,21 @@ async def async_set_water_heater_reduced_temperature(self, temperature: float):

def set_water_heater_operation_mode(self, operation_mode: str):
"""Set water heater operation mode"""
self.api.set_nuos_mode(self.gw, NuosSplitOperativeMode[operation_mode])
self.data[NuosSplitProperties.MODE] = NuosSplitOperativeMode[
old_value = self.water_heater_mode_value if self.water_heater_mode_value is not None else 1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please avoid hardcoding old=1 when the cached mode is unknown. Nuos value 1 is COMFORT, so a newly created device or empty cache sends COMFORT as the previous value regardless of the device's actual mode; since this endpoint's old field is the previous mode, the write can be rejected. Fetch the current state before both writes or handle an unknown previous value explicitly.

self.api.set_nuos_mode(
self.gw, NuosSplitOperativeMode[operation_mode], old_value
)
self.data[NuosSplitProperties.OP_MODE] = NuosSplitOperativeMode[
operation_mode
].value

async def async_set_water_heater_operation_mode(self, operation_mode: str):
"""Async set water heater operation mode"""
old_value = self.water_heater_mode_value if self.water_heater_mode_value is not None else 1
await self.api.async_set_nuos_mode(
self.gw, NuosSplitOperativeMode[operation_mode]
self.gw, NuosSplitOperativeMode[operation_mode], old_value
)
self.data[NuosSplitProperties.MODE] = NuosSplitOperativeMode[
self.data[NuosSplitProperties.OP_MODE] = NuosSplitOperativeMode[

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please update test_nuos_split_properties_sync_async_and_missing_state_defaults with this OP_MODE cache change. Its fixture omits MODE but the sync and async checks still index that key after setters, so this change makes the existing suite raise KeyError and leaves the getter-backed cache unverified. Assert OP_MODE/water_heater_mode_value and verify the previous mode passed to each API call.

operation_mode
].value

Expand Down
Loading