python-izone 2.0.1__py3-none-any.whl → 2.1.1__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 +190 -46
- pizone/exceptions.py +35 -0
- pizone/v2.py +10 -11
- pizone/version.py +2 -2
- pizone/zone.py +26 -15
- {python_izone-2.0.1.dist-info → python_izone-2.1.1.dist-info}/METADATA +1 -1
- python_izone-2.1.1.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.1.dist-info}/WHEEL +0 -0
- {python_izone-2.0.1.dist-info → python_izone-2.1.1.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
|
|
|
@@ -95,6 +109,16 @@ class Controller:
|
|
|
95
109
|
REQUEST_TIMEOUT = 10
|
|
96
110
|
"""Time to wait for a response from the device, in seconds."""
|
|
97
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
|
+
|
|
98
122
|
ZONE_CONFIRM_DELAY = 0.25
|
|
99
123
|
ZONE_CONFIRM_INTERVAL = 2.0
|
|
100
124
|
ZONE_CONFIRM_WINDOW = 30.0
|
|
@@ -175,9 +199,13 @@ class Controller:
|
|
|
175
199
|
self._izone_ok: bool = True
|
|
176
200
|
self._fault_fields: tuple[str, ...] = ()
|
|
177
201
|
self._last_fault: dict[str, Any] | None = None
|
|
202
|
+
# System fields the zones and fan modes were built from at connect.
|
|
203
|
+
self._built_from: dict[str, Any] | None = None
|
|
204
|
+
self._reconfigured: dict[str, tuple[Any, Any]] | None = None
|
|
178
205
|
self._on_address_changed: Callable[[ControllerEndpoint], None] | None = None
|
|
179
206
|
|
|
180
207
|
self._sending_lock = Lock()
|
|
208
|
+
self._v2_write_gens: dict[tuple[str, int | None], int] = {}
|
|
181
209
|
self._refresh_depth: int = 0
|
|
182
210
|
self._refresh_fail_ex: ConnectionError | None = None
|
|
183
211
|
self._zone_mode_confirmations: dict[int, _ZoneModeConfirmation] = {}
|
|
@@ -260,19 +288,23 @@ class Controller:
|
|
|
260
288
|
if settings is None:
|
|
261
289
|
raise ConnectionError("SystemSettings device ID mismatch")
|
|
262
290
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
)
|
|
268
|
-
else:
|
|
269
|
-
self.fan_modes = Controller._VALID_FAN_MODES["disabled"]
|
|
291
|
+
self.fan_modes = Controller._VALID_FAN_MODES.get(
|
|
292
|
+
self._fan_auto(self._system_settings),
|
|
293
|
+
Controller._VALID_FAN_MODES["unknown"],
|
|
294
|
+
)
|
|
270
295
|
|
|
271
296
|
zone_count = int(settings["NoOfZones"])
|
|
272
297
|
self.zones = [Zone(self, i) for i in range(zone_count)]
|
|
273
298
|
|
|
274
299
|
await self._fetch_zones()
|
|
275
300
|
|
|
301
|
+
self._built_from = {
|
|
302
|
+
"NoOfZones": zone_count,
|
|
303
|
+
"NoOfConst": settings.get("NoOfConst"),
|
|
304
|
+
"SysType": settings.get("SysType"),
|
|
305
|
+
"FanAuto": self._fan_auto(self._system_settings),
|
|
306
|
+
}
|
|
307
|
+
|
|
276
308
|
await self._probe_power()
|
|
277
309
|
|
|
278
310
|
async def _probe_power(self) -> None:
|
|
@@ -347,6 +379,7 @@ class Controller:
|
|
|
347
379
|
"fan_modes": [fan.value for fan in self.fan_modes],
|
|
348
380
|
"system_settings": dict(self._system_settings),
|
|
349
381
|
"last_fault": self._last_fault,
|
|
382
|
+
"reconfigured": self._reconfigured,
|
|
350
383
|
"zones": [zone.dump_state() for zone in self.zones],
|
|
351
384
|
"power": self._power.dump_state() if self._power is not None else None,
|
|
352
385
|
}
|
|
@@ -423,8 +456,11 @@ class Controller:
|
|
|
423
456
|
raise InvalidValueError("Free air system is not enabled")
|
|
424
457
|
await self._set_system_state("FreeAir", "FreeAir", "on")
|
|
425
458
|
else:
|
|
426
|
-
|
|
427
|
-
|
|
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
|
|
428
464
|
await self._set_system_state("SysMode", "SystemMODE", value.value)
|
|
429
465
|
|
|
430
466
|
@property
|
|
@@ -849,6 +885,7 @@ class Controller:
|
|
|
849
885
|
"""System + zones [+ power] fetch (no refresh scope)."""
|
|
850
886
|
if self._read_api == "v2":
|
|
851
887
|
await self._fetch_system()
|
|
888
|
+
self._raise_if_reconfigured()
|
|
852
889
|
await self._fetch_zones()
|
|
853
890
|
await self._fetch_power()
|
|
854
891
|
return
|
|
@@ -895,8 +932,56 @@ class Controller:
|
|
|
895
932
|
|
|
896
933
|
self._system_settings = values
|
|
897
934
|
self._set_izone_ok(True)
|
|
935
|
+
if not faults and self._built_from is not None:
|
|
936
|
+
self._check_reconfigured(values)
|
|
898
937
|
return values
|
|
899
938
|
|
|
939
|
+
@staticmethod
|
|
940
|
+
def _fan_auto(values: ControllerData) -> str:
|
|
941
|
+
"""Return FanAuto as the fan modes read it; absent means disabled."""
|
|
942
|
+
if not values:
|
|
943
|
+
return "disabled"
|
|
944
|
+
return str(values.get("FanAuto", "disabled"))
|
|
945
|
+
|
|
946
|
+
def _check_reconfigured(self, values: ControllerData) -> None:
|
|
947
|
+
"""Latch if a clean read no longer matches what was built at connect."""
|
|
948
|
+
built = cast(dict[str, Any], self._built_from)
|
|
949
|
+
if (
|
|
950
|
+
int(values["NoOfZones"]) == built["NoOfZones"]
|
|
951
|
+
and values.get("NoOfConst") == built["NoOfConst"]
|
|
952
|
+
and values.get("SysType") == built["SysType"]
|
|
953
|
+
and self._fan_auto(values) == built["FanAuto"]
|
|
954
|
+
):
|
|
955
|
+
return
|
|
956
|
+
current = {
|
|
957
|
+
"NoOfZones": int(values["NoOfZones"]),
|
|
958
|
+
"NoOfConst": values.get("NoOfConst"),
|
|
959
|
+
"SysType": values.get("SysType"),
|
|
960
|
+
"FanAuto": self._fan_auto(values),
|
|
961
|
+
}
|
|
962
|
+
self._note_reconfigured(
|
|
963
|
+
{
|
|
964
|
+
field: (old, current[field])
|
|
965
|
+
for field, old in built.items()
|
|
966
|
+
if current[field] != old
|
|
967
|
+
}
|
|
968
|
+
)
|
|
969
|
+
|
|
970
|
+
def _note_reconfigured(self, changes: dict[str, tuple[Any, Any]]) -> None:
|
|
971
|
+
"""Latch the reconfigured state; it only clears with a new controller."""
|
|
972
|
+
if self._reconfigured is None:
|
|
973
|
+
self._reconfigured = {}
|
|
974
|
+
_LOG.warning(
|
|
975
|
+
"iZone system reconfigured uid=%s: %s",
|
|
976
|
+
self._device_uid,
|
|
977
|
+
DeviceReconfigurationError(changes),
|
|
978
|
+
)
|
|
979
|
+
self._reconfigured.update(changes)
|
|
980
|
+
|
|
981
|
+
def _raise_if_reconfigured(self) -> None:
|
|
982
|
+
if self._reconfigured is not None:
|
|
983
|
+
raise DeviceReconfigurationError(dict(self._reconfigured))
|
|
984
|
+
|
|
900
985
|
def _record_faults(
|
|
901
986
|
self, values: ControllerData, faults: list[str], *, offline: bool
|
|
902
987
|
) -> None:
|
|
@@ -972,57 +1057,112 @@ class Controller:
|
|
|
972
1057
|
command: str,
|
|
973
1058
|
value: DictValue,
|
|
974
1059
|
send: DictValue | None = None,
|
|
975
|
-
) ->
|
|
1060
|
+
) -> bool:
|
|
976
1061
|
"""Send a system command and update the local cache.
|
|
977
1062
|
|
|
1063
|
+
Returns False if a newer write to the same field replaced it.
|
|
1064
|
+
|
|
978
1065
|
Raises:
|
|
979
1066
|
ConnectionError: If the HTTP request fails.
|
|
1067
|
+
DeviceReconfigurationError: If the system was reconfigured.
|
|
980
1068
|
|
|
981
1069
|
"""
|
|
1070
|
+
self._raise_if_reconfigured()
|
|
982
1071
|
if send is None:
|
|
983
1072
|
send = value
|
|
984
1073
|
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
v2_payload = v2_mod.system_command_to_v2(state, value, send)
|
|
988
|
-
if state == "FreeAir" and self._isave_v2_unsupported:
|
|
989
|
-
v2_payload = None
|
|
990
|
-
if v2_payload is not None:
|
|
991
|
-
try:
|
|
992
|
-
await self._http_command_v2(v2_payload)
|
|
993
|
-
except ControllerCommandError:
|
|
994
|
-
if state != "FreeAir":
|
|
995
|
-
raise
|
|
996
|
-
self._isave_v2_unsupported = True
|
|
997
|
-
await self._http_post(command, {command: send})
|
|
998
|
-
else:
|
|
999
|
-
await self._http_post(command, {command: send})
|
|
1000
|
-
self._system_settings[state] = value
|
|
1001
|
-
await self._fetch_system_v2_unlocked()
|
|
1002
|
-
else:
|
|
1074
|
+
if self._read_api != "v2":
|
|
1075
|
+
async with self._sending_lock, self._refresh_scope():
|
|
1003
1076
|
await self._http_post(command, {command: send})
|
|
1004
1077
|
self._system_settings[state] = value
|
|
1005
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
|
|
1006
1099
|
|
|
1007
1100
|
async def _execute_zone_command(
|
|
1008
1101
|
self, command: str, data: dict[str, Any], zone_index: int
|
|
1009
|
-
) ->
|
|
1010
|
-
"""POST a zone command and confirm with a zone refresh.
|
|
1011
|
-
|
|
1012
|
-
|
|
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
|
+
"""
|
|
1107
|
+
self._raise_if_reconfigured()
|
|
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()
|
|
1013
1154
|
if self._closed:
|
|
1014
1155
|
raise ConnectionError("Controller is closed")
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
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)
|
|
1020
1162
|
else:
|
|
1021
|
-
await
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
await self._http_post(command, data)
|
|
1025
|
-
await self._fetch_zone_group(group)
|
|
1163
|
+
await apply()
|
|
1164
|
+
return True
|
|
1165
|
+
await asyncio.sleep(self.V2_ERROR_RETRY_INTERVAL)
|
|
1026
1166
|
|
|
1027
1167
|
async def _fetch_zone_v2_unlocked(self, index: int) -> None:
|
|
1028
1168
|
"""Refresh one zone via Type=2. Caller must hold ``_sending_lock``."""
|
|
@@ -1082,7 +1222,11 @@ class Controller:
|
|
|
1082
1222
|
"""Bounded, read-only confirmation; never resend a zone command."""
|
|
1083
1223
|
loop = asyncio.get_running_loop()
|
|
1084
1224
|
try:
|
|
1085
|
-
while
|
|
1225
|
+
while (
|
|
1226
|
+
self._zone_mode_confirmations
|
|
1227
|
+
and not self._closed
|
|
1228
|
+
and self._reconfigured is None
|
|
1229
|
+
):
|
|
1086
1230
|
self._expire_zone_modes(loop.time())
|
|
1087
1231
|
if not self._zone_mode_confirmations:
|
|
1088
1232
|
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/v2.py
CHANGED
|
@@ -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):
|
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.
|
|
22
|
-
__version_tuple__ = version_tuple = (2,
|
|
21
|
+
__version__ = version = '2.1.1'
|
|
22
|
+
__version_tuple__ = version_tuple = (2, 1, 1)
|
|
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:
|
|
@@ -203,8 +205,8 @@ class Zone:
|
|
|
203
205
|
if value < 0 or value > 100:
|
|
204
206
|
raise InvalidValueError(f"MinAir '{value}' is out of range")
|
|
205
207
|
|
|
206
|
-
await self._send_command("AirMinCommand", value)
|
|
207
|
-
|
|
208
|
+
if await self._send_command("AirMinCommand", value):
|
|
209
|
+
self._zone_data["MinAir"] = value
|
|
208
210
|
|
|
209
211
|
async def set_airflow_max(self, value: int) -> None:
|
|
210
212
|
"""Change the zone maximum airflow in 5% increments.
|
|
@@ -219,8 +221,8 @@ class Zone:
|
|
|
219
221
|
if value < 0 or value > 100:
|
|
220
222
|
raise InvalidValueError(f"MaxAir '{value}' is out of range")
|
|
221
223
|
|
|
222
|
-
await self._send_command("AirMaxCommand", value)
|
|
223
|
-
|
|
224
|
+
if await self._send_command("AirMaxCommand", value):
|
|
225
|
+
self._zone_data["MaxAir"] = value
|
|
224
226
|
|
|
225
227
|
async def set_temp_setpoint(self, value: float) -> None:
|
|
226
228
|
"""Change the zone temperature setpoint in degrees C.
|
|
@@ -241,9 +243,9 @@ class Zone:
|
|
|
241
243
|
if value < self._controller.temp_min or value > self._controller.temp_max:
|
|
242
244
|
raise InvalidValueError(f"SetPoint '{value}' is out of range")
|
|
243
245
|
|
|
244
|
-
await self._send_command("ZoneCommand", value)
|
|
245
|
-
|
|
246
|
-
|
|
246
|
+
if await self._send_command("ZoneCommand", value):
|
|
247
|
+
self._zone_data["Mode"] = "auto"
|
|
248
|
+
self._zone_data["SetPoint"] = value
|
|
247
249
|
|
|
248
250
|
async def set_mode(self, value: Zone.Mode) -> None:
|
|
249
251
|
"""Set the current zone mode.
|
|
@@ -259,14 +261,14 @@ class Zone:
|
|
|
259
261
|
# V2 can select AUTO without overwriting a newer wall-panel setpoint.
|
|
260
262
|
# V1 still needs the cached setpoint to select temperature control.
|
|
261
263
|
if self._controller._read_api == "v2": # noqa: SLF001
|
|
262
|
-
await self._send_command("ZoneCommand", value.value)
|
|
264
|
+
sent = await self._send_command("ZoneCommand", value.value)
|
|
263
265
|
else:
|
|
264
|
-
await self._send_command(
|
|
266
|
+
sent = await self._send_command(
|
|
265
267
|
"ZoneCommand", self._get_zone_state("SetPoint")
|
|
266
268
|
)
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
269
|
+
if sent:
|
|
270
|
+
self._zone_data["Mode"] = "auto"
|
|
271
|
+
elif await self._send_command("ZoneCommand", value.value):
|
|
270
272
|
self._zone_data["Mode"] = value.value
|
|
271
273
|
|
|
272
274
|
def _update_zone(self, zone_data: Zone.ZoneData) -> None:
|
|
@@ -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]
|
|
@@ -307,14 +316,16 @@ class Zone:
|
|
|
307
316
|
except KeyError, ValueError:
|
|
308
317
|
return None
|
|
309
318
|
|
|
310
|
-
async def _send_command(self, command: str, data: str | float) ->
|
|
319
|
+
async def _send_command(self, command: str, data: str | float) -> bool:
|
|
311
320
|
"""Send a zone command via the parent controller.
|
|
312
321
|
|
|
322
|
+
Returns False if a newer write to the same field replaced it.
|
|
323
|
+
|
|
313
324
|
Raises:
|
|
314
325
|
ConnectionError: If the device cannot be reached or the response is invalid.
|
|
315
326
|
|
|
316
327
|
"""
|
|
317
328
|
send_data = {command: {"ZoneNo": str(self._index + 1), "Command": str(data)}}
|
|
318
|
-
await self._controller._execute_zone_command( # noqa: SLF001
|
|
329
|
+
return await self._controller._execute_zone_command( # noqa: SLF001
|
|
319
330
|
command, send_data, self._index
|
|
320
331
|
)
|
|
@@ -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=tbzYIWLgNGbdbIz9V2p01S5lY6B_VN7KJ4uddqB6G9k,52631
|
|
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=EzVCIzEAHaZcZVjvhreTR9_rNr7rrwRt_t9Bpd-pkZw,19270
|
|
10
|
+
pizone/version.py,sha256=rn5oInXmmhzUEn1IjVIbkXfet5tCFtndQd4xmEGVmko,520
|
|
11
|
+
pizone/zone.py,sha256=a-077W9SivsC3O-XYSrxWJex3pubaJIIw-AKMVSGrOA,11042
|
|
12
|
+
python_izone-2.1.1.dist-info/METADATA,sha256=IvSP9hlkCS_gosdxwNsNjXF0Y0jR-sXacwg4XP0wdXY,4282
|
|
13
|
+
python_izone-2.1.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
14
|
+
python_izone-2.1.1.dist-info/licenses/licence.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
15
|
+
python_izone-2.1.1.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
|