Skip to content

Commit 57f2ba2

Browse files
dpmworldclaude
andcommitted
Merge upstream/main into fix/nuos-operation-mode-cache-desync
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2 parents 19d7273 + 68b00db commit 57f2ba2

4 files changed

Lines changed: 40 additions & 7 deletions

File tree

‎ariston/ariston_api.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ def __request(
499499
params,
500500
)
501501
response = requests.request(
502-
method, path, params=params, json=body, headers=headers, timeout=30000
502+
method, path, params=params, json=body, headers=headers, timeout=30
503503
)
504504
if not response.ok:
505505
match response.status_code:
@@ -978,7 +978,11 @@ async def __async_request(
978978
params,
979979
)
980980

981-
async with aiohttp.ClientSession() as session:
981+
# Apply an explicit total timeout so a stalled request fails fast
982+
# instead of relying on aiohttp's 5 minute default. This mirrors the
983+
# 30 second timeout used by the synchronous `requests` path.
984+
timeout = aiohttp.ClientTimeout(total=30)
985+
async with aiohttp.ClientSession(timeout=timeout) as session:
982986
response = await session.request(
983987
method, path, params=params, json=body, headers=headers
984988
)

‎ariston/nuos_split_device.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ async def async_set_water_heater_boost(self, boost: bool):
146146
def _set_water_heater_temperature(self, temperature: float, reduced: float):
147147
"""Set water heater temperature"""
148148
self.api.set_nuos_temperature(self.gw, temperature, reduced, self.water_heater_target_temperature, self.water_heater_reduced_temperature)
149-
self.data[NuosSplitProperties.PROC_REQ_TEMP] = temperature
149+
# Mirror what the cloud now stores. The /temperatures endpoint sets
150+
# `comfortTemp` and `reducedTemp`; `procReqTemp` is a separate,
151+
# device-driven field. Writing to it here did not match what the
152+
# `water_heater_target_temperature` getter reads back, so the
153+
# optimistic cache update was invisible until the next refresh.
154+
self.data[NuosSplitProperties.COMFORT_TEMP] = temperature
150155
self.data[NuosSplitProperties.REDUCED_TEMP] = reduced
151156

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

169177
async def async_set_water_heater_temperature(self, temperature: float):

‎tests/test_ariston_api.py‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import unittest
55
from unittest.mock import AsyncMock, patch
66

7+
import aiohttp
8+
79
from ariston.ariston_api import AristonAPI, ConnectionException
810
from ariston.const import (
911
BsbOperativeMode,
@@ -91,6 +93,10 @@ def test_login_token_is_sent_with_followup_request(self):
9193

9294
self.assertEqual(devices, [{"gw": "gateway-1"}])
9395
login_call, devices_call = request.call_args_list
96+
# requests expects seconds: a regression to milliseconds (30000) would
97+
# let a hung connection block the caller for hours.
98+
self.assertEqual(login_call.kwargs["timeout"], 30)
99+
self.assertEqual(devices_call.kwargs["timeout"], 30)
94100
self.assertEqual(login_call.args[0], "POST")
95101
self.assertEqual(
96102
login_call.kwargs["json"],
@@ -123,9 +129,15 @@ async def connect_and_discover():
123129
with patch(
124130
"ariston.ariston_api.aiohttp.ClientSession",
125131
side_effect=[login_session, devices_session],
126-
):
132+
) as client_session:
127133
devices = asyncio.run(connect_and_discover())
128134

135+
# Every async request must set an explicit total timeout instead of
136+
# relying on aiohttp's 5 minute default.
137+
self.assertEqual(client_session.call_count, 2)
138+
for call in client_session.call_args_list:
139+
self.assertEqual(call.kwargs["timeout"], aiohttp.ClientTimeout(total=30))
140+
129141
self.assertEqual(devices, [{"gw": "gateway-1"}])
130142
self.assertEqual(
131143
login_session.calls[0][0],

‎tests/test_device_models.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ def test_nuos_split_properties_sync_async_and_missing_state_defaults(self):
299299

300300
device.set_water_heater_boost(False)
301301
device.set_water_heater_temperature(60)
302+
# The getter must reflect the requested target immediately, without
303+
# waiting for the next cloud refresh (regression: setter used to write
304+
# procReqTemp while the getter reads comfortTemp).
305+
self.assertEqual(device.water_heater_target_temperature, 60)
306+
self.assertEqual(device.data[NuosSplitProperties.COMFORT_TEMP], 60)
307+
self.assertNotIn(NuosSplitProperties.PROC_REQ_TEMP, device.data)
302308
device.set_water_heater_reduced_temperature(42)
303309
device.set_water_heater_operation_mode("FAST")
304310
# The getter must reflect the requested mode immediately (regression:
@@ -308,10 +314,10 @@ def test_nuos_split_properties_sync_async_and_missing_state_defaults(self):
308314
device.set_min_setpoint_temp(35)
309315
device.set_preheating(True)
310316
device.set_heating_rate(5)
311-
self.assertEqual(device.data[NuosSplitProperties.PROC_REQ_TEMP], 43)
317+
self.assertEqual(device.data[NuosSplitProperties.COMFORT_TEMP], 43)
312318
self.assertEqual(device.data[NuosSplitProperties.REDUCED_TEMP], 42)
313319
self.assertEqual(device.data[NuosSplitProperties.OP_MODE], NuosSplitOperativeMode.FAST.value)
314-
device.api.set_nuos_temperature.assert_called_with("gw-1", 43, 42, 55, 40)
320+
device.api.set_nuos_temperature.assert_called_with("gw-1", 43, 42, 60, 40)
315321
device.api.set_velis_plant_setting.assert_called()
316322

317323
device.api.async_set_nous_boost = AsyncMock()
@@ -322,6 +328,9 @@ def test_nuos_split_properties_sync_async_and_missing_state_defaults(self):
322328
async def set_values():
323329
await device.async_set_water_heater_boost(True)
324330
await device.async_set_water_heater_temperature(62)
331+
self.assertEqual(device.water_heater_target_temperature, 62)
332+
self.assertEqual(device.data[NuosSplitProperties.COMFORT_TEMP], 62)
333+
self.assertNotIn(NuosSplitProperties.PROC_REQ_TEMP, device.data)
325334
await device.async_set_water_heater_reduced_temperature(39)
326335
await device.async_set_water_heater_operation_mode("GREEN")
327336
await device.async_set_min_setpoint_temp(36)

0 commit comments

Comments
 (0)