python-izone 2.0.1__tar.gz → 2.1.0__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.0.1 → python_izone-2.1.0}/PKG-INFO +1 -1
- python_izone-2.1.0/docs/release-notes/v2.1.0.md +11 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/pizone/__init__.py +2 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/pizone/controller.py +89 -11
- {python_izone-2.0.1 → python_izone-2.1.0}/pizone/exceptions.py +35 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/pizone/version.py +2 -2
- {python_izone-2.0.1 → python_izone-2.1.0}/pizone/zone.py +10 -1
- python_izone-2.1.0/tests/test_reconfiguration.py +259 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/.gitattributes +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/.github/workflows/main.yml +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/.gitignore +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/.pre-commit-config.yaml +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/.python-version +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/.vscode/.ropeproject/config.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/.vscode/extensions.json +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/.vscode/launch.json +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/.vscode/settings.json +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/README.md +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/api_docs/AC-DOC-1401-11_iZoneEthernetInterface.pdf +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/api_docs/iPower_JSON_datastrings_Out.h +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/api_docs/iZone_JSON_datastrings.h +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/docs/release-notes/v1.3.10.md +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/docs/release-notes/v1.3.11.md +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/docs/release-notes/v1.3.12.md +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/docs/release-notes/v1.3.4.md +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/docs/release-notes/v1.3.5.md +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/docs/release-notes/v1.3.6.md +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/docs/release-notes/v1.3.7.md +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/docs/release-notes/v1.3.8.md +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/docs/release-notes/v1.3.9.md +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/docs/release-notes/v2.0.0.md +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/docs/release-notes/v2.0.1.md +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/docs/v2-confirmation.md +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/licence.txt +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/pizone/const.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/pizone/discovery.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/pizone/power.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/pizone/py.typed +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/pizone/types.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/pizone/v2.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/pyproject.toml +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/scripts/check +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/scripts/coverage +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/scripts/izone_v1_probe.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/__init__.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/conftest.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/http_fakes.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/power_data.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/resources.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_control_zone.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_controller.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_discovery.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_discovery_api.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_discovery_close_timeout.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_dump_state.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_hardware_controller.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_hardware_hosts.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_http.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_power.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_v2.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_v2_confirmation.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_v2_fan_capability.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_v2_vendor_enums.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_v2_zone_validation.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/test_zone.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/tests/v2_fixtures.py +0 -0
- {python_izone-2.0.1 → python_izone-2.1.0}/uv.lock +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Release notes — v2.1.0
|
|
2
|
+
|
|
3
|
+
**Compare range:** https://github.com/Swamp-Ig/pizone/compare/v2.0.1...v2.1.0
|
|
4
|
+
|
|
5
|
+
## Since v2.0.1
|
|
6
|
+
|
|
7
|
+
### Reprogrammed systems are detected
|
|
8
|
+
|
|
9
|
+
- If an installer reprograms the system (zone count, zone types or fan setup), refreshes and commands now raise the new `DeviceReconfigurationError` instead of carrying on with the old layout. Its `changes` attribute lists what changed.
|
|
10
|
+
- To recover, close the controller and create a new one with `DiscoveryService.create_controller()`.
|
|
11
|
+
- `DeviceReconfigurationError` is not a `ConnectionError`, so existing outage handling won't catch it. Callers should catch it and recreate the controller.
|
|
@@ -35,6 +35,7 @@ from .discovery import DiscoveryService, create_discovery
|
|
|
35
35
|
from .exceptions import (
|
|
36
36
|
ControllerAlreadyClaimedError,
|
|
37
37
|
ControllerCommandError,
|
|
38
|
+
DeviceReconfigurationError,
|
|
38
39
|
EndpointVerifyError,
|
|
39
40
|
InvalidValueError,
|
|
40
41
|
ResponseDecodeError,
|
|
@@ -77,6 +78,7 @@ __all__ = [
|
|
|
77
78
|
"ControllerAlreadyClaimedError",
|
|
78
79
|
"ControllerCommandError",
|
|
79
80
|
"ControllerEndpoint",
|
|
81
|
+
"DeviceReconfigurationError",
|
|
80
82
|
"DiscoveredEndpoints",
|
|
81
83
|
"DiscoveryService",
|
|
82
84
|
"EndpointVerifyError",
|
|
@@ -15,7 +15,12 @@ from typing import TYPE_CHECKING, Any, Literal, Self, cast
|
|
|
15
15
|
import aiohttp
|
|
16
16
|
|
|
17
17
|
from . import power as power_mod, v2 as v2_mod
|
|
18
|
-
from .exceptions import
|
|
18
|
+
from .exceptions import (
|
|
19
|
+
ControllerCommandError,
|
|
20
|
+
DeviceReconfigurationError,
|
|
21
|
+
InvalidValueError,
|
|
22
|
+
ResponseDecodeError,
|
|
23
|
+
)
|
|
19
24
|
from .power import Power
|
|
20
25
|
from .types import ControllerEndpoint, ControllerProbe
|
|
21
26
|
from .zone import Zone
|
|
@@ -43,8 +48,17 @@ def _refresh_api(
|
|
|
43
48
|
|
|
44
49
|
@wraps(method)
|
|
45
50
|
async def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
self._raise_if_reconfigured()
|
|
52
|
+
try:
|
|
53
|
+
async with self._refresh_scope():
|
|
54
|
+
result = await method(self, *args, **kwargs)
|
|
55
|
+
except Exception as ex:
|
|
56
|
+
# A read in this refresh saw the reconfigure; that outranks its errors.
|
|
57
|
+
if self._reconfigured is not None:
|
|
58
|
+
raise DeviceReconfigurationError(dict(self._reconfigured)) from ex
|
|
59
|
+
raise
|
|
60
|
+
self._raise_if_reconfigured()
|
|
61
|
+
return result
|
|
48
62
|
|
|
49
63
|
return wrapper
|
|
50
64
|
|
|
@@ -175,6 +189,9 @@ class Controller:
|
|
|
175
189
|
self._izone_ok: bool = True
|
|
176
190
|
self._fault_fields: tuple[str, ...] = ()
|
|
177
191
|
self._last_fault: dict[str, Any] | None = None
|
|
192
|
+
# System fields the zones and fan modes were built from at connect.
|
|
193
|
+
self._built_from: dict[str, Any] | None = None
|
|
194
|
+
self._reconfigured: dict[str, tuple[Any, Any]] | None = None
|
|
178
195
|
self._on_address_changed: Callable[[ControllerEndpoint], None] | None = None
|
|
179
196
|
|
|
180
197
|
self._sending_lock = Lock()
|
|
@@ -260,19 +277,23 @@ class Controller:
|
|
|
260
277
|
if settings is None:
|
|
261
278
|
raise ConnectionError("SystemSettings device ID mismatch")
|
|
262
279
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
)
|
|
268
|
-
else:
|
|
269
|
-
self.fan_modes = Controller._VALID_FAN_MODES["disabled"]
|
|
280
|
+
self.fan_modes = Controller._VALID_FAN_MODES.get(
|
|
281
|
+
self._fan_auto(self._system_settings),
|
|
282
|
+
Controller._VALID_FAN_MODES["unknown"],
|
|
283
|
+
)
|
|
270
284
|
|
|
271
285
|
zone_count = int(settings["NoOfZones"])
|
|
272
286
|
self.zones = [Zone(self, i) for i in range(zone_count)]
|
|
273
287
|
|
|
274
288
|
await self._fetch_zones()
|
|
275
289
|
|
|
290
|
+
self._built_from = {
|
|
291
|
+
"NoOfZones": zone_count,
|
|
292
|
+
"NoOfConst": settings.get("NoOfConst"),
|
|
293
|
+
"SysType": settings.get("SysType"),
|
|
294
|
+
"FanAuto": self._fan_auto(self._system_settings),
|
|
295
|
+
}
|
|
296
|
+
|
|
276
297
|
await self._probe_power()
|
|
277
298
|
|
|
278
299
|
async def _probe_power(self) -> None:
|
|
@@ -347,6 +368,7 @@ class Controller:
|
|
|
347
368
|
"fan_modes": [fan.value for fan in self.fan_modes],
|
|
348
369
|
"system_settings": dict(self._system_settings),
|
|
349
370
|
"last_fault": self._last_fault,
|
|
371
|
+
"reconfigured": self._reconfigured,
|
|
350
372
|
"zones": [zone.dump_state() for zone in self.zones],
|
|
351
373
|
"power": self._power.dump_state() if self._power is not None else None,
|
|
352
374
|
}
|
|
@@ -849,6 +871,7 @@ class Controller:
|
|
|
849
871
|
"""System + zones [+ power] fetch (no refresh scope)."""
|
|
850
872
|
if self._read_api == "v2":
|
|
851
873
|
await self._fetch_system()
|
|
874
|
+
self._raise_if_reconfigured()
|
|
852
875
|
await self._fetch_zones()
|
|
853
876
|
await self._fetch_power()
|
|
854
877
|
return
|
|
@@ -895,8 +918,56 @@ class Controller:
|
|
|
895
918
|
|
|
896
919
|
self._system_settings = values
|
|
897
920
|
self._set_izone_ok(True)
|
|
921
|
+
if not faults and self._built_from is not None:
|
|
922
|
+
self._check_reconfigured(values)
|
|
898
923
|
return values
|
|
899
924
|
|
|
925
|
+
@staticmethod
|
|
926
|
+
def _fan_auto(values: ControllerData) -> str:
|
|
927
|
+
"""Return FanAuto as the fan modes read it; absent means disabled."""
|
|
928
|
+
if not values:
|
|
929
|
+
return "disabled"
|
|
930
|
+
return str(values.get("FanAuto", "disabled"))
|
|
931
|
+
|
|
932
|
+
def _check_reconfigured(self, values: ControllerData) -> None:
|
|
933
|
+
"""Latch if a clean read no longer matches what was built at connect."""
|
|
934
|
+
built = cast(dict[str, Any], self._built_from)
|
|
935
|
+
if (
|
|
936
|
+
int(values["NoOfZones"]) == built["NoOfZones"]
|
|
937
|
+
and values.get("NoOfConst") == built["NoOfConst"]
|
|
938
|
+
and values.get("SysType") == built["SysType"]
|
|
939
|
+
and self._fan_auto(values) == built["FanAuto"]
|
|
940
|
+
):
|
|
941
|
+
return
|
|
942
|
+
current = {
|
|
943
|
+
"NoOfZones": int(values["NoOfZones"]),
|
|
944
|
+
"NoOfConst": values.get("NoOfConst"),
|
|
945
|
+
"SysType": values.get("SysType"),
|
|
946
|
+
"FanAuto": self._fan_auto(values),
|
|
947
|
+
}
|
|
948
|
+
self._note_reconfigured(
|
|
949
|
+
{
|
|
950
|
+
field: (old, current[field])
|
|
951
|
+
for field, old in built.items()
|
|
952
|
+
if current[field] != old
|
|
953
|
+
}
|
|
954
|
+
)
|
|
955
|
+
|
|
956
|
+
def _note_reconfigured(self, changes: dict[str, tuple[Any, Any]]) -> None:
|
|
957
|
+
"""Latch the reconfigured state; it only clears with a new controller."""
|
|
958
|
+
if self._reconfigured is None:
|
|
959
|
+
self._reconfigured = {}
|
|
960
|
+
_LOG.warning(
|
|
961
|
+
"iZone system reconfigured uid=%s: %s",
|
|
962
|
+
self._device_uid,
|
|
963
|
+
DeviceReconfigurationError(changes),
|
|
964
|
+
)
|
|
965
|
+
self._reconfigured.update(changes)
|
|
966
|
+
|
|
967
|
+
def _raise_if_reconfigured(self) -> None:
|
|
968
|
+
if self._reconfigured is not None:
|
|
969
|
+
raise DeviceReconfigurationError(dict(self._reconfigured))
|
|
970
|
+
|
|
900
971
|
def _record_faults(
|
|
901
972
|
self, values: ControllerData, faults: list[str], *, offline: bool
|
|
902
973
|
) -> None:
|
|
@@ -977,8 +1048,10 @@ class Controller:
|
|
|
977
1048
|
|
|
978
1049
|
Raises:
|
|
979
1050
|
ConnectionError: If the HTTP request fails.
|
|
1051
|
+
DeviceReconfigurationError: If the system was reconfigured.
|
|
980
1052
|
|
|
981
1053
|
"""
|
|
1054
|
+
self._raise_if_reconfigured()
|
|
982
1055
|
if send is None:
|
|
983
1056
|
send = value
|
|
984
1057
|
|
|
@@ -1008,6 +1081,7 @@ class Controller:
|
|
|
1008
1081
|
self, command: str, data: dict[str, Any], zone_index: int
|
|
1009
1082
|
) -> None:
|
|
1010
1083
|
"""POST a zone command and confirm with a zone refresh."""
|
|
1084
|
+
self._raise_if_reconfigured()
|
|
1011
1085
|
async with self._sending_lock, self._refresh_scope():
|
|
1012
1086
|
if self._read_api == "v2":
|
|
1013
1087
|
if self._closed:
|
|
@@ -1082,7 +1156,11 @@ class Controller:
|
|
|
1082
1156
|
"""Bounded, read-only confirmation; never resend a zone command."""
|
|
1083
1157
|
loop = asyncio.get_running_loop()
|
|
1084
1158
|
try:
|
|
1085
|
-
while
|
|
1159
|
+
while (
|
|
1160
|
+
self._zone_mode_confirmations
|
|
1161
|
+
and not self._closed
|
|
1162
|
+
and self._reconfigured is None
|
|
1163
|
+
):
|
|
1086
1164
|
self._expire_zone_modes(loop.time())
|
|
1087
1165
|
if not self._zone_mode_confirmations:
|
|
1088
1166
|
break
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""pizone-specific exceptions."""
|
|
2
2
|
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
3
5
|
from .const import PLACEHOLDER_DEVICE_UID
|
|
4
6
|
from .types import VerifyFailure, _failure_text
|
|
5
7
|
|
|
@@ -13,6 +15,39 @@ class ControllerCommandError(Exception):
|
|
|
13
15
|
"""
|
|
14
16
|
|
|
15
17
|
|
|
18
|
+
class DeviceReconfigurationError(Exception):
|
|
19
|
+
"""The system no longer matches the controller built at connect.
|
|
20
|
+
|
|
21
|
+
Raised once a clean read shows that an installer has reprogrammed the
|
|
22
|
+
system, for example the number of zones or a zone type changed. The
|
|
23
|
+
controller stays this way: every refresh and command raises this until it
|
|
24
|
+
is closed and a new one is created with
|
|
25
|
+
:meth:`~pizone.discovery.DiscoveryService.create_controller`.
|
|
26
|
+
|
|
27
|
+
Not a :exc:`ConnectionError`: the device is reachable and answering.
|
|
28
|
+
|
|
29
|
+
Attributes:
|
|
30
|
+
changes: Each changed field, mapped to its value at connect and its
|
|
31
|
+
new value. Zone types use keys like ``"Zone 3 Type"``.
|
|
32
|
+
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
def __init__(self, changes: dict[str, tuple[Any, Any]]) -> None:
|
|
36
|
+
"""Create the error for *changes*."""
|
|
37
|
+
super().__init__()
|
|
38
|
+
self.changes = changes
|
|
39
|
+
|
|
40
|
+
def __str__(self) -> str:
|
|
41
|
+
"""Plain-English description, for logs and tracebacks."""
|
|
42
|
+
detail = ", ".join(
|
|
43
|
+
f"{field} {old!r} -> {new!r}" for field, (old, new) in self.changes.items()
|
|
44
|
+
)
|
|
45
|
+
return (
|
|
46
|
+
f"iZone system was reconfigured ({detail}); close this controller "
|
|
47
|
+
"and create a new one"
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
16
51
|
class InvalidValueError(ValueError, AttributeError):
|
|
17
52
|
"""A setter rejected a value before sending anything to the device.
|
|
18
53
|
|
|
@@ -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.0
|
|
22
|
-
__version_tuple__ = version_tuple = (2,
|
|
21
|
+
__version__ = version = '2.1.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (2, 1, 0)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -90,6 +90,8 @@ class Zone:
|
|
|
90
90
|
self._zone_data: Zone.ZoneData = {}
|
|
91
91
|
self._index = index
|
|
92
92
|
self._controller = controller
|
|
93
|
+
# Zone type at connect; None until the first clean read sets it.
|
|
94
|
+
self._built_type: Zone.DictValue | None = None
|
|
93
95
|
|
|
94
96
|
@property
|
|
95
97
|
def index(self) -> int:
|
|
@@ -278,9 +280,16 @@ class Zone:
|
|
|
278
280
|
"""
|
|
279
281
|
if zone_data["Index"] != self._index:
|
|
280
282
|
raise AttributeError("Can't change index of existing zone.")
|
|
281
|
-
|
|
283
|
+
zone_type = zone_data.get("Type")
|
|
284
|
+
if str(zone_type) == "error":
|
|
282
285
|
return
|
|
283
286
|
self._zone_data = zone_data
|
|
287
|
+
if self._built_type is None:
|
|
288
|
+
self._built_type = zone_type
|
|
289
|
+
elif zone_type != self._built_type:
|
|
290
|
+
self._controller._note_reconfigured( # noqa: SLF001
|
|
291
|
+
{f"Zone {self._index + 1} Type": (self._built_type, zone_type)}
|
|
292
|
+
)
|
|
284
293
|
|
|
285
294
|
def _get_zone_state(self, state: str) -> DictValue:
|
|
286
295
|
return self._zone_data[state]
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"""Latching on a device reconfiguration seen in a clean read."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
from collections.abc import AsyncIterator
|
|
5
|
+
from copy import deepcopy
|
|
6
|
+
from typing import Any, cast
|
|
7
|
+
from unittest.mock import AsyncMock
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
|
|
11
|
+
from pizone import DeviceReconfigurationError, v2
|
|
12
|
+
|
|
13
|
+
from .conftest import MockController, MockDiscoveryService, add_mock_controller
|
|
14
|
+
from .v2_fixtures import SAMPLE_SYSTEM_V2, SAMPLE_ZONES_V2
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.fixture
|
|
18
|
+
async def v2_controller() -> AsyncIterator[MockController]:
|
|
19
|
+
svc = MockDiscoveryService()
|
|
20
|
+
ctrl = MockController(
|
|
21
|
+
svc,
|
|
22
|
+
device_uid="000025841",
|
|
23
|
+
device_ip="192.0.2.1",
|
|
24
|
+
is_v2=True,
|
|
25
|
+
is_ipower=False,
|
|
26
|
+
)
|
|
27
|
+
ctrl._read_api = "v2"
|
|
28
|
+
ctrl.v2_system = deepcopy(SAMPLE_SYSTEM_V2)
|
|
29
|
+
ctrl.v2_zones = deepcopy(SAMPLE_ZONES_V2)
|
|
30
|
+
svc._claim(ctrl)
|
|
31
|
+
try:
|
|
32
|
+
await ctrl._initialize(
|
|
33
|
+
system_settings=v2.system_v2_to_settings(
|
|
34
|
+
SAMPLE_SYSTEM_V2["SystemV2"], ctrl.device_uid
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
ctrl.sent.clear()
|
|
38
|
+
yield ctrl
|
|
39
|
+
finally:
|
|
40
|
+
await ctrl.close()
|
|
41
|
+
await svc.close()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _v1(service: MockDiscoveryService) -> MockController:
|
|
45
|
+
return cast(MockController, service._controller("000000001"))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@pytest.mark.parametrize(
|
|
49
|
+
("field", "value", "expected"),
|
|
50
|
+
[
|
|
51
|
+
pytest.param("NoOfZones", 7, (8, 7), id="zone_count"),
|
|
52
|
+
pytest.param("NoOfConst", 2, (1, 2), id="const_count"),
|
|
53
|
+
pytest.param("SysType", "310", ("320", "310"), id="sys_type"),
|
|
54
|
+
pytest.param("FanAuto", "disabled", ("3-speed", "disabled"), id="fan_auto"),
|
|
55
|
+
],
|
|
56
|
+
)
|
|
57
|
+
@pytest.mark.asyncio
|
|
58
|
+
async def test_vital_field_change_latches(
|
|
59
|
+
service: MockDiscoveryService, field: str, value: Any, expected: tuple
|
|
60
|
+
) -> None:
|
|
61
|
+
controller = _v1(service)
|
|
62
|
+
controller.resources["SystemSettings"][field] = value
|
|
63
|
+
|
|
64
|
+
with pytest.raises(DeviceReconfigurationError) as err:
|
|
65
|
+
await controller.refresh_system()
|
|
66
|
+
|
|
67
|
+
assert err.value.changes == {field: expected}
|
|
68
|
+
assert controller.dump_state()["reconfigured"] == {field: expected}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@pytest.mark.asyncio
|
|
72
|
+
async def test_missing_fan_auto_matches_disabled() -> None:
|
|
73
|
+
svc = MockDiscoveryService()
|
|
74
|
+
controller = MockController(
|
|
75
|
+
svc,
|
|
76
|
+
device_uid="000000001",
|
|
77
|
+
device_ip="8.8.8.8",
|
|
78
|
+
is_v2=False,
|
|
79
|
+
is_ipower=False,
|
|
80
|
+
)
|
|
81
|
+
del controller.resources["SystemSettings"]["FanAuto"]
|
|
82
|
+
svc._claim(controller)
|
|
83
|
+
await controller._initialize(
|
|
84
|
+
system_settings=deepcopy(controller.resources["SystemSettings"])
|
|
85
|
+
)
|
|
86
|
+
# Fan modes read an absent FanAuto as disabled, so the check must too.
|
|
87
|
+
controller.resources["SystemSettings"]["FanAuto"] = "disabled"
|
|
88
|
+
|
|
89
|
+
await controller.refresh_system()
|
|
90
|
+
|
|
91
|
+
assert controller._reconfigured is None
|
|
92
|
+
await svc.close()
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@pytest.mark.asyncio
|
|
96
|
+
async def test_faulted_read_does_not_latch(service: MockDiscoveryService) -> None:
|
|
97
|
+
controller = _v1(service)
|
|
98
|
+
settings = controller.resources["SystemSettings"]
|
|
99
|
+
settings["NoOfConst"] = 3
|
|
100
|
+
settings["UnitType"] = "error"
|
|
101
|
+
|
|
102
|
+
await controller.refresh_system()
|
|
103
|
+
|
|
104
|
+
assert controller._reconfigured is None
|
|
105
|
+
settings["UnitType"] = "Panasonic/Toshiba"
|
|
106
|
+
with pytest.raises(DeviceReconfigurationError):
|
|
107
|
+
await controller.refresh_system()
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
@pytest.mark.asyncio
|
|
111
|
+
async def test_unchanged_refresh_does_not_latch(service: MockDiscoveryService) -> None:
|
|
112
|
+
controller = _v1(service)
|
|
113
|
+
|
|
114
|
+
await controller.refresh_all()
|
|
115
|
+
await controller.refresh_all()
|
|
116
|
+
|
|
117
|
+
assert controller._reconfigured is None
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@pytest.mark.parametrize(
|
|
121
|
+
("zone_type", "latched"),
|
|
122
|
+
[
|
|
123
|
+
pytest.param("opcl", True, id="type_changed"),
|
|
124
|
+
pytest.param("error", False, id="type_faulted"),
|
|
125
|
+
],
|
|
126
|
+
)
|
|
127
|
+
@pytest.mark.asyncio
|
|
128
|
+
async def test_zone_type_change_latches(
|
|
129
|
+
service: MockDiscoveryService, zone_type: str, latched: bool
|
|
130
|
+
) -> None:
|
|
131
|
+
controller = _v1(service)
|
|
132
|
+
controller.resources["Zones1_4"][2]["Type"] = zone_type
|
|
133
|
+
|
|
134
|
+
if latched:
|
|
135
|
+
with pytest.raises(DeviceReconfigurationError) as err:
|
|
136
|
+
await controller.refresh_zones()
|
|
137
|
+
assert err.value.changes == {"Zone 3 Type": ("auto", "opcl")}
|
|
138
|
+
else:
|
|
139
|
+
await controller.refresh_zones()
|
|
140
|
+
assert controller._reconfigured is None
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@pytest.mark.asyncio
|
|
144
|
+
async def test_latched_controller_raises_before_io(
|
|
145
|
+
service: MockDiscoveryService,
|
|
146
|
+
) -> None:
|
|
147
|
+
controller = _v1(service)
|
|
148
|
+
controller.resources["SystemSettings"]["NoOfZones"] = 7
|
|
149
|
+
with pytest.raises(DeviceReconfigurationError):
|
|
150
|
+
await controller.refresh_system()
|
|
151
|
+
get = AsyncMock(wraps=controller._http_get)
|
|
152
|
+
controller._http_get = get # type: ignore[method-assign]
|
|
153
|
+
controller.sent.clear()
|
|
154
|
+
|
|
155
|
+
with pytest.raises(DeviceReconfigurationError):
|
|
156
|
+
await controller.refresh_all()
|
|
157
|
+
with pytest.raises(DeviceReconfigurationError):
|
|
158
|
+
await controller.set_on(False)
|
|
159
|
+
with pytest.raises(DeviceReconfigurationError):
|
|
160
|
+
await controller.zones[0].set_temp_setpoint(22.0)
|
|
161
|
+
|
|
162
|
+
get.assert_not_awaited()
|
|
163
|
+
assert controller.sent == []
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
@pytest.mark.asyncio
|
|
167
|
+
async def test_v1_reconfigure_outranks_zone_error(
|
|
168
|
+
service: MockDiscoveryService,
|
|
169
|
+
) -> None:
|
|
170
|
+
controller = _v1(service)
|
|
171
|
+
controller.resources["SystemSettings"]["NoOfZones"] = 4
|
|
172
|
+
del controller.resources["Zones5_8"]
|
|
173
|
+
|
|
174
|
+
with pytest.raises(DeviceReconfigurationError) as err:
|
|
175
|
+
await controller.refresh_all()
|
|
176
|
+
|
|
177
|
+
assert err.value.changes == {"NoOfZones": (8, 4)}
|
|
178
|
+
assert isinstance(err.value.__cause__, ConnectionError)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
@pytest.mark.asyncio
|
|
182
|
+
async def test_v2_reconfigure_raises_before_zone_requests(
|
|
183
|
+
v2_controller: MockController,
|
|
184
|
+
) -> None:
|
|
185
|
+
cast(dict, v2_controller.v2_system)["SystemV2"]["NoOfZones"] = 1
|
|
186
|
+
|
|
187
|
+
with pytest.raises(DeviceReconfigurationError) as err:
|
|
188
|
+
await v2_controller.refresh_all()
|
|
189
|
+
|
|
190
|
+
assert err.value.changes == {"NoOfZones": (2, 1)}
|
|
191
|
+
assert [item[1]["iZoneV2Request"]["Type"] for item in v2_controller.sent] == [1]
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
@pytest.mark.asyncio
|
|
195
|
+
async def test_v2_zone_type_change_latches(v2_controller: MockController) -> None:
|
|
196
|
+
v2_controller.v2_zones[1]["ZonesV2"]["ZoneType"] = 3
|
|
197
|
+
|
|
198
|
+
with pytest.raises(DeviceReconfigurationError) as err:
|
|
199
|
+
await v2_controller.refresh_zones()
|
|
200
|
+
|
|
201
|
+
assert err.value.changes == {"Zone 2 Type": ("opcl", "auto")}
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
@pytest.mark.asyncio
|
|
205
|
+
async def test_command_whose_confirm_read_latches_still_returns(
|
|
206
|
+
service: MockDiscoveryService,
|
|
207
|
+
) -> None:
|
|
208
|
+
controller = _v1(service)
|
|
209
|
+
controller.resources["SystemSettings"]["NoOfZones"] = 7
|
|
210
|
+
|
|
211
|
+
await controller.set_on(False)
|
|
212
|
+
|
|
213
|
+
assert controller._reconfigured == {"NoOfZones": (8, 7)}
|
|
214
|
+
with pytest.raises(DeviceReconfigurationError):
|
|
215
|
+
await controller.set_on(True)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
@pytest.mark.asyncio
|
|
219
|
+
async def test_confirm_loop_stops_when_latched(v2_controller: MockController) -> None:
|
|
220
|
+
v2_controller.ZONE_CONFIRM_DELAY = 0.01
|
|
221
|
+
v2_controller.ZONE_CONFIRM_INTERVAL = 0.01
|
|
222
|
+
await v2_controller.zones[0].set_mode(v2_controller.zones[0].Mode.CLOSE)
|
|
223
|
+
v2_controller._reconfigured = {"NoOfZones": (2, 1)}
|
|
224
|
+
read = AsyncMock(wraps=v2_controller._v2_request)
|
|
225
|
+
v2_controller._v2_request = read # type: ignore[method-assign]
|
|
226
|
+
v2_controller._zone_confirm_wake.set()
|
|
227
|
+
|
|
228
|
+
task = v2_controller._zone_confirm_task
|
|
229
|
+
assert task is not None
|
|
230
|
+
await asyncio.wait_for(task, 2)
|
|
231
|
+
|
|
232
|
+
read.assert_not_awaited()
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
@pytest.mark.asyncio
|
|
236
|
+
async def test_recreated_controller_is_not_latched() -> None:
|
|
237
|
+
svc = MockDiscoveryService()
|
|
238
|
+
controller = await add_mock_controller(svc, "000000001", "8.8.8.8")
|
|
239
|
+
controller.resources["SystemSettings"]["NoOfZones"] = 4
|
|
240
|
+
with pytest.raises(DeviceReconfigurationError):
|
|
241
|
+
await controller.refresh_system()
|
|
242
|
+
|
|
243
|
+
await controller.close()
|
|
244
|
+
fresh = MockController(
|
|
245
|
+
svc,
|
|
246
|
+
device_uid="000000001",
|
|
247
|
+
device_ip="8.8.8.8",
|
|
248
|
+
is_v2=False,
|
|
249
|
+
is_ipower=False,
|
|
250
|
+
)
|
|
251
|
+
fresh.resources["SystemSettings"]["NoOfZones"] = 4
|
|
252
|
+
svc._claim(fresh)
|
|
253
|
+
await fresh._initialize(system_settings=fresh.resources["SystemSettings"])
|
|
254
|
+
|
|
255
|
+
await fresh.refresh_all()
|
|
256
|
+
|
|
257
|
+
assert fresh._reconfigured is None
|
|
258
|
+
assert len(fresh.zones) == 4
|
|
259
|
+
await svc.close()
|
|
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.0.1 → python_izone-2.1.0}/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
|