python-izone 2.1.0__tar.gz → 2.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_izone-2.1.0 → python_izone-2.1.1}/PKG-INFO +1 -1
- python_izone-2.1.1/docs/release-notes/v2.1.1.md +13 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/pizone/controller.py +101 -35
- {python_izone-2.1.0 → python_izone-2.1.1}/pizone/v2.py +10 -11
- {python_izone-2.1.0 → python_izone-2.1.1}/pizone/version.py +2 -2
- {python_izone-2.1.0 → python_izone-2.1.1}/pizone/zone.py +16 -14
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/conftest.py +3 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_controller.py +30 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_zone.py +97 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/.gitattributes +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/.github/workflows/main.yml +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/.gitignore +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/.pre-commit-config.yaml +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/.python-version +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/.vscode/.ropeproject/config.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/.vscode/extensions.json +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/.vscode/launch.json +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/.vscode/settings.json +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/README.md +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/api_docs/AC-DOC-1401-11_iZoneEthernetInterface.pdf +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/api_docs/iPower_JSON_datastrings_Out.h +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/api_docs/iZone_JSON_datastrings.h +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/docs/release-notes/v1.3.10.md +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/docs/release-notes/v1.3.11.md +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/docs/release-notes/v1.3.12.md +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/docs/release-notes/v1.3.4.md +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/docs/release-notes/v1.3.5.md +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/docs/release-notes/v1.3.6.md +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/docs/release-notes/v1.3.7.md +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/docs/release-notes/v1.3.8.md +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/docs/release-notes/v1.3.9.md +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/docs/release-notes/v2.0.0.md +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/docs/release-notes/v2.0.1.md +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/docs/release-notes/v2.1.0.md +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/docs/v2-confirmation.md +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/licence.txt +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/pizone/__init__.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/pizone/const.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/pizone/discovery.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/pizone/exceptions.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/pizone/power.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/pizone/py.typed +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/pizone/types.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/pyproject.toml +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/scripts/check +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/scripts/coverage +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/scripts/izone_v1_probe.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/__init__.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/http_fakes.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/power_data.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/resources.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_control_zone.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_discovery.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_discovery_api.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_discovery_close_timeout.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_dump_state.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_hardware_controller.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_hardware_hosts.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_http.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_power.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_reconfiguration.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_v2.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_v2_confirmation.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_v2_fan_capability.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_v2_vendor_enums.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/test_v2_zone_validation.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/tests/v2_fixtures.py +0 -0
- {python_izone-2.1.0 → python_izone-2.1.1}/uv.lock +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Release notes — v2.1.1
|
|
2
|
+
|
|
3
|
+
**Compare range:** https://github.com/Swamp-Ig/pizone/compare/v2.1.0...v2.1.1
|
|
4
|
+
|
|
5
|
+
## Since v2.1.0
|
|
6
|
+
|
|
7
|
+
### V2 commands retry while the bridge is busy
|
|
8
|
+
|
|
9
|
+
- Some V2-only bridges reject commands with `{ERROR}` for a few seconds, seemingly while applying an earlier write ([home-assistant/core#194474](https://github.com/home-assistant/core/issues/194474)). V2 commands now retry every 0.5 s for up to 8 s, instead of once after 0.15 s.
|
|
10
|
+
- The sending lock is released between tries, so polls and other commands keep running while one command waits.
|
|
11
|
+
- A newer write to the same field (for example a zone's maximum airflow) replaces a write that is waiting to retry. The replaced call returns without sending again, and doesn't update the cache or run its later steps, so the newest value wins.
|
|
12
|
+
- A command the bridge keeps rejecting now takes up to 8 s to raise `ControllerCommandError`. The first FreeAir command on a bridge without V2 iSave support also waits out the window before falling back to V1.
|
|
13
|
+
- V1 commands are unchanged. No API changes.
|
|
@@ -109,6 +109,16 @@ class Controller:
|
|
|
109
109
|
REQUEST_TIMEOUT = 10
|
|
110
110
|
"""Time to wait for a response from the device, in seconds."""
|
|
111
111
|
|
|
112
|
+
V2_ERROR_RETRY_INTERVAL = 0.5
|
|
113
|
+
"""Gap between V2 command retries after ``{ERROR}``, in seconds."""
|
|
114
|
+
|
|
115
|
+
V2_ERROR_RETRY_WINDOW = 8.0
|
|
116
|
+
"""How long to keep retrying a V2 command that returns ``{ERROR}``.
|
|
117
|
+
|
|
118
|
+
Some bridges reject commands for a few seconds while applying an earlier
|
|
119
|
+
write.
|
|
120
|
+
"""
|
|
121
|
+
|
|
112
122
|
ZONE_CONFIRM_DELAY = 0.25
|
|
113
123
|
ZONE_CONFIRM_INTERVAL = 2.0
|
|
114
124
|
ZONE_CONFIRM_WINDOW = 30.0
|
|
@@ -195,6 +205,7 @@ class Controller:
|
|
|
195
205
|
self._on_address_changed: Callable[[ControllerEndpoint], None] | None = None
|
|
196
206
|
|
|
197
207
|
self._sending_lock = Lock()
|
|
208
|
+
self._v2_write_gens: dict[tuple[str, int | None], int] = {}
|
|
198
209
|
self._refresh_depth: int = 0
|
|
199
210
|
self._refresh_fail_ex: ConnectionError | None = None
|
|
200
211
|
self._zone_mode_confirmations: dict[int, _ZoneModeConfirmation] = {}
|
|
@@ -445,8 +456,11 @@ class Controller:
|
|
|
445
456
|
raise InvalidValueError("Free air system is not enabled")
|
|
446
457
|
await self._set_system_state("FreeAir", "FreeAir", "on")
|
|
447
458
|
else:
|
|
448
|
-
|
|
449
|
-
|
|
459
|
+
# A newer FreeAir write replaced ours; let it decide the mode.
|
|
460
|
+
if self.free_air and not await self._set_system_state(
|
|
461
|
+
"FreeAir", "FreeAir", "off"
|
|
462
|
+
):
|
|
463
|
+
return
|
|
450
464
|
await self._set_system_state("SysMode", "SystemMODE", value.value)
|
|
451
465
|
|
|
452
466
|
@property
|
|
@@ -1043,9 +1057,11 @@ class Controller:
|
|
|
1043
1057
|
command: str,
|
|
1044
1058
|
value: DictValue,
|
|
1045
1059
|
send: DictValue | None = None,
|
|
1046
|
-
) ->
|
|
1060
|
+
) -> bool:
|
|
1047
1061
|
"""Send a system command and update the local cache.
|
|
1048
1062
|
|
|
1063
|
+
Returns False if a newer write to the same field replaced it.
|
|
1064
|
+
|
|
1049
1065
|
Raises:
|
|
1050
1066
|
ConnectionError: If the HTTP request fails.
|
|
1051
1067
|
DeviceReconfigurationError: If the system was reconfigured.
|
|
@@ -1055,48 +1071,98 @@ class Controller:
|
|
|
1055
1071
|
if send is None:
|
|
1056
1072
|
send = value
|
|
1057
1073
|
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
v2_payload = v2_mod.system_command_to_v2(state, value, send)
|
|
1061
|
-
if state == "FreeAir" and self._isave_v2_unsupported:
|
|
1062
|
-
v2_payload = None
|
|
1063
|
-
if v2_payload is not None:
|
|
1064
|
-
try:
|
|
1065
|
-
await self._http_command_v2(v2_payload)
|
|
1066
|
-
except ControllerCommandError:
|
|
1067
|
-
if state != "FreeAir":
|
|
1068
|
-
raise
|
|
1069
|
-
self._isave_v2_unsupported = True
|
|
1070
|
-
await self._http_post(command, {command: send})
|
|
1071
|
-
else:
|
|
1072
|
-
await self._http_post(command, {command: send})
|
|
1073
|
-
self._system_settings[state] = value
|
|
1074
|
-
await self._fetch_system_v2_unlocked()
|
|
1075
|
-
else:
|
|
1074
|
+
if self._read_api != "v2":
|
|
1075
|
+
async with self._sending_lock, self._refresh_scope():
|
|
1076
1076
|
await self._http_post(command, {command: send})
|
|
1077
1077
|
self._system_settings[state] = value
|
|
1078
1078
|
await self._fetch_system()
|
|
1079
|
+
return True
|
|
1080
|
+
|
|
1081
|
+
async def apply() -> None:
|
|
1082
|
+
self._system_settings[state] = value
|
|
1083
|
+
await self._fetch_system_v2_unlocked()
|
|
1084
|
+
|
|
1085
|
+
v2_payload = v2_mod.system_command_to_v2(state, value, send)
|
|
1086
|
+
if state == "FreeAir" and self._isave_v2_unsupported:
|
|
1087
|
+
v2_payload = None
|
|
1088
|
+
if v2_payload is not None:
|
|
1089
|
+
try:
|
|
1090
|
+
return await self._command_v2_retrying(v2_payload, apply)
|
|
1091
|
+
except ControllerCommandError:
|
|
1092
|
+
if state != "FreeAir":
|
|
1093
|
+
raise
|
|
1094
|
+
self._isave_v2_unsupported = True
|
|
1095
|
+
async with self._sending_lock, self._refresh_scope():
|
|
1096
|
+
await self._http_post(command, {command: send})
|
|
1097
|
+
await apply()
|
|
1098
|
+
return True
|
|
1079
1099
|
|
|
1080
1100
|
async def _execute_zone_command(
|
|
1081
1101
|
self, command: str, data: dict[str, Any], zone_index: int
|
|
1082
|
-
) ->
|
|
1083
|
-
"""POST a zone command and confirm with a zone refresh.
|
|
1102
|
+
) -> bool:
|
|
1103
|
+
"""POST a zone command and confirm with a zone refresh.
|
|
1104
|
+
|
|
1105
|
+
Returns False if a newer write to the same field replaced it.
|
|
1106
|
+
"""
|
|
1084
1107
|
self._raise_if_reconfigured()
|
|
1085
|
-
|
|
1086
|
-
|
|
1108
|
+
if self._read_api != "v2":
|
|
1109
|
+
group = (zone_index // 4) * 4
|
|
1110
|
+
async with self._sending_lock, self._refresh_scope():
|
|
1111
|
+
await self._http_post(command, data)
|
|
1112
|
+
await self._fetch_zone_group(group)
|
|
1113
|
+
return True
|
|
1114
|
+
|
|
1115
|
+
payload = v2_mod.zone_command_to_v2(command, data, zone_index)
|
|
1116
|
+
|
|
1117
|
+
async def apply() -> None:
|
|
1118
|
+
if "ZoneMode" in payload:
|
|
1119
|
+
mode = v2_mod.zone_mode_from_wire(payload["ZoneMode"]["Mode"])
|
|
1120
|
+
self._track_zone_mode(zone_index, mode.value)
|
|
1121
|
+
else:
|
|
1122
|
+
await self._fetch_zone_v2_unlocked(zone_index)
|
|
1123
|
+
|
|
1124
|
+
return await self._command_v2_retrying(payload, apply)
|
|
1125
|
+
|
|
1126
|
+
async def _command_v2_retrying(
|
|
1127
|
+
self, payload: dict[str, Any], apply: Callable[[], Awaitable[None]]
|
|
1128
|
+
) -> bool:
|
|
1129
|
+
"""Send *payload* and run *apply*, retrying ``{ERROR}`` without the lock.
|
|
1130
|
+
|
|
1131
|
+
A newer write to the same field replaces one waiting to retry; the
|
|
1132
|
+
replaced call skips *apply* and returns False.
|
|
1133
|
+
|
|
1134
|
+
Raises:
|
|
1135
|
+
ConnectionError: If the HTTP request fails or the controller is closed.
|
|
1136
|
+
ControllerCommandError: If the bridge still rejects the command once
|
|
1137
|
+
``V2_ERROR_RETRY_WINDOW`` has passed.
|
|
1138
|
+
DeviceReconfigurationError: If the system was reconfigured.
|
|
1139
|
+
|
|
1140
|
+
"""
|
|
1141
|
+
key = v2_mod.command_key(payload)
|
|
1142
|
+
gen: int | None = None
|
|
1143
|
+
loop = asyncio.get_running_loop()
|
|
1144
|
+
deadline = loop.time() + self.V2_ERROR_RETRY_WINDOW
|
|
1145
|
+
while True:
|
|
1146
|
+
async with self._sending_lock, self._refresh_scope():
|
|
1147
|
+
if gen is None:
|
|
1148
|
+
gen = self._v2_write_gens.get(key, 0) + 1
|
|
1149
|
+
self._v2_write_gens[key] = gen
|
|
1150
|
+
elif self._v2_write_gens[key] != gen:
|
|
1151
|
+
_LOG.debug("Dropping %s, replaced by a newer write", payload)
|
|
1152
|
+
return False
|
|
1153
|
+
self._raise_if_reconfigured()
|
|
1087
1154
|
if self._closed:
|
|
1088
1155
|
raise ConnectionError("Controller is closed")
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1156
|
+
try:
|
|
1157
|
+
await self._http_command_v2(payload)
|
|
1158
|
+
except ControllerCommandError:
|
|
1159
|
+
if loop.time() >= deadline:
|
|
1160
|
+
raise
|
|
1161
|
+
_LOG.debug("Bridge rejected %s, retrying", payload)
|
|
1094
1162
|
else:
|
|
1095
|
-
await
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
await self._http_post(command, data)
|
|
1099
|
-
await self._fetch_zone_group(group)
|
|
1163
|
+
await apply()
|
|
1164
|
+
return True
|
|
1165
|
+
await asyncio.sleep(self.V2_ERROR_RETRY_INTERVAL)
|
|
1100
1166
|
|
|
1101
1167
|
async def _fetch_zone_v2_unlocked(self, index: int) -> None:
|
|
1102
1168
|
"""Refresh one zone via Type=2. Caller must hold ``_sending_lock``."""
|
|
@@ -449,6 +449,12 @@ def system_command_to_v2(state: str, value: Any, send: Any) -> dict[str, Any] |
|
|
|
449
449
|
return None
|
|
450
450
|
|
|
451
451
|
|
|
452
|
+
def command_key(payload: dict[str, Any]) -> tuple[str, int | None]:
|
|
453
|
+
"""Return the field an iZoneCommandV2 payload writes: (command, zone index)."""
|
|
454
|
+
((name, body),) = payload.items()
|
|
455
|
+
return name, body.get("Index") if isinstance(body, dict) else None
|
|
456
|
+
|
|
457
|
+
|
|
452
458
|
def zone_command_to_v2(
|
|
453
459
|
command: str, data: dict[str, Any], zone_index: int
|
|
454
460
|
) -> dict[str, Any]:
|
|
@@ -560,7 +566,10 @@ async def command_v2(
|
|
|
560
566
|
use_content_type: bool | None,
|
|
561
567
|
timeout: float = 10.0,
|
|
562
568
|
) -> tuple[str, bool | None]:
|
|
563
|
-
"""POST iZoneCommandV2; return (raw body text, content-type mode used).
|
|
569
|
+
"""POST iZoneCommandV2; return (raw body text, content-type mode used).
|
|
570
|
+
|
|
571
|
+
Sends once; the controller retries ``{ERROR}`` with its lock released.
|
|
572
|
+
"""
|
|
564
573
|
if use_content_type is not None:
|
|
565
574
|
body = await _post_once(
|
|
566
575
|
session,
|
|
@@ -570,16 +579,6 @@ async def command_v2(
|
|
|
570
579
|
use_content_type=use_content_type,
|
|
571
580
|
timeout=timeout,
|
|
572
581
|
)
|
|
573
|
-
if body.strip().startswith("{ERROR"):
|
|
574
|
-
await asyncio.sleep(V2_ERROR_BACKOFF)
|
|
575
|
-
body = await _post_once(
|
|
576
|
-
session,
|
|
577
|
-
host,
|
|
578
|
-
path="iZoneCommandV2",
|
|
579
|
-
payload=payload,
|
|
580
|
-
use_content_type=use_content_type,
|
|
581
|
-
timeout=timeout,
|
|
582
|
-
)
|
|
583
582
|
return body, use_content_type
|
|
584
583
|
|
|
585
584
|
for mode in (False, True):
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '2.1.
|
|
22
|
-
__version_tuple__ = version_tuple = (2, 1,
|
|
21
|
+
__version__ = version = '2.1.1'
|
|
22
|
+
__version_tuple__ = version_tuple = (2, 1, 1)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -205,8 +205,8 @@ class Zone:
|
|
|
205
205
|
if value < 0 or value > 100:
|
|
206
206
|
raise InvalidValueError(f"MinAir '{value}' is out of range")
|
|
207
207
|
|
|
208
|
-
await self._send_command("AirMinCommand", value)
|
|
209
|
-
|
|
208
|
+
if await self._send_command("AirMinCommand", value):
|
|
209
|
+
self._zone_data["MinAir"] = value
|
|
210
210
|
|
|
211
211
|
async def set_airflow_max(self, value: int) -> None:
|
|
212
212
|
"""Change the zone maximum airflow in 5% increments.
|
|
@@ -221,8 +221,8 @@ class Zone:
|
|
|
221
221
|
if value < 0 or value > 100:
|
|
222
222
|
raise InvalidValueError(f"MaxAir '{value}' is out of range")
|
|
223
223
|
|
|
224
|
-
await self._send_command("AirMaxCommand", value)
|
|
225
|
-
|
|
224
|
+
if await self._send_command("AirMaxCommand", value):
|
|
225
|
+
self._zone_data["MaxAir"] = value
|
|
226
226
|
|
|
227
227
|
async def set_temp_setpoint(self, value: float) -> None:
|
|
228
228
|
"""Change the zone temperature setpoint in degrees C.
|
|
@@ -243,9 +243,9 @@ class Zone:
|
|
|
243
243
|
if value < self._controller.temp_min or value > self._controller.temp_max:
|
|
244
244
|
raise InvalidValueError(f"SetPoint '{value}' is out of range")
|
|
245
245
|
|
|
246
|
-
await self._send_command("ZoneCommand", value)
|
|
247
|
-
|
|
248
|
-
|
|
246
|
+
if await self._send_command("ZoneCommand", value):
|
|
247
|
+
self._zone_data["Mode"] = "auto"
|
|
248
|
+
self._zone_data["SetPoint"] = value
|
|
249
249
|
|
|
250
250
|
async def set_mode(self, value: Zone.Mode) -> None:
|
|
251
251
|
"""Set the current zone mode.
|
|
@@ -261,14 +261,14 @@ class Zone:
|
|
|
261
261
|
# V2 can select AUTO without overwriting a newer wall-panel setpoint.
|
|
262
262
|
# V1 still needs the cached setpoint to select temperature control.
|
|
263
263
|
if self._controller._read_api == "v2": # noqa: SLF001
|
|
264
|
-
await self._send_command("ZoneCommand", value.value)
|
|
264
|
+
sent = await self._send_command("ZoneCommand", value.value)
|
|
265
265
|
else:
|
|
266
|
-
await self._send_command(
|
|
266
|
+
sent = await self._send_command(
|
|
267
267
|
"ZoneCommand", self._get_zone_state("SetPoint")
|
|
268
268
|
)
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
if sent:
|
|
270
|
+
self._zone_data["Mode"] = "auto"
|
|
271
|
+
elif await self._send_command("ZoneCommand", value.value):
|
|
272
272
|
self._zone_data["Mode"] = value.value
|
|
273
273
|
|
|
274
274
|
def _update_zone(self, zone_data: Zone.ZoneData) -> None:
|
|
@@ -316,14 +316,16 @@ class Zone:
|
|
|
316
316
|
except KeyError, ValueError:
|
|
317
317
|
return None
|
|
318
318
|
|
|
319
|
-
async def _send_command(self, command: str, data: str | float) ->
|
|
319
|
+
async def _send_command(self, command: str, data: str | float) -> bool:
|
|
320
320
|
"""Send a zone command via the parent controller.
|
|
321
321
|
|
|
322
|
+
Returns False if a newer write to the same field replaced it.
|
|
323
|
+
|
|
322
324
|
Raises:
|
|
323
325
|
ConnectionError: If the device cannot be reached or the response is invalid.
|
|
324
326
|
|
|
325
327
|
"""
|
|
326
328
|
send_data = {command: {"ZoneNo": str(self._index + 1), "Command": str(data)}}
|
|
327
|
-
await self._controller._execute_zone_command( # noqa: SLF001
|
|
329
|
+
return await self._controller._execute_zone_command( # noqa: SLF001
|
|
328
330
|
command, send_data, self._index
|
|
329
331
|
)
|
|
@@ -41,6 +41,9 @@ _V1_SYSTEM_COMMAND_FIELDS = {
|
|
|
41
41
|
class MockController(Controller):
|
|
42
42
|
"""Controller double backed by static response dictionaries."""
|
|
43
43
|
|
|
44
|
+
# Fail on the first {ERROR}; retry behaviour has its own tests.
|
|
45
|
+
V2_ERROR_RETRY_WINDOW = 0.0
|
|
46
|
+
|
|
44
47
|
def __init__(
|
|
45
48
|
self,
|
|
46
49
|
discovery_service: DiscoveryService,
|
|
@@ -1004,6 +1004,36 @@ async def test_v2_free_air_falls_back_and_stays_on_v1() -> None:
|
|
|
1004
1004
|
await svc.close()
|
|
1005
1005
|
|
|
1006
1006
|
|
|
1007
|
+
@pytest.mark.asyncio
|
|
1008
|
+
async def test_v2_set_mode_stops_when_free_air_off_is_replaced() -> None:
|
|
1009
|
+
"""A newer set_mode that replaces our FreeAir off also decides SysMode."""
|
|
1010
|
+
svc, controller = await _v2_free_air_controller()
|
|
1011
|
+
controller._system_settings["FreeAir"] = "on"
|
|
1012
|
+
controller.V2_ERROR_RETRY_INTERVAL = 0.1
|
|
1013
|
+
controller.V2_ERROR_RETRY_WINDOW = 1.0
|
|
1014
|
+
sent: list[dict[str, object]] = []
|
|
1015
|
+
|
|
1016
|
+
async def send(payload: dict[str, object]) -> str:
|
|
1017
|
+
sent.append(payload)
|
|
1018
|
+
if len(sent) == 1:
|
|
1019
|
+
raise ControllerCommandError("Server returned error state {ERROR}")
|
|
1020
|
+
return ""
|
|
1021
|
+
|
|
1022
|
+
controller._http_command_v2 = send # type: ignore[method-assign]
|
|
1023
|
+
|
|
1024
|
+
older = asyncio.create_task(controller.set_mode(Controller.Mode.COOL))
|
|
1025
|
+
await asyncio.sleep(0.05)
|
|
1026
|
+
await controller.set_mode(Controller.Mode.HEAT)
|
|
1027
|
+
await older
|
|
1028
|
+
|
|
1029
|
+
assert sent == [
|
|
1030
|
+
{"iSaveOn": 0},
|
|
1031
|
+
{"iSaveOn": 0},
|
|
1032
|
+
{"SysMode": v2_mod.mode_to_wire(Controller.Mode.HEAT)},
|
|
1033
|
+
]
|
|
1034
|
+
await svc.close()
|
|
1035
|
+
|
|
1036
|
+
|
|
1007
1037
|
@pytest.mark.asyncio
|
|
1008
1038
|
async def test_v2_other_commands_do_not_fall_back_on_command_error() -> None:
|
|
1009
1039
|
"""Only FreeAir's known-unreliable V2 command gets a V1 fallback."""
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Tests for zone property reads and command validation."""
|
|
2
2
|
|
|
3
|
+
import asyncio
|
|
3
4
|
from collections.abc import AsyncIterator, Awaitable, Callable
|
|
4
5
|
from copy import deepcopy
|
|
5
6
|
from typing import cast
|
|
@@ -361,3 +362,99 @@ async def test_zone_status_property_decoding(
|
|
|
361
362
|
zone._zone_data[key] = raw
|
|
362
363
|
|
|
363
364
|
assert getattr(zone, attr) == expected
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def _rejecting_send(
|
|
368
|
+
controller: MockController, rejections: int
|
|
369
|
+
) -> list[dict[str, object]]:
|
|
370
|
+
"""Make iZoneCommandV2 return {ERROR} for the first *rejections* sends."""
|
|
371
|
+
sent: list[dict[str, object]] = []
|
|
372
|
+
remaining = rejections
|
|
373
|
+
|
|
374
|
+
async def send(payload: dict[str, object]) -> str:
|
|
375
|
+
nonlocal remaining
|
|
376
|
+
sent.append(payload)
|
|
377
|
+
if remaining:
|
|
378
|
+
remaining -= 1
|
|
379
|
+
raise ControllerCommandError("Server returned error state {ERROR}")
|
|
380
|
+
return ""
|
|
381
|
+
|
|
382
|
+
controller._http_command_v2 = send # type: ignore[method-assign]
|
|
383
|
+
return sent
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
@pytest.fixture
|
|
387
|
+
def fast_retries(v2_controller: MockController) -> MockController:
|
|
388
|
+
v2_controller.V2_ERROR_RETRY_INTERVAL = 0.01
|
|
389
|
+
v2_controller.V2_ERROR_RETRY_WINDOW = 1.0
|
|
390
|
+
return v2_controller
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
@pytest.mark.asyncio
|
|
394
|
+
async def test_v2_command_retries_until_bridge_accepts(
|
|
395
|
+
fast_retries: MockController,
|
|
396
|
+
) -> None:
|
|
397
|
+
sent = _rejecting_send(fast_retries, rejections=2)
|
|
398
|
+
zone = fast_retries.zones[0]
|
|
399
|
+
|
|
400
|
+
await zone.set_airflow_max(40)
|
|
401
|
+
|
|
402
|
+
assert sent == [{"ZoneMaxAir": {"Index": 0, "MaxAir": 40}}] * 3
|
|
403
|
+
assert zone.airflow_max == 40
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
@pytest.mark.asyncio
|
|
407
|
+
async def test_v2_command_gives_up_after_retry_window(
|
|
408
|
+
fast_retries: MockController,
|
|
409
|
+
) -> None:
|
|
410
|
+
fast_retries.V2_ERROR_RETRY_WINDOW = 0.05
|
|
411
|
+
sent = _rejecting_send(fast_retries, rejections=1000)
|
|
412
|
+
zone = fast_retries.zones[0]
|
|
413
|
+
before = zone.airflow_max
|
|
414
|
+
|
|
415
|
+
with pytest.raises(ControllerCommandError):
|
|
416
|
+
await zone.set_airflow_max(40)
|
|
417
|
+
|
|
418
|
+
assert len(sent) > 1
|
|
419
|
+
assert zone.airflow_max == before
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
@pytest.mark.asyncio
|
|
423
|
+
async def test_v2_retry_releases_lock_for_other_writes(
|
|
424
|
+
fast_retries: MockController,
|
|
425
|
+
) -> None:
|
|
426
|
+
sent = _rejecting_send(fast_retries, rejections=1)
|
|
427
|
+
zone = fast_retries.zones[0]
|
|
428
|
+
fast_retries.V2_ERROR_RETRY_INTERVAL = 0.1
|
|
429
|
+
|
|
430
|
+
retrying = asyncio.create_task(zone.set_airflow_max(40))
|
|
431
|
+
await asyncio.sleep(0.05)
|
|
432
|
+
await zone.set_airflow_min(10)
|
|
433
|
+
await retrying
|
|
434
|
+
|
|
435
|
+
assert sent == [
|
|
436
|
+
{"ZoneMaxAir": {"Index": 0, "MaxAir": 40}},
|
|
437
|
+
{"ZoneMinAir": {"Index": 0, "MinAir": 10}},
|
|
438
|
+
{"ZoneMaxAir": {"Index": 0, "MaxAir": 40}},
|
|
439
|
+
]
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
@pytest.mark.asyncio
|
|
443
|
+
async def test_v2_newer_write_replaces_retrying_write(
|
|
444
|
+
fast_retries: MockController,
|
|
445
|
+
) -> None:
|
|
446
|
+
sent = _rejecting_send(fast_retries, rejections=1)
|
|
447
|
+
zone = fast_retries.zones[0]
|
|
448
|
+
fast_retries.V2_ERROR_RETRY_INTERVAL = 0.1
|
|
449
|
+
|
|
450
|
+
retrying = asyncio.create_task(zone.set_airflow_max(40))
|
|
451
|
+
await asyncio.sleep(0.05)
|
|
452
|
+
await zone.set_airflow_max(45)
|
|
453
|
+
await retrying
|
|
454
|
+
|
|
455
|
+
# The replaced write is not sent again and does not overwrite the cache.
|
|
456
|
+
assert sent == [
|
|
457
|
+
{"ZoneMaxAir": {"Index": 0, "MaxAir": 40}},
|
|
458
|
+
{"ZoneMaxAir": {"Index": 0, "MaxAir": 45}},
|
|
459
|
+
]
|
|
460
|
+
assert zone.airflow_max == 45
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_izone-2.1.0 → python_izone-2.1.1}/api_docs/AC-DOC-1401-11_iZoneEthernetInterface.pdf
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|