python-duco-connectivity 0.15.0__tar.gz → 0.17.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_duco_connectivity-0.15.0/src/python_duco_connectivity.egg-info → python_duco_connectivity-0.17.0}/PKG-INFO +17 -1
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/README.md +16 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/pyproject.toml +1 -1
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/duco_connectivity/__init__.py +4 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/duco_connectivity/cli.py +3 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/duco_connectivity/client.py +102 -28
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/duco_connectivity/exceptions.py +22 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/duco_connectivity/models.py +12 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0/src/python_duco_connectivity.egg-info}/PKG-INFO +17 -1
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/tests/test_api_reference.py +1 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/tests/test_client.py +194 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/tests/test_exceptions.py +20 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/LICENSE +0 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/setup.cfg +0 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/duco_connectivity/__main__.py +0 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/duco_connectivity/py.typed +0 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/python_duco_connectivity.egg-info/SOURCES.txt +0 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/python_duco_connectivity.egg-info/dependency_links.txt +0 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/python_duco_connectivity.egg-info/entry_points.txt +0 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/python_duco_connectivity.egg-info/requires.txt +0 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/python_duco_connectivity.egg-info/top_level.txt +0 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/tests/test_cli.py +0 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/tests/test_local_sample_validation.py +0 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/tests/test_models.py +0 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/tests/test_pytest_live_support.py +0 -0
- {python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/tests/test_replay_helpers.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-duco-connectivity
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.17.0
|
|
4
4
|
Summary: Async HTTP client for the local Duco Connectivity API
|
|
5
5
|
Author: Ronald van der Meer
|
|
6
6
|
License-Expression: MIT
|
|
@@ -64,6 +64,7 @@ in the development examples below.
|
|
|
64
64
|
- asynchronous communication via `aiohttp`
|
|
65
65
|
- typed stable config families for the documented `/config` branches
|
|
66
66
|
- typed helpers for stable `/info` fields such as heat recovery filter time
|
|
67
|
+
- a typed overview for selected values from one unfiltered `/info` request
|
|
67
68
|
- natural empty results for optional capability discovery and explicit errors
|
|
68
69
|
for strict capability access
|
|
69
70
|
- typed models that stay close to the API response shape
|
|
@@ -97,6 +98,17 @@ pre-0.13 raw status string remains compatible and derives `raw_status`
|
|
|
97
98
|
automatically; callers using a normalized `DiagStatus` must provide
|
|
98
99
|
`raw_status` explicitly.
|
|
99
100
|
|
|
101
|
+
`async_get_info_overview()` combines RSSI, diagnostic subsystems, heat recovery
|
|
102
|
+
filter time, and ventilation temperatures from one `GET /info` request. Missing
|
|
103
|
+
product-specific modules produce their natural empty values. Unlike most typed
|
|
104
|
+
models, `InfoOverview` does not retain the broad response or the LAN raw
|
|
105
|
+
payload, because that response can contain network credentials such as the
|
|
106
|
+
Wi-Fi access point key.
|
|
107
|
+
|
|
108
|
+
`async_set_node_identify(node_id, identify)` exposes the node `SetIdentify`
|
|
109
|
+
action with an explicit Boolean state. The helper raises `DucoActionError` when
|
|
110
|
+
the box returns an unsuccessful action result.
|
|
111
|
+
|
|
100
112
|
## Getting started
|
|
101
113
|
|
|
102
114
|
```python
|
|
@@ -111,9 +123,11 @@ async def main() -> None:
|
|
|
111
123
|
async with aiohttp.ClientSession() as session:
|
|
112
124
|
client = DucoClient(session, "192.168.1.10")
|
|
113
125
|
api_info = await client.async_get_api_info()
|
|
126
|
+
info = await client.async_get_info_overview()
|
|
114
127
|
nodes = await client.async_get_nodes_overview()
|
|
115
128
|
|
|
116
129
|
print(api_info.public_api_version)
|
|
130
|
+
print(info.rssi_wifi)
|
|
117
131
|
print([node.node_id for node in nodes])
|
|
118
132
|
|
|
119
133
|
|
|
@@ -129,6 +143,8 @@ public client methods, exports, compatibility aliases, and construction rules.
|
|
|
129
143
|
- `docs/api-reference.md` for the central public API inventory
|
|
130
144
|
- `docs/cli.md` for the function probe CLI and shell examples
|
|
131
145
|
- `docs/config.md` for system, node, and zone config reads and writes
|
|
146
|
+
- `docs/endpoint-inventory.md` for the Public API 2.5 read routes and observed
|
|
147
|
+
response shapes across tested Duco products
|
|
132
148
|
- `docs/live-testing.md` for local opt-in tests against a real Duco device
|
|
133
149
|
- `docs/replay-testing.md` for local sample validation against ignored raw API
|
|
134
150
|
captures
|
|
@@ -32,6 +32,7 @@ in the development examples below.
|
|
|
32
32
|
- asynchronous communication via `aiohttp`
|
|
33
33
|
- typed stable config families for the documented `/config` branches
|
|
34
34
|
- typed helpers for stable `/info` fields such as heat recovery filter time
|
|
35
|
+
- a typed overview for selected values from one unfiltered `/info` request
|
|
35
36
|
- natural empty results for optional capability discovery and explicit errors
|
|
36
37
|
for strict capability access
|
|
37
38
|
- typed models that stay close to the API response shape
|
|
@@ -65,6 +66,17 @@ pre-0.13 raw status string remains compatible and derives `raw_status`
|
|
|
65
66
|
automatically; callers using a normalized `DiagStatus` must provide
|
|
66
67
|
`raw_status` explicitly.
|
|
67
68
|
|
|
69
|
+
`async_get_info_overview()` combines RSSI, diagnostic subsystems, heat recovery
|
|
70
|
+
filter time, and ventilation temperatures from one `GET /info` request. Missing
|
|
71
|
+
product-specific modules produce their natural empty values. Unlike most typed
|
|
72
|
+
models, `InfoOverview` does not retain the broad response or the LAN raw
|
|
73
|
+
payload, because that response can contain network credentials such as the
|
|
74
|
+
Wi-Fi access point key.
|
|
75
|
+
|
|
76
|
+
`async_set_node_identify(node_id, identify)` exposes the node `SetIdentify`
|
|
77
|
+
action with an explicit Boolean state. The helper raises `DucoActionError` when
|
|
78
|
+
the box returns an unsuccessful action result.
|
|
79
|
+
|
|
68
80
|
## Getting started
|
|
69
81
|
|
|
70
82
|
```python
|
|
@@ -79,9 +91,11 @@ async def main() -> None:
|
|
|
79
91
|
async with aiohttp.ClientSession() as session:
|
|
80
92
|
client = DucoClient(session, "192.168.1.10")
|
|
81
93
|
api_info = await client.async_get_api_info()
|
|
94
|
+
info = await client.async_get_info_overview()
|
|
82
95
|
nodes = await client.async_get_nodes_overview()
|
|
83
96
|
|
|
84
97
|
print(api_info.public_api_version)
|
|
98
|
+
print(info.rssi_wifi)
|
|
85
99
|
print([node.node_id for node in nodes])
|
|
86
100
|
|
|
87
101
|
|
|
@@ -97,6 +111,8 @@ public client methods, exports, compatibility aliases, and construction rules.
|
|
|
97
111
|
- `docs/api-reference.md` for the central public API inventory
|
|
98
112
|
- `docs/cli.md` for the function probe CLI and shell examples
|
|
99
113
|
- `docs/config.md` for system, node, and zone config reads and writes
|
|
114
|
+
- `docs/endpoint-inventory.md` for the Public API 2.5 read routes and observed
|
|
115
|
+
response shapes across tested Duco products
|
|
100
116
|
- `docs/live-testing.md` for local opt-in tests against a real Duco device
|
|
101
117
|
- `docs/replay-testing.md` for local sample validation against ignored raw API
|
|
102
118
|
captures
|
|
@@ -4,6 +4,7 @@ from importlib.metadata import PackageNotFoundError, version
|
|
|
4
4
|
|
|
5
5
|
from .client import DucoClient
|
|
6
6
|
from .exceptions import (
|
|
7
|
+
DucoActionError,
|
|
7
8
|
DucoConnectionError,
|
|
8
9
|
DucoError,
|
|
9
10
|
DucoRateLimitError,
|
|
@@ -62,6 +63,7 @@ from .models import (
|
|
|
62
63
|
InfoGroup,
|
|
63
64
|
InfoGroupStruct,
|
|
64
65
|
InfoModuleSelector,
|
|
66
|
+
InfoOverview,
|
|
65
67
|
InfoZone,
|
|
66
68
|
InfoZoneGroup,
|
|
67
69
|
InfoZonesOverview,
|
|
@@ -169,6 +171,7 @@ __all__ = [
|
|
|
169
171
|
"DiagComponent",
|
|
170
172
|
"DiagInfo",
|
|
171
173
|
"DiagStatus",
|
|
174
|
+
"DucoActionError",
|
|
172
175
|
"DucoClient",
|
|
173
176
|
"DucoConnectionError",
|
|
174
177
|
"DucoError",
|
|
@@ -183,6 +186,7 @@ __all__ = [
|
|
|
183
186
|
"InfoGroup",
|
|
184
187
|
"InfoGroupStruct",
|
|
185
188
|
"InfoModuleSelector",
|
|
189
|
+
"InfoOverview",
|
|
186
190
|
"InfoZone",
|
|
187
191
|
"InfoZoneGroup",
|
|
188
192
|
"InfoZoneStruct",
|
{python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/duco_connectivity/cli.py
RENAMED
|
@@ -76,6 +76,9 @@ METHOD_SPECS: dict[str, MethodSpec] = {
|
|
|
76
76
|
description="Return the typed response from /config/zones/{zone}.",
|
|
77
77
|
),
|
|
78
78
|
"async_get_board_info": MethodSpec(description="Return board identity details."),
|
|
79
|
+
"async_get_info_overview": MethodSpec(
|
|
80
|
+
description="Return selected typed values from one unfiltered /info request."
|
|
81
|
+
),
|
|
79
82
|
"async_get_lan_info": MethodSpec(description="Return LAN settings."),
|
|
80
83
|
"async_get_diagnostics_info": MethodSpec(
|
|
81
84
|
description="Return the typed diagnostics response from /info?module=Diag."
|
{python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/duco_connectivity/client.py
RENAMED
|
@@ -13,6 +13,7 @@ from urllib.parse import urlsplit
|
|
|
13
13
|
import aiohttp
|
|
14
14
|
|
|
15
15
|
from .exceptions import (
|
|
16
|
+
DucoActionError,
|
|
16
17
|
DucoConnectionError,
|
|
17
18
|
DucoError,
|
|
18
19
|
DucoResponseError,
|
|
@@ -63,10 +64,12 @@ from .models import (
|
|
|
63
64
|
InfoGroup,
|
|
64
65
|
InfoGroupStruct,
|
|
65
66
|
InfoModuleSelector,
|
|
67
|
+
InfoOverview,
|
|
66
68
|
InfoZone,
|
|
67
69
|
InfoZoneGroup,
|
|
68
70
|
InfoZonesOverview,
|
|
69
71
|
InfoZoneStruct,
|
|
72
|
+
KnownActionName,
|
|
70
73
|
LanInfo,
|
|
71
74
|
NetworkType,
|
|
72
75
|
Node,
|
|
@@ -2052,6 +2055,50 @@ class DucoClient:
|
|
|
2052
2055
|
raw_payload=self._preserve_raw_payload(board),
|
|
2053
2056
|
)
|
|
2054
2057
|
|
|
2058
|
+
@classmethod
|
|
2059
|
+
def _parse_info_overview(cls, payload: Any) -> InfoOverview:
|
|
2060
|
+
"""Parse selected values from an unfiltered `/info` payload."""
|
|
2061
|
+
if not isinstance(payload, dict):
|
|
2062
|
+
msg = f"Expected object payload from /info, got {type(payload).__name__}"
|
|
2063
|
+
raise DucoError(msg)
|
|
2064
|
+
|
|
2065
|
+
rssi_wifi = None
|
|
2066
|
+
general = payload.get("General")
|
|
2067
|
+
if general is not None:
|
|
2068
|
+
if not isinstance(general, dict):
|
|
2069
|
+
msg = (
|
|
2070
|
+
"Expected object payload at General in /info response, got "
|
|
2071
|
+
f"{type(general).__name__}"
|
|
2072
|
+
)
|
|
2073
|
+
raise DucoError(msg)
|
|
2074
|
+
lan = general.get("Lan")
|
|
2075
|
+
if lan is not None:
|
|
2076
|
+
if not isinstance(lan, dict):
|
|
2077
|
+
msg = (
|
|
2078
|
+
"Expected object payload at General.Lan in /info response, got "
|
|
2079
|
+
f"{type(lan).__name__}"
|
|
2080
|
+
)
|
|
2081
|
+
raise DucoError(msg)
|
|
2082
|
+
rssi_wifi = cls._read_optional_wrapped_int(
|
|
2083
|
+
lan,
|
|
2084
|
+
"RssiWifi",
|
|
2085
|
+
path="General.Lan",
|
|
2086
|
+
)
|
|
2087
|
+
|
|
2088
|
+
return InfoOverview(
|
|
2089
|
+
rssi_wifi=rssi_wifi,
|
|
2090
|
+
diagnostic_subsystems=cls._parse_diag_info(payload).diagnostic_subsystems,
|
|
2091
|
+
time_filter_remain=cls._parse_time_filter_remaining(payload, request_context="/info"),
|
|
2092
|
+
ventilation_temperatures=cls._parse_ventilation_temperature_info(
|
|
2093
|
+
payload, request_context="/info"
|
|
2094
|
+
),
|
|
2095
|
+
)
|
|
2096
|
+
|
|
2097
|
+
async def async_get_info_overview(self) -> InfoOverview:
|
|
2098
|
+
"""Return selected typed values from one unfiltered `/info` request."""
|
|
2099
|
+
payload = await self._request_json("GET", "/info")
|
|
2100
|
+
return self._parse_info_overview(payload)
|
|
2101
|
+
|
|
2055
2102
|
async def async_get_lan_info(self) -> LanInfo:
|
|
2056
2103
|
"""Return LAN settings reported by the box."""
|
|
2057
2104
|
payload = await self.async_get_info(
|
|
@@ -2258,31 +2305,36 @@ class DucoClient:
|
|
|
2258
2305
|
return None
|
|
2259
2306
|
raise
|
|
2260
2307
|
|
|
2308
|
+
return self._parse_time_filter_remaining(payload)
|
|
2309
|
+
|
|
2310
|
+
@classmethod
|
|
2311
|
+
def _parse_time_filter_remaining(
|
|
2312
|
+
cls,
|
|
2313
|
+
payload: Any,
|
|
2314
|
+
*,
|
|
2315
|
+
request_context: str = "/info?module=HeatRecovery",
|
|
2316
|
+
) -> int | None:
|
|
2317
|
+
"""Parse remaining heat recovery filter time from an info payload."""
|
|
2318
|
+
|
|
2261
2319
|
if not isinstance(payload, dict):
|
|
2262
|
-
msg = (
|
|
2263
|
-
"Expected object payload from /info?module=HeatRecovery, got "
|
|
2264
|
-
f"{type(payload).__name__}"
|
|
2265
|
-
)
|
|
2320
|
+
msg = f"Expected object payload from {request_context}, got {type(payload).__name__}"
|
|
2266
2321
|
raise DucoError(msg)
|
|
2267
2322
|
|
|
2268
2323
|
heat_recovery = payload.get("HeatRecovery")
|
|
2269
2324
|
if heat_recovery is None:
|
|
2270
2325
|
return None
|
|
2271
2326
|
if not isinstance(heat_recovery, dict):
|
|
2272
|
-
msg = "Expected object payload at HeatRecovery in
|
|
2327
|
+
msg = f"Expected object payload at HeatRecovery in {request_context} response"
|
|
2273
2328
|
raise DucoError(msg)
|
|
2274
2329
|
|
|
2275
2330
|
general = heat_recovery.get("General")
|
|
2276
2331
|
if general is None:
|
|
2277
2332
|
return None
|
|
2278
2333
|
if not isinstance(general, dict):
|
|
2279
|
-
msg =
|
|
2280
|
-
"Expected object payload at HeatRecovery.General in "
|
|
2281
|
-
"/info?module=HeatRecovery response"
|
|
2282
|
-
)
|
|
2334
|
+
msg = f"Expected object payload at HeatRecovery.General in {request_context} response"
|
|
2283
2335
|
raise DucoError(msg)
|
|
2284
2336
|
|
|
2285
|
-
return
|
|
2337
|
+
return cls._read_optional_wrapped_int(
|
|
2286
2338
|
general,
|
|
2287
2339
|
"TimeFilterRemain",
|
|
2288
2340
|
path="HeatRecovery.General",
|
|
@@ -2297,40 +2349,46 @@ class DucoClient:
|
|
|
2297
2349
|
return VentilationTemperatureInfo()
|
|
2298
2350
|
raise
|
|
2299
2351
|
|
|
2352
|
+
return self._parse_ventilation_temperature_info(payload)
|
|
2353
|
+
|
|
2354
|
+
@classmethod
|
|
2355
|
+
def _parse_ventilation_temperature_info(
|
|
2356
|
+
cls,
|
|
2357
|
+
payload: Any,
|
|
2358
|
+
*,
|
|
2359
|
+
request_context: str = "/info?module=Ventilation",
|
|
2360
|
+
) -> VentilationTemperatureInfo:
|
|
2361
|
+
"""Parse ventilation temperatures from an info payload."""
|
|
2362
|
+
|
|
2300
2363
|
if not isinstance(payload, dict):
|
|
2301
|
-
msg = (
|
|
2302
|
-
"Expected object payload from /info?module=Ventilation, got "
|
|
2303
|
-
f"{type(payload).__name__}"
|
|
2304
|
-
)
|
|
2364
|
+
msg = f"Expected object payload from {request_context}, got {type(payload).__name__}"
|
|
2305
2365
|
raise DucoError(msg)
|
|
2306
2366
|
|
|
2307
2367
|
ventilation = payload.get("Ventilation")
|
|
2308
2368
|
if ventilation is None:
|
|
2309
2369
|
return VentilationTemperatureInfo()
|
|
2310
2370
|
if not isinstance(ventilation, dict):
|
|
2311
|
-
msg = "Expected object payload at Ventilation in
|
|
2371
|
+
msg = f"Expected object payload at Ventilation in {request_context} response"
|
|
2312
2372
|
raise DucoError(msg)
|
|
2313
2373
|
|
|
2314
2374
|
sensor = ventilation.get("Sensor")
|
|
2315
2375
|
if sensor is None:
|
|
2316
|
-
return VentilationTemperatureInfo(raw_payload=
|
|
2376
|
+
return VentilationTemperatureInfo(raw_payload=cls._preserve_raw_payload(ventilation))
|
|
2317
2377
|
if not isinstance(sensor, dict):
|
|
2318
|
-
msg =
|
|
2319
|
-
"Expected object payload at Ventilation.Sensor in /info?module=Ventilation response"
|
|
2320
|
-
)
|
|
2378
|
+
msg = f"Expected object payload at Ventilation.Sensor in {request_context} response"
|
|
2321
2379
|
raise DucoError(msg)
|
|
2322
2380
|
|
|
2323
|
-
temp_oda =
|
|
2324
|
-
temp_sup =
|
|
2325
|
-
temp_eta =
|
|
2326
|
-
temp_eha =
|
|
2381
|
+
temp_oda = cls._read_optional_wrapped_int(sensor, "TempOda", path="Ventilation.Sensor")
|
|
2382
|
+
temp_sup = cls._read_optional_wrapped_int(sensor, "TempSup", path="Ventilation.Sensor")
|
|
2383
|
+
temp_eta = cls._read_optional_wrapped_int(sensor, "TempEta", path="Ventilation.Sensor")
|
|
2384
|
+
temp_eha = cls._read_optional_wrapped_int(sensor, "TempEha", path="Ventilation.Sensor")
|
|
2327
2385
|
|
|
2328
2386
|
return VentilationTemperatureInfo(
|
|
2329
|
-
temp_oda=None if temp_oda is None else
|
|
2330
|
-
temp_sup=None if temp_sup is None else
|
|
2331
|
-
temp_eta=None if temp_eta is None else
|
|
2332
|
-
temp_eha=None if temp_eha is None else
|
|
2333
|
-
raw_payload=
|
|
2387
|
+
temp_oda=None if temp_oda is None else cls._decicelsius_to_celsius(temp_oda),
|
|
2388
|
+
temp_sup=None if temp_sup is None else cls._decicelsius_to_celsius(temp_sup),
|
|
2389
|
+
temp_eta=None if temp_eta is None else cls._decicelsius_to_celsius(temp_eta),
|
|
2390
|
+
temp_eha=None if temp_eha is None else cls._decicelsius_to_celsius(temp_eha),
|
|
2391
|
+
raw_payload=cls._preserve_raw_payload(sensor),
|
|
2334
2392
|
)
|
|
2335
2393
|
|
|
2336
2394
|
async def async_get_bypass_supply_temperature_target(
|
|
@@ -2446,6 +2504,22 @@ class DucoClient:
|
|
|
2446
2504
|
val=state_value,
|
|
2447
2505
|
)
|
|
2448
2506
|
|
|
2507
|
+
async def async_set_node_identify(self, node_id: int, identify: bool) -> None:
|
|
2508
|
+
"""Set the identify state for a node."""
|
|
2509
|
+
action = KnownActionName.SET_IDENTIFY
|
|
2510
|
+
result = await self.async_set_node_action(
|
|
2511
|
+
node_id=node_id,
|
|
2512
|
+
action=action,
|
|
2513
|
+
val=identify,
|
|
2514
|
+
)
|
|
2515
|
+
if result.result is not ActionResultStatus.SUCCESS:
|
|
2516
|
+
raise DucoActionError(
|
|
2517
|
+
action=action,
|
|
2518
|
+
result=result.result,
|
|
2519
|
+
code=result.code,
|
|
2520
|
+
message=result.message,
|
|
2521
|
+
)
|
|
2522
|
+
|
|
2449
2523
|
async def async_set_node_action(
|
|
2450
2524
|
self,
|
|
2451
2525
|
node_id: int,
|
|
@@ -5,6 +5,28 @@ class DucoError(Exception):
|
|
|
5
5
|
"""Base class for client errors."""
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
class DucoActionError(DucoError):
|
|
9
|
+
"""Raised when the box reports an unsuccessful action result."""
|
|
10
|
+
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
action: str,
|
|
14
|
+
result: str,
|
|
15
|
+
code: int | None = None,
|
|
16
|
+
message: str | None = None,
|
|
17
|
+
) -> None:
|
|
18
|
+
self.action = action
|
|
19
|
+
self.result = result
|
|
20
|
+
self.code = code
|
|
21
|
+
self.message = message
|
|
22
|
+
detail = f"Duco action {action} returned {result}"
|
|
23
|
+
if code is not None:
|
|
24
|
+
detail = f"{detail} (code {code})"
|
|
25
|
+
if message:
|
|
26
|
+
detail = f"{detail}: {message}"
|
|
27
|
+
super().__init__(detail)
|
|
28
|
+
|
|
29
|
+
|
|
8
30
|
class DucoConnectionError(DucoError):
|
|
9
31
|
"""Raised when the client cannot reach the box."""
|
|
10
32
|
|
{python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/duco_connectivity/models.py
RENAMED
|
@@ -1676,6 +1676,18 @@ class DiagInfo:
|
|
|
1676
1676
|
raw_payload: dict[str, Any] = field(default_factory=dict, repr=False, compare=False)
|
|
1677
1677
|
|
|
1678
1678
|
|
|
1679
|
+
@dataclass(frozen=True, slots=True)
|
|
1680
|
+
class InfoOverview:
|
|
1681
|
+
"""Selected typed values returned by an unfiltered `/info` request."""
|
|
1682
|
+
|
|
1683
|
+
rssi_wifi: int | None = None
|
|
1684
|
+
diagnostic_subsystems: tuple[DiagComponent, ...] = ()
|
|
1685
|
+
time_filter_remain: int | None = None
|
|
1686
|
+
ventilation_temperatures: VentilationTemperatureInfo = field(
|
|
1687
|
+
default_factory=VentilationTemperatureInfo
|
|
1688
|
+
)
|
|
1689
|
+
|
|
1690
|
+
|
|
1679
1691
|
@dataclass(frozen=True, slots=True, init=False)
|
|
1680
1692
|
class Action:
|
|
1681
1693
|
"""System action request payload."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-duco-connectivity
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.17.0
|
|
4
4
|
Summary: Async HTTP client for the local Duco Connectivity API
|
|
5
5
|
Author: Ronald van der Meer
|
|
6
6
|
License-Expression: MIT
|
|
@@ -64,6 +64,7 @@ in the development examples below.
|
|
|
64
64
|
- asynchronous communication via `aiohttp`
|
|
65
65
|
- typed stable config families for the documented `/config` branches
|
|
66
66
|
- typed helpers for stable `/info` fields such as heat recovery filter time
|
|
67
|
+
- a typed overview for selected values from one unfiltered `/info` request
|
|
67
68
|
- natural empty results for optional capability discovery and explicit errors
|
|
68
69
|
for strict capability access
|
|
69
70
|
- typed models that stay close to the API response shape
|
|
@@ -97,6 +98,17 @@ pre-0.13 raw status string remains compatible and derives `raw_status`
|
|
|
97
98
|
automatically; callers using a normalized `DiagStatus` must provide
|
|
98
99
|
`raw_status` explicitly.
|
|
99
100
|
|
|
101
|
+
`async_get_info_overview()` combines RSSI, diagnostic subsystems, heat recovery
|
|
102
|
+
filter time, and ventilation temperatures from one `GET /info` request. Missing
|
|
103
|
+
product-specific modules produce their natural empty values. Unlike most typed
|
|
104
|
+
models, `InfoOverview` does not retain the broad response or the LAN raw
|
|
105
|
+
payload, because that response can contain network credentials such as the
|
|
106
|
+
Wi-Fi access point key.
|
|
107
|
+
|
|
108
|
+
`async_set_node_identify(node_id, identify)` exposes the node `SetIdentify`
|
|
109
|
+
action with an explicit Boolean state. The helper raises `DucoActionError` when
|
|
110
|
+
the box returns an unsuccessful action result.
|
|
111
|
+
|
|
100
112
|
## Getting started
|
|
101
113
|
|
|
102
114
|
```python
|
|
@@ -111,9 +123,11 @@ async def main() -> None:
|
|
|
111
123
|
async with aiohttp.ClientSession() as session:
|
|
112
124
|
client = DucoClient(session, "192.168.1.10")
|
|
113
125
|
api_info = await client.async_get_api_info()
|
|
126
|
+
info = await client.async_get_info_overview()
|
|
114
127
|
nodes = await client.async_get_nodes_overview()
|
|
115
128
|
|
|
116
129
|
print(api_info.public_api_version)
|
|
130
|
+
print(info.rssi_wifi)
|
|
117
131
|
print([node.node_id for node in nodes])
|
|
118
132
|
|
|
119
133
|
|
|
@@ -129,6 +143,8 @@ public client methods, exports, compatibility aliases, and construction rules.
|
|
|
129
143
|
- `docs/api-reference.md` for the central public API inventory
|
|
130
144
|
- `docs/cli.md` for the function probe CLI and shell examples
|
|
131
145
|
- `docs/config.md` for system, node, and zone config reads and writes
|
|
146
|
+
- `docs/endpoint-inventory.md` for the Public API 2.5 read routes and observed
|
|
147
|
+
response shapes across tested Duco products
|
|
132
148
|
- `docs/live-testing.md` for local opt-in tests against a real Duco device
|
|
133
149
|
- `docs/replay-testing.md` for local sample validation against ignored raw API
|
|
134
150
|
captures
|
{python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/tests/test_api_reference.py
RENAMED
|
@@ -56,6 +56,7 @@ def test_collect_public_symbols_groups_known_exports() -> None:
|
|
|
56
56
|
assert "VentilationState" in symbols["Enums"]
|
|
57
57
|
assert "InfoModuleSelector" in symbols["Enums"]
|
|
58
58
|
assert "ConfigZone" in symbols["Models"]
|
|
59
|
+
assert "DucoActionError" in symbols["Exceptions"]
|
|
59
60
|
assert "DucoWriteLimitError" in symbols["Exceptions"]
|
|
60
61
|
assert symbols["Compatibility exports"] == ["ApiEndpointInfo", "DucoRateLimitError"]
|
|
61
62
|
assert symbols["Other"] == ["__version__"]
|
|
@@ -13,6 +13,7 @@ from duco_connectivity import (
|
|
|
13
13
|
ActionEnumValue,
|
|
14
14
|
ActionItem,
|
|
15
15
|
ActionName,
|
|
16
|
+
ActionResult,
|
|
16
17
|
ActionResultStatus,
|
|
17
18
|
ActionValueType,
|
|
18
19
|
BoardName,
|
|
@@ -43,6 +44,7 @@ from duco_connectivity import (
|
|
|
43
44
|
DiagComponent,
|
|
44
45
|
DiagInfo,
|
|
45
46
|
DiagStatus,
|
|
47
|
+
DucoActionError,
|
|
46
48
|
DucoClient,
|
|
47
49
|
DucoConnectionError,
|
|
48
50
|
DucoError,
|
|
@@ -55,10 +57,12 @@ from duco_connectivity import (
|
|
|
55
57
|
InfoGeneralSubmoduleSelector,
|
|
56
58
|
InfoGroup,
|
|
57
59
|
InfoModuleSelector,
|
|
60
|
+
InfoOverview,
|
|
58
61
|
InfoZone,
|
|
59
62
|
InfoZoneGroup,
|
|
60
63
|
InfoZonesOverview,
|
|
61
64
|
IpAddress,
|
|
65
|
+
KnownActionName,
|
|
62
66
|
KnownBoardName,
|
|
63
67
|
KnownLanMode,
|
|
64
68
|
LanMode,
|
|
@@ -2004,6 +2008,127 @@ async def test_lan_info_wifi_is_parsed(lan_info_data: dict[str, object]) -> None
|
|
|
2004
2008
|
assert lan.raw_payload is lan_info_data["General"]["Lan"]
|
|
2005
2009
|
|
|
2006
2010
|
|
|
2011
|
+
async def test_info_overview_parses_supported_data_without_sensitive_raw_payload(
|
|
2012
|
+
generic_info_all_data: dict[str, object],
|
|
2013
|
+
) -> None:
|
|
2014
|
+
"""The broad info overview should expose only its typed public contract."""
|
|
2015
|
+
mock_response = _response(json_payload=generic_info_all_data)
|
|
2016
|
+
|
|
2017
|
+
async with aiohttp.ClientSession() as session:
|
|
2018
|
+
client = DucoClient(session=session, host="192.0.2.94")
|
|
2019
|
+
with patch.object(session, "request", _request(mock_response)) as request_mock:
|
|
2020
|
+
overview = await client.async_get_info_overview()
|
|
2021
|
+
|
|
2022
|
+
assert isinstance(overview, InfoOverview)
|
|
2023
|
+
assert_type(overview, InfoOverview)
|
|
2024
|
+
assert overview.rssi_wifi == -47
|
|
2025
|
+
assert tuple(subsystem.component for subsystem in overview.diagnostic_subsystems) == (
|
|
2026
|
+
"Ventilation",
|
|
2027
|
+
"VentCool",
|
|
2028
|
+
"SunCtrl",
|
|
2029
|
+
)
|
|
2030
|
+
assert overview.time_filter_remain is None
|
|
2031
|
+
assert overview.ventilation_temperatures == VentilationTemperatureInfo()
|
|
2032
|
+
assert not hasattr(overview, "raw_payload")
|
|
2033
|
+
assert request_mock.call_args.args == ("GET", "http://192.0.2.94/info")
|
|
2034
|
+
|
|
2035
|
+
|
|
2036
|
+
async def test_info_overview_parses_energy_modules() -> None:
|
|
2037
|
+
"""The broad info overview should combine all supported ENERGY data."""
|
|
2038
|
+
payload: dict[str, object] = {
|
|
2039
|
+
"General": {
|
|
2040
|
+
"Lan": {
|
|
2041
|
+
"WifiApKey": {"Val": "secret"},
|
|
2042
|
+
"RssiWifi": {"Val": -51},
|
|
2043
|
+
}
|
|
2044
|
+
},
|
|
2045
|
+
"Diag": {
|
|
2046
|
+
"SubSystems": [
|
|
2047
|
+
{"Component": "Ventilation", "Status": "Ok"},
|
|
2048
|
+
]
|
|
2049
|
+
},
|
|
2050
|
+
"HeatRecovery": {
|
|
2051
|
+
"General": {"TimeFilterRemain": {"Val": 7200}},
|
|
2052
|
+
},
|
|
2053
|
+
"Ventilation": {
|
|
2054
|
+
"Sensor": {
|
|
2055
|
+
"TempOda": {"Val": 175},
|
|
2056
|
+
"TempSup": {"Val": 180},
|
|
2057
|
+
"TempEta": {"Val": 215},
|
|
2058
|
+
"TempEha": {"Val": 225},
|
|
2059
|
+
}
|
|
2060
|
+
},
|
|
2061
|
+
}
|
|
2062
|
+
mock_response = _response(json_payload=payload)
|
|
2063
|
+
|
|
2064
|
+
async with aiohttp.ClientSession() as session:
|
|
2065
|
+
client = DucoClient(session=session, host="192.0.2.94")
|
|
2066
|
+
with patch.object(session, "request", _request(mock_response)):
|
|
2067
|
+
overview = await client.async_get_info_overview()
|
|
2068
|
+
|
|
2069
|
+
assert overview.rssi_wifi == -51
|
|
2070
|
+
assert overview.diagnostic_subsystems[0].status is DiagStatus.OK
|
|
2071
|
+
assert overview.time_filter_remain == 7200
|
|
2072
|
+
assert overview.ventilation_temperatures == VentilationTemperatureInfo(
|
|
2073
|
+
temp_oda=17.5,
|
|
2074
|
+
temp_sup=18.0,
|
|
2075
|
+
temp_eta=21.5,
|
|
2076
|
+
temp_eha=22.5,
|
|
2077
|
+
)
|
|
2078
|
+
assert "WifiApKey" not in repr(overview)
|
|
2079
|
+
|
|
2080
|
+
|
|
2081
|
+
@pytest.mark.parametrize(
|
|
2082
|
+
("payload", "message"),
|
|
2083
|
+
[
|
|
2084
|
+
pytest.param(
|
|
2085
|
+
[],
|
|
2086
|
+
"Expected object payload from /info, got list",
|
|
2087
|
+
id="top-level",
|
|
2088
|
+
),
|
|
2089
|
+
pytest.param(
|
|
2090
|
+
{"General": []},
|
|
2091
|
+
"Expected object payload at General in /info response, got list",
|
|
2092
|
+
id="general",
|
|
2093
|
+
),
|
|
2094
|
+
pytest.param(
|
|
2095
|
+
{"General": {"Lan": []}},
|
|
2096
|
+
"Expected object payload at General.Lan in /info response, got list",
|
|
2097
|
+
id="lan",
|
|
2098
|
+
),
|
|
2099
|
+
pytest.param(
|
|
2100
|
+
{"General": {"Lan": {"RssiWifi": {"Val": "strong"}}}},
|
|
2101
|
+
"Expected integer value for General.Lan.RssiWifi, got str",
|
|
2102
|
+
id="rssi",
|
|
2103
|
+
),
|
|
2104
|
+
pytest.param(
|
|
2105
|
+
{"HeatRecovery": []},
|
|
2106
|
+
"Expected object payload at HeatRecovery in /info response",
|
|
2107
|
+
id="heat-recovery",
|
|
2108
|
+
),
|
|
2109
|
+
pytest.param(
|
|
2110
|
+
{"Ventilation": []},
|
|
2111
|
+
"Expected object payload at Ventilation in /info response",
|
|
2112
|
+
id="ventilation",
|
|
2113
|
+
),
|
|
2114
|
+
],
|
|
2115
|
+
)
|
|
2116
|
+
async def test_info_overview_rejects_malformed_payloads(
|
|
2117
|
+
payload: object,
|
|
2118
|
+
message: str,
|
|
2119
|
+
) -> None:
|
|
2120
|
+
"""Present malformed overview sections should fail with field context."""
|
|
2121
|
+
mock_response = _response(json_payload=payload)
|
|
2122
|
+
|
|
2123
|
+
async with aiohttp.ClientSession() as session:
|
|
2124
|
+
client = DucoClient(session=session, host="192.0.2.94")
|
|
2125
|
+
with (
|
|
2126
|
+
patch.object(session, "request", _request(mock_response)),
|
|
2127
|
+
pytest.raises(DucoError, match=re.escape(message)),
|
|
2128
|
+
):
|
|
2129
|
+
await client.async_get_info_overview()
|
|
2130
|
+
|
|
2131
|
+
|
|
2007
2132
|
async def test_lan_info_ethernet_is_parsed(
|
|
2008
2133
|
lan_info_ethernet_data: dict[str, object],
|
|
2009
2134
|
) -> None:
|
|
@@ -5111,6 +5236,75 @@ async def test_set_ventilation_state_delegates_to_generic_node_action() -> None:
|
|
|
5111
5236
|
)
|
|
5112
5237
|
|
|
5113
5238
|
|
|
5239
|
+
@pytest.mark.parametrize("identify", [True, False])
|
|
5240
|
+
async def test_set_node_identify_delegates_to_generic_node_action(
|
|
5241
|
+
identify: bool,
|
|
5242
|
+
) -> None:
|
|
5243
|
+
"""Identify writes should use the typed Boolean node action contract."""
|
|
5244
|
+
async with aiohttp.ClientSession() as session:
|
|
5245
|
+
client = DucoClient(session=session, host="192.0.2.94")
|
|
5246
|
+
with patch.object(
|
|
5247
|
+
client,
|
|
5248
|
+
"async_set_node_action",
|
|
5249
|
+
AsyncMock(return_value=ActionResult(result=ActionResultStatus.SUCCESS)),
|
|
5250
|
+
) as set_node_action:
|
|
5251
|
+
await client.async_set_node_identify(1, identify)
|
|
5252
|
+
|
|
5253
|
+
set_node_action.assert_awaited_once_with(
|
|
5254
|
+
node_id=1,
|
|
5255
|
+
action=KnownActionName.SET_IDENTIFY,
|
|
5256
|
+
val=identify,
|
|
5257
|
+
)
|
|
5258
|
+
|
|
5259
|
+
|
|
5260
|
+
async def test_set_node_identify_uses_boolean_json_body() -> None:
|
|
5261
|
+
"""Identify writes should send an explicit JSON Boolean value."""
|
|
5262
|
+
mock_response = _response(json_payload={"Result": "SUCCESS"})
|
|
5263
|
+
|
|
5264
|
+
async with aiohttp.ClientSession() as session:
|
|
5265
|
+
client = DucoClient(session=session, host="192.0.2.94")
|
|
5266
|
+
request = MagicMock(return_value=_request_context(mock_response))
|
|
5267
|
+
with patch.object(session, "request", request):
|
|
5268
|
+
await client.async_set_node_identify(1, True)
|
|
5269
|
+
|
|
5270
|
+
_, kwargs = request.call_args
|
|
5271
|
+
assert kwargs["data"] == b'{"Action":"SetIdentify","Val":true}'
|
|
5272
|
+
assert kwargs["headers"] == {"Content-Type": "application/json"}
|
|
5273
|
+
|
|
5274
|
+
|
|
5275
|
+
@pytest.mark.parametrize(
|
|
5276
|
+
"result_status",
|
|
5277
|
+
[ActionResultStatus.FAILED, ActionResultStatus.UNKNOWN],
|
|
5278
|
+
)
|
|
5279
|
+
async def test_set_node_identify_raises_for_unsuccessful_result(
|
|
5280
|
+
result_status: ActionResultStatus,
|
|
5281
|
+
) -> None:
|
|
5282
|
+
"""Identify writes should raise when the API does not report success."""
|
|
5283
|
+
async with aiohttp.ClientSession() as session:
|
|
5284
|
+
client = DucoClient(session=session, host="192.0.2.94")
|
|
5285
|
+
with (
|
|
5286
|
+
patch.object(
|
|
5287
|
+
client,
|
|
5288
|
+
"async_set_node_action",
|
|
5289
|
+
AsyncMock(
|
|
5290
|
+
return_value=ActionResult(
|
|
5291
|
+
result=result_status,
|
|
5292
|
+
code=12,
|
|
5293
|
+
message="Action is not performed",
|
|
5294
|
+
)
|
|
5295
|
+
),
|
|
5296
|
+
),
|
|
5297
|
+
pytest.raises(
|
|
5298
|
+
DucoActionError,
|
|
5299
|
+
match=(
|
|
5300
|
+
rf"Duco action SetIdentify returned {result_status} "
|
|
5301
|
+
r"\(code 12\): Action is not performed"
|
|
5302
|
+
),
|
|
5303
|
+
),
|
|
5304
|
+
):
|
|
5305
|
+
await client.async_set_node_identify(1, True)
|
|
5306
|
+
|
|
5307
|
+
|
|
5114
5308
|
async def test_set_ventilation_state_uses_compact_json_body() -> None:
|
|
5115
5309
|
"""Write requests should use compact JSON with explicit content type."""
|
|
5116
5310
|
mock_response = _response(json_payload={"Result": "SUCCESS"})
|
{python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/tests/test_exceptions.py
RENAMED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import pytest
|
|
4
4
|
|
|
5
5
|
from duco_connectivity import (
|
|
6
|
+
DucoActionError,
|
|
6
7
|
DucoConnectionError,
|
|
7
8
|
DucoError,
|
|
8
9
|
DucoRateLimitError,
|
|
@@ -12,6 +13,25 @@ from duco_connectivity import (
|
|
|
12
13
|
)
|
|
13
14
|
|
|
14
15
|
|
|
16
|
+
def test_action_error_exposes_result_context() -> None:
|
|
17
|
+
"""DucoActionError should expose the unsuccessful action result."""
|
|
18
|
+
err = DucoActionError(
|
|
19
|
+
action="SetIdentify",
|
|
20
|
+
result="FAILED",
|
|
21
|
+
code=12,
|
|
22
|
+
message="Action is not performed",
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
assert err.action == "SetIdentify"
|
|
26
|
+
assert err.result == "FAILED"
|
|
27
|
+
assert err.code == 12
|
|
28
|
+
assert err.message == "Action is not performed"
|
|
29
|
+
assert str(err) == (
|
|
30
|
+
"Duco action SetIdentify returned FAILED (code 12): Action is not performed"
|
|
31
|
+
)
|
|
32
|
+
assert isinstance(err, DucoError)
|
|
33
|
+
|
|
34
|
+
|
|
15
35
|
def test_connection_error_inherits_from_base_error() -> None:
|
|
16
36
|
"""DucoConnectionError should remain catchable as DucoError."""
|
|
17
37
|
err = DucoConnectionError("unreachable")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/src/duco_connectivity/py.typed
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
|
{python_duco_connectivity-0.15.0 → python_duco_connectivity-0.17.0}/tests/test_replay_helpers.py
RENAMED
|
File without changes
|