python-izone 2.0.1__py3-none-any.whl → 2.1.0__py3-none-any.whl
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.
- pizone/__init__.py +2 -0
- pizone/controller.py +89 -11
- pizone/exceptions.py +35 -0
- pizone/version.py +2 -2
- pizone/zone.py +10 -1
- {python_izone-2.0.1.dist-info → python_izone-2.1.0.dist-info}/METADATA +1 -1
- python_izone-2.1.0.dist-info/RECORD +15 -0
- python_izone-2.0.1.dist-info/RECORD +0 -15
- {python_izone-2.0.1.dist-info → python_izone-2.1.0.dist-info}/WHEEL +0 -0
- {python_izone-2.0.1.dist-info → python_izone-2.1.0.dist-info}/licenses/licence.txt +0 -0
pizone/__init__.py
CHANGED
|
@@ -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",
|
pizone/controller.py
CHANGED
|
@@ -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
|
pizone/exceptions.py
CHANGED
|
@@ -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
|
|
pizone/version.py
CHANGED
|
@@ -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
|
pizone/zone.py
CHANGED
|
@@ -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,15 @@
|
|
|
1
|
+
pizone/__init__.py,sha256=Q3in9_rEc4gMUJJqOkrvcJJQoCAl2pQIcAnTB_sxQBI,3010
|
|
2
|
+
pizone/const.py,sha256=0skTh6zBe61AJ_57fqdBrxz3aVBM3T4Ak_cPSkOx2Bo,153
|
|
3
|
+
pizone/controller.py,sha256=umLIQicUYuhqm2iJ2ECj-aEefRlasyH6lv_40ogMfac,50274
|
|
4
|
+
pizone/discovery.py,sha256=UX5IAZTAXEk51nHsCLzFe4W80MZjlm31W8HYfszGuwo,43447
|
|
5
|
+
pizone/exceptions.py,sha256=IJMsGOocv-sqBDsZP4MuOb_a3b1kRhGLig3YykncgI0,4527
|
|
6
|
+
pizone/power.py,sha256=2ltoFotv3phsRJHXxP9Yu7M4PmvUVi8Q_0KJUVvuGkc,10533
|
|
7
|
+
pizone/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
pizone/types.py,sha256=W7pAoBPw1cDt0V_5MbasgUiz7Iwq0zfdxpH4gHTmzsQ,2860
|
|
9
|
+
pizone/v2.py,sha256=F-jsKfOVFAtRrjzHeGQcuG48_DJ3C-0sRKE_2urTwEw,19276
|
|
10
|
+
pizone/version.py,sha256=v9WVy_5yL3epBJmMyIAo86Fa1LzYly1fPB2fENrVANg,520
|
|
11
|
+
pizone/zone.py,sha256=TaUnHKZUSupP1NHy8SJglXmkv6yG42e-MUu20u00Pv0,10909
|
|
12
|
+
python_izone-2.1.0.dist-info/METADATA,sha256=SypgaparUHrPPq_CDRy2yYgfP3ND0V0ilvPTVr9P5Ko,4282
|
|
13
|
+
python_izone-2.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
14
|
+
python_izone-2.1.0.dist-info/licenses/licence.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
15
|
+
python_izone-2.1.0.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
pizone/__init__.py,sha256=0mUQKWmIebkS8h5yxgqVOqJAXfmQcESGsnkCh6Dkvbo,2944
|
|
2
|
-
pizone/const.py,sha256=0skTh6zBe61AJ_57fqdBrxz3aVBM3T4Ak_cPSkOx2Bo,153
|
|
3
|
-
pizone/controller.py,sha256=6XhX5ktUOxNFL1KHz0FnSbxblFhCAA6Z1LvNNUn44sk,47327
|
|
4
|
-
pizone/discovery.py,sha256=UX5IAZTAXEk51nHsCLzFe4W80MZjlm31W8HYfszGuwo,43447
|
|
5
|
-
pizone/exceptions.py,sha256=gd4Xuo05TDtQRob1F65WWhLBEKhsWveK3nK6w-j8Lr4,3270
|
|
6
|
-
pizone/power.py,sha256=2ltoFotv3phsRJHXxP9Yu7M4PmvUVi8Q_0KJUVvuGkc,10533
|
|
7
|
-
pizone/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
pizone/types.py,sha256=W7pAoBPw1cDt0V_5MbasgUiz7Iwq0zfdxpH4gHTmzsQ,2860
|
|
9
|
-
pizone/v2.py,sha256=F-jsKfOVFAtRrjzHeGQcuG48_DJ3C-0sRKE_2urTwEw,19276
|
|
10
|
-
pizone/version.py,sha256=AJvqZqEOrEKVHQbALacgWiM-1U44ZzqQ-ZsR-NbTbjg,520
|
|
11
|
-
pizone/zone.py,sha256=u6NLmha6fr19_75UOnipkSTQ-PPkhVQ9ivpqRCchq6c,10470
|
|
12
|
-
python_izone-2.0.1.dist-info/METADATA,sha256=VqjyrgX_w8GFyIF35uMQm9dRB3g_BTPouqv_KedB2xg,4282
|
|
13
|
-
python_izone-2.0.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
14
|
-
python_izone-2.0.1.dist-info/licenses/licence.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
15
|
-
python_izone-2.0.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|