dimplex-controller 0.11.0__tar.gz → 0.13.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.
- {dimplex_controller-0.11.0 → dimplex_controller-0.13.0}/PKG-INFO +45 -14
- {dimplex_controller-0.11.0 → dimplex_controller-0.13.0}/README.md +44 -13
- {dimplex_controller-0.11.0 → dimplex_controller-0.13.0}/dimplex_controller/__init__.py +26 -1
- {dimplex_controller-0.11.0 → dimplex_controller-0.13.0}/dimplex_controller/auth.py +15 -1
- {dimplex_controller-0.11.0 → dimplex_controller-0.13.0}/dimplex_controller/capabilities.py +34 -6
- {dimplex_controller-0.11.0 → dimplex_controller-0.13.0}/dimplex_controller/cli.py +104 -11
- {dimplex_controller-0.11.0 → dimplex_controller-0.13.0}/dimplex_controller/client.py +416 -34
- dimplex_controller-0.13.0/dimplex_controller/const.py +49 -0
- {dimplex_controller-0.11.0 → dimplex_controller-0.13.0}/dimplex_controller/models.py +184 -29
- {dimplex_controller-0.11.0 → dimplex_controller-0.13.0}/pyproject.toml +8 -7
- dimplex_controller-0.11.0/dimplex_controller/const.py +0 -22
- {dimplex_controller-0.11.0 → dimplex_controller-0.13.0}/LICENSE +0 -0
- {dimplex_controller-0.11.0 → dimplex_controller-0.13.0}/dimplex_controller/exceptions.py +0 -0
- {dimplex_controller-0.11.0 → dimplex_controller-0.13.0}/dimplex_controller/py.typed +0 -0
- {dimplex_controller-0.11.0 → dimplex_controller-0.13.0}/dimplex_controller/telemetry.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dimplex-controller
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
4
4
|
Summary: Python client for Dimplex heating controllers (GDHV IoT)
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -27,11 +27,12 @@ Description-Content-Type: text/markdown
|
|
|
27
27
|
|
|
28
28
|
# Dimplex Controller Python Client
|
|
29
29
|
|
|
30
|
-
[](https://pypi.org/project/dimplex-controller/)
|
|
31
|
+
[](https://www.python.org/downloads/)
|
|
32
32
|
[](LICENSE)
|
|
33
|
-
[](https://github.com/KRoperUK/dimplex-controller-py/actions/workflows/test.yml)
|
|
34
|
+
[](https://pypi.org/project/dimplex-controller/)
|
|
35
|
+
[](https://buymeacoffee.com/kroperukc)
|
|
35
36
|
|
|
36
37
|
<p align="center">
|
|
37
38
|
<strong>Async Python client for controlling Glen Dimplex Heating & Ventilation (GDHV) appliances via the Dimplex cloud API.</strong>
|
|
@@ -176,21 +177,44 @@ for status in status_list:
|
|
|
176
177
|
### Sending control commands
|
|
177
178
|
|
|
178
179
|
```python
|
|
179
|
-
from dimplex_controller.models import ApplianceModeSettings
|
|
180
|
-
|
|
181
180
|
# Enable EcoStart
|
|
182
181
|
await client.set_eco_start(hub_id, [appliance_id], True)
|
|
183
182
|
|
|
184
183
|
# Enable Open Window Detection
|
|
185
184
|
await client.set_open_window_detection(hub_id, [appliance_id], True)
|
|
186
185
|
|
|
187
|
-
#
|
|
186
|
+
# Timed Boost (ApplianceModes=2, Time = minutes)
|
|
188
187
|
await client.set_boost(hub_id, [appliance_id], temperature=25.0, duration_minutes=60)
|
|
189
188
|
|
|
190
|
-
#
|
|
191
|
-
|
|
189
|
+
# Away until a given moment (ApplianceModes=4). Away is a settable 7–30 °C
|
|
190
|
+
# setback and defaults to the 7 °C anti-freeze floor.
|
|
191
|
+
from datetime import datetime, timedelta, timezone
|
|
192
|
+
|
|
193
|
+
await client.set_away(
|
|
194
|
+
hub_id,
|
|
195
|
+
[appliance_id],
|
|
196
|
+
temperature=12.0,
|
|
197
|
+
until=datetime.now(timezone.utc) + timedelta(days=3),
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
# Set the target temperature — dedicated endpoint, leaves the schedule alone
|
|
201
|
+
await client.set_appliance_setpoint_temperature(hub_id, [appliance_id], 21.5)
|
|
202
|
+
|
|
203
|
+
# Turn off the way the app does: frost protection at 7 °C
|
|
204
|
+
await client.turn_off(hub_id, [appliance_id])
|
|
192
205
|
```
|
|
193
206
|
|
|
207
|
+
> **Mode flag values matter.** `EApplianceModes` is a bitfield where Boost is `2`
|
|
208
|
+
> and Away is `4`; `16` is Advance and `32` is FrostProtect. Releases before
|
|
209
|
+
> 0.13.0 had these wrong, so Boost silently became Advance and Away became a
|
|
210
|
+
> fixed 7 °C frost hold. If you hand-build `ApplianceModeSettings`, use
|
|
211
|
+
> `ApplianceModeFlag`. See
|
|
212
|
+
> [docs/decompiled-api-reference.md](docs/decompiled-api-reference.md).
|
|
213
|
+
>
|
|
214
|
+
> **Avoid `SetTimerMode` for control.** `set_mode()` and the deprecated
|
|
215
|
+
> `set_target_temperature()` rewrite the schedule; Quantum rejects that with
|
|
216
|
+
> HTTP 403. Use `set_appliance_setpoint_temperature()` and `turn_off()`.
|
|
217
|
+
|
|
194
218
|
### Energy reports
|
|
195
219
|
|
|
196
220
|
```python
|
|
@@ -232,16 +256,23 @@ Main client class. Construct with an `aiohttp.ClientSession` and a `refresh_toke
|
|
|
232
256
|
| `get_user_context()` | Returns `UserContext`. |
|
|
233
257
|
| `get_product_models()` | Returns `list[ProductModel]` (cacheable). |
|
|
234
258
|
| `get_schedule(hub_id, appliance_id)` | Returns `TimerModeSettings` (timer + periods). |
|
|
235
|
-
| `set_mode(hub_id, appliance_id, mode)` |
|
|
236
|
-
| `set_target_temperature(hub_id, appliance_id, temp)` |
|
|
259
|
+
| `set_mode(hub_id, appliance_id, mode)` | Rewrite `TimerMode`. **403 on Quantum** — prefer `turn_off`. |
|
|
260
|
+
| `set_target_temperature(hub_id, appliance_id, temp)` | Deprecated: rewrites period setpoints. Prefer `set_appliance_setpoint_temperature`. |
|
|
261
|
+
| `set_appliance_setpoint_temperature(hub_id, appliance_ids, temperature)` | Preferred setpoint path; non-destructive. |
|
|
237
262
|
| `set_period_setpoint(...)` | Update one timer period without clobbering siblings. |
|
|
238
263
|
| `update_period(...)` | Replace a timer period matched by day + start time. |
|
|
239
|
-
| `
|
|
264
|
+
| `copy_schedule_to_appliances(...)` | Copy one appliance's schedule onto others. |
|
|
265
|
+
| `set_boost(hub_id, appliance_ids, *, temperature, duration_minutes, enable)` | Timed Boost (`ApplianceModes=2`). |
|
|
240
266
|
| `clear_boost(hub_id, appliance_ids)` | Disable Boost. |
|
|
241
|
-
| `set_away(hub_id, appliance_ids, *, temperature, enable, number_of_days)` |
|
|
267
|
+
| `set_away(hub_id, appliance_ids, *, temperature, enable, until, number_of_days)` | Away setback (`ApplianceModes=4`). |
|
|
242
268
|
| `clear_away(hub_id, appliance_ids)` | Disable Away. |
|
|
269
|
+
| `set_frost_protect(...)` / `turn_off(...)` | Frost protection at 7 °C — the app's "off". |
|
|
270
|
+
| `set_advance(...)` | Advance to the next schedule period. |
|
|
271
|
+
| `set_manual(...)` / `set_eco_mode(...)` | Manual / Eco mode holds. |
|
|
272
|
+
| `set_setback_temperature(...)` | Write the setback temperature (untested). |
|
|
243
273
|
| `set_eco_start(hub_id, appliance_ids, enable)` | Toggle EcoStart. |
|
|
244
274
|
| `set_open_window_detection(hub_id, appliance_ids, enable)` | Toggle Open Window Detection. |
|
|
275
|
+
| `set_hot_water_*(...)` / `*_heat_pump_hot_water_schedule(...)` | Hot-water cylinder surface (untested — no hardware). |
|
|
245
276
|
| `get_tsi_energy_report(hub_id, ...)` | Returns `TsiEnergyReport`. |
|
|
246
277
|
| `capabilities_for(appliance, *, status, product)` | Derive an `ApplianceCapabilities` matrix. |
|
|
247
278
|
| `export_tokens()` / `apply_tokens(bundle)` | Token persistence helpers. |
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# Dimplex Controller Python Client
|
|
2
2
|
|
|
3
|
-
[](https://pypi.org/project/dimplex-controller/)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
5
|
[](LICENSE)
|
|
6
|
-
[](https://github.com/KRoperUK/dimplex-controller-py/actions/workflows/test.yml)
|
|
7
|
+
[](https://pypi.org/project/dimplex-controller/)
|
|
8
|
+
[](https://buymeacoffee.com/kroperukc)
|
|
8
9
|
|
|
9
10
|
<p align="center">
|
|
10
11
|
<strong>Async Python client for controlling Glen Dimplex Heating & Ventilation (GDHV) appliances via the Dimplex cloud API.</strong>
|
|
@@ -149,21 +150,44 @@ for status in status_list:
|
|
|
149
150
|
### Sending control commands
|
|
150
151
|
|
|
151
152
|
```python
|
|
152
|
-
from dimplex_controller.models import ApplianceModeSettings
|
|
153
|
-
|
|
154
153
|
# Enable EcoStart
|
|
155
154
|
await client.set_eco_start(hub_id, [appliance_id], True)
|
|
156
155
|
|
|
157
156
|
# Enable Open Window Detection
|
|
158
157
|
await client.set_open_window_detection(hub_id, [appliance_id], True)
|
|
159
158
|
|
|
160
|
-
#
|
|
159
|
+
# Timed Boost (ApplianceModes=2, Time = minutes)
|
|
161
160
|
await client.set_boost(hub_id, [appliance_id], temperature=25.0, duration_minutes=60)
|
|
162
161
|
|
|
163
|
-
#
|
|
164
|
-
|
|
162
|
+
# Away until a given moment (ApplianceModes=4). Away is a settable 7–30 °C
|
|
163
|
+
# setback and defaults to the 7 °C anti-freeze floor.
|
|
164
|
+
from datetime import datetime, timedelta, timezone
|
|
165
|
+
|
|
166
|
+
await client.set_away(
|
|
167
|
+
hub_id,
|
|
168
|
+
[appliance_id],
|
|
169
|
+
temperature=12.0,
|
|
170
|
+
until=datetime.now(timezone.utc) + timedelta(days=3),
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
# Set the target temperature — dedicated endpoint, leaves the schedule alone
|
|
174
|
+
await client.set_appliance_setpoint_temperature(hub_id, [appliance_id], 21.5)
|
|
175
|
+
|
|
176
|
+
# Turn off the way the app does: frost protection at 7 °C
|
|
177
|
+
await client.turn_off(hub_id, [appliance_id])
|
|
165
178
|
```
|
|
166
179
|
|
|
180
|
+
> **Mode flag values matter.** `EApplianceModes` is a bitfield where Boost is `2`
|
|
181
|
+
> and Away is `4`; `16` is Advance and `32` is FrostProtect. Releases before
|
|
182
|
+
> 0.13.0 had these wrong, so Boost silently became Advance and Away became a
|
|
183
|
+
> fixed 7 °C frost hold. If you hand-build `ApplianceModeSettings`, use
|
|
184
|
+
> `ApplianceModeFlag`. See
|
|
185
|
+
> [docs/decompiled-api-reference.md](docs/decompiled-api-reference.md).
|
|
186
|
+
>
|
|
187
|
+
> **Avoid `SetTimerMode` for control.** `set_mode()` and the deprecated
|
|
188
|
+
> `set_target_temperature()` rewrite the schedule; Quantum rejects that with
|
|
189
|
+
> HTTP 403. Use `set_appliance_setpoint_temperature()` and `turn_off()`.
|
|
190
|
+
|
|
167
191
|
### Energy reports
|
|
168
192
|
|
|
169
193
|
```python
|
|
@@ -205,16 +229,23 @@ Main client class. Construct with an `aiohttp.ClientSession` and a `refresh_toke
|
|
|
205
229
|
| `get_user_context()` | Returns `UserContext`. |
|
|
206
230
|
| `get_product_models()` | Returns `list[ProductModel]` (cacheable). |
|
|
207
231
|
| `get_schedule(hub_id, appliance_id)` | Returns `TimerModeSettings` (timer + periods). |
|
|
208
|
-
| `set_mode(hub_id, appliance_id, mode)` |
|
|
209
|
-
| `set_target_temperature(hub_id, appliance_id, temp)` |
|
|
232
|
+
| `set_mode(hub_id, appliance_id, mode)` | Rewrite `TimerMode`. **403 on Quantum** — prefer `turn_off`. |
|
|
233
|
+
| `set_target_temperature(hub_id, appliance_id, temp)` | Deprecated: rewrites period setpoints. Prefer `set_appliance_setpoint_temperature`. |
|
|
234
|
+
| `set_appliance_setpoint_temperature(hub_id, appliance_ids, temperature)` | Preferred setpoint path; non-destructive. |
|
|
210
235
|
| `set_period_setpoint(...)` | Update one timer period without clobbering siblings. |
|
|
211
236
|
| `update_period(...)` | Replace a timer period matched by day + start time. |
|
|
212
|
-
| `
|
|
237
|
+
| `copy_schedule_to_appliances(...)` | Copy one appliance's schedule onto others. |
|
|
238
|
+
| `set_boost(hub_id, appliance_ids, *, temperature, duration_minutes, enable)` | Timed Boost (`ApplianceModes=2`). |
|
|
213
239
|
| `clear_boost(hub_id, appliance_ids)` | Disable Boost. |
|
|
214
|
-
| `set_away(hub_id, appliance_ids, *, temperature, enable, number_of_days)` |
|
|
240
|
+
| `set_away(hub_id, appliance_ids, *, temperature, enable, until, number_of_days)` | Away setback (`ApplianceModes=4`). |
|
|
215
241
|
| `clear_away(hub_id, appliance_ids)` | Disable Away. |
|
|
242
|
+
| `set_frost_protect(...)` / `turn_off(...)` | Frost protection at 7 °C — the app's "off". |
|
|
243
|
+
| `set_advance(...)` | Advance to the next schedule period. |
|
|
244
|
+
| `set_manual(...)` / `set_eco_mode(...)` | Manual / Eco mode holds. |
|
|
245
|
+
| `set_setback_temperature(...)` | Write the setback temperature (untested). |
|
|
216
246
|
| `set_eco_start(hub_id, appliance_ids, enable)` | Toggle EcoStart. |
|
|
217
247
|
| `set_open_window_detection(hub_id, appliance_ids, enable)` | Toggle Open Window Detection. |
|
|
248
|
+
| `set_hot_water_*(...)` / `*_heat_pump_hot_water_schedule(...)` | Hot-water cylinder surface (untested — no hardware). |
|
|
218
249
|
| `get_tsi_energy_report(hub_id, ...)` | Returns `TsiEnergyReport`. |
|
|
219
250
|
| `capabilities_for(appliance, *, status, product)` | Derive an `ApplianceCapabilities` matrix. |
|
|
220
251
|
| `export_tokens()` / `apply_tokens(bundle)` | Token persistence helpers. |
|
|
@@ -11,9 +11,18 @@ successful poll, not an error — use ``get_appliance_overview_map`` if you
|
|
|
11
11
|
need a stable id → status mapping.
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
from .auth import TokenBundle
|
|
14
|
+
from .auth import TokenBundle, TokenListener
|
|
15
15
|
from .capabilities import ApplianceCapabilities, capabilities_for
|
|
16
16
|
from .client import DimplexControl
|
|
17
|
+
from .const import (
|
|
18
|
+
DEFAULT_AWAY_TEMPERATURE,
|
|
19
|
+
DEFAULT_BOOST_TEMPERATURE,
|
|
20
|
+
FROST_TEMPERATURE,
|
|
21
|
+
MODE_TEMP_MAX,
|
|
22
|
+
MODE_TEMP_MIN,
|
|
23
|
+
NO_SETPOINT_SENTINEL,
|
|
24
|
+
NULL_DATETIME,
|
|
25
|
+
)
|
|
17
26
|
from .exceptions import (
|
|
18
27
|
DimplexApiError,
|
|
19
28
|
DimplexAuthError,
|
|
@@ -28,10 +37,14 @@ from .models import (
|
|
|
28
37
|
Appliance,
|
|
29
38
|
ApplianceModeFlag,
|
|
30
39
|
ApplianceModeSettings,
|
|
40
|
+
ApplianceModeStatus,
|
|
31
41
|
ApplianceStatus,
|
|
32
42
|
AutomaticProvisioning,
|
|
33
43
|
Hub,
|
|
44
|
+
HygieneFrequency,
|
|
34
45
|
ProductModel,
|
|
46
|
+
ScheduleProfile,
|
|
47
|
+
SetbackStatus,
|
|
35
48
|
TimerMode,
|
|
36
49
|
TimerModeSettings,
|
|
37
50
|
TimerPeriod,
|
|
@@ -50,6 +63,7 @@ from .telemetry import (
|
|
|
50
63
|
__all__ = [
|
|
51
64
|
"DimplexControl",
|
|
52
65
|
"TokenBundle",
|
|
66
|
+
"TokenListener",
|
|
53
67
|
"ApplianceCapabilities",
|
|
54
68
|
"capabilities_for",
|
|
55
69
|
"Hub",
|
|
@@ -58,12 +72,23 @@ __all__ = [
|
|
|
58
72
|
"ApplianceStatus",
|
|
59
73
|
"ApplianceModeSettings",
|
|
60
74
|
"ApplianceModeFlag",
|
|
75
|
+
"ApplianceModeStatus",
|
|
76
|
+
"HygieneFrequency",
|
|
77
|
+
"ScheduleProfile",
|
|
78
|
+
"SetbackStatus",
|
|
61
79
|
"TimerMode",
|
|
62
80
|
"TimerModeSettings",
|
|
63
81
|
"TimerPeriod",
|
|
64
82
|
"AutomaticProvisioning",
|
|
65
83
|
"ProductModel",
|
|
66
84
|
"TsiEnergyReport",
|
|
85
|
+
"DEFAULT_AWAY_TEMPERATURE",
|
|
86
|
+
"DEFAULT_BOOST_TEMPERATURE",
|
|
87
|
+
"FROST_TEMPERATURE",
|
|
88
|
+
"MODE_TEMP_MIN",
|
|
89
|
+
"MODE_TEMP_MAX",
|
|
90
|
+
"NO_SETPOINT_SENTINEL",
|
|
91
|
+
"NULL_DATETIME",
|
|
67
92
|
"parse_telemetry_points",
|
|
68
93
|
"filter_telemetry_points",
|
|
69
94
|
"summarise_energy",
|
|
@@ -309,12 +309,23 @@ class AuthManager:
|
|
|
309
309
|
|
|
310
310
|
Uses direct HTTP credential submission so users don't need to
|
|
311
311
|
manually extract auth codes from browser network traffic.
|
|
312
|
+
|
|
313
|
+
A separate :class:`aiohttp.ClientSession` is used because the B2C
|
|
314
|
+
flow requires a dedicated cookie jar for state tracking across
|
|
315
|
+
redirects (using the shared session would pollute its cookies).
|
|
316
|
+
The session inherits the caller's **connector** (TLS/proxy config)
|
|
317
|
+
and the configured timeout so network behaviour is consistent.
|
|
312
318
|
"""
|
|
313
319
|
jar = aiohttp.CookieJar(unsafe=True)
|
|
314
320
|
start_url = self.get_login_url()
|
|
321
|
+
# Inherit the caller's connector (TLS cert, proxy, DNS resolver) so
|
|
322
|
+
# headless login respects the same network configuration as API calls.
|
|
323
|
+
connector = self._session.connector
|
|
315
324
|
|
|
316
325
|
try:
|
|
317
|
-
async with aiohttp.ClientSession(
|
|
326
|
+
async with aiohttp.ClientSession(
|
|
327
|
+
cookie_jar=jar, timeout=self._timeout, connector=connector, connector_owner=False
|
|
328
|
+
) as session:
|
|
318
329
|
# Step 1: GET the auth URI, follow redirects to B2C login page
|
|
319
330
|
_LOGGER.debug("Fetching B2C login page")
|
|
320
331
|
try:
|
|
@@ -374,6 +385,9 @@ class AuthManager:
|
|
|
374
385
|
# re-injected with quoted values on the next request.
|
|
375
386
|
async with aiohttp.ClientSession(
|
|
376
387
|
cookie_jar=aiohttp.DummyCookieJar(),
|
|
388
|
+
timeout=self._timeout,
|
|
389
|
+
connector=connector,
|
|
390
|
+
connector_owner=False,
|
|
377
391
|
) as raw_session:
|
|
378
392
|
try:
|
|
379
393
|
async with raw_session.post(
|
|
@@ -9,6 +9,7 @@ from __future__ import annotations
|
|
|
9
9
|
from dataclasses import dataclass
|
|
10
10
|
from typing import Any
|
|
11
11
|
|
|
12
|
+
from .const import FROST_TEMPERATURE, MODE_TEMP_MAX, MODE_TEMP_MIN
|
|
12
13
|
from .models import Appliance, ApplianceStatus, AutomaticProvisioning, ProductModel
|
|
13
14
|
|
|
14
15
|
# Default boost lengths (minutes) offered by the mobile app for most heaters.
|
|
@@ -27,18 +28,26 @@ class ApplianceCapabilities:
|
|
|
27
28
|
|
|
28
29
|
boost: bool = True
|
|
29
30
|
away: bool = True
|
|
31
|
+
advance: bool = True
|
|
30
32
|
open_window: bool = True
|
|
31
33
|
eco_start: bool = True
|
|
32
34
|
setback_read: bool = True
|
|
33
|
-
setback_write: bool =
|
|
34
|
-
frost: bool = True #
|
|
35
|
+
setback_write: bool = True # POST /RemoteControl/SetSetbackTemperature
|
|
36
|
+
frost: bool = True # ApplianceModeFlag.FROST_PROTECT (the app's "off")
|
|
35
37
|
timer: bool = True
|
|
38
|
+
# POST /RemoteControl/SetApplianceSetpointTemperature — the non-destructive
|
|
39
|
+
# setpoint path. Preferred over rewriting the schedule via SetTimerMode,
|
|
40
|
+
# which Quantum rejects with HTTP 403.
|
|
41
|
+
setpoint_write: bool = True
|
|
36
42
|
energy_meter: bool = False
|
|
37
43
|
storage: bool = False
|
|
38
44
|
hot_water: bool = False
|
|
45
|
+
heat_pump: bool = False
|
|
46
|
+
hygiene: bool = False
|
|
39
47
|
climate: bool = True
|
|
40
|
-
min_temp: float =
|
|
41
|
-
max_temp: float =
|
|
48
|
+
min_temp: float = MODE_TEMP_MIN
|
|
49
|
+
max_temp: float = MODE_TEMP_MAX
|
|
50
|
+
frost_temp: float = FROST_TEMPERATURE
|
|
42
51
|
default_boost_minutes: int = DEFAULT_BOOST_MINUTES
|
|
43
52
|
boost_durations: tuple[int, ...] = DEFAULT_BOOST_DURATIONS
|
|
44
53
|
|
|
@@ -58,18 +67,23 @@ class ApplianceCapabilities:
|
|
|
58
67
|
return {
|
|
59
68
|
"boost": self.boost,
|
|
60
69
|
"away": self.away,
|
|
70
|
+
"advance": self.advance,
|
|
61
71
|
"open_window": self.open_window,
|
|
62
72
|
"eco_start": self.eco_start,
|
|
63
73
|
"setback_read": self.setback_read,
|
|
64
74
|
"setback_write": self.setback_write,
|
|
65
75
|
"frost": self.frost,
|
|
66
76
|
"timer": self.timer,
|
|
77
|
+
"setpoint_write": self.setpoint_write,
|
|
67
78
|
"energy_meter": self.energy_meter,
|
|
68
79
|
"storage": self.storage,
|
|
69
80
|
"hot_water": self.hot_water,
|
|
81
|
+
"heat_pump": self.heat_pump,
|
|
82
|
+
"hygiene": self.hygiene,
|
|
70
83
|
"climate": self.climate,
|
|
71
84
|
"min_temp": self.min_temp,
|
|
72
85
|
"max_temp": self.max_temp,
|
|
86
|
+
"frost_temp": self.frost_temp,
|
|
73
87
|
"default_boost_minutes": self.default_boost_minutes,
|
|
74
88
|
"boost_durations": list(self.boost_durations),
|
|
75
89
|
"climate_presets": self.climate_presets(),
|
|
@@ -125,6 +139,7 @@ def capabilities_for(
|
|
|
125
139
|
storage = False
|
|
126
140
|
energy_meter = False
|
|
127
141
|
hot_water = False
|
|
142
|
+
heat_pump = False
|
|
128
143
|
if prov is not None:
|
|
129
144
|
if prov.charge_capacity is not None and prov.charge_capacity > 0:
|
|
130
145
|
storage = True
|
|
@@ -134,11 +149,15 @@ def capabilities_for(
|
|
|
134
149
|
if any(k in tokens for k in ("quantum", "storage", "qrad", "charge")):
|
|
135
150
|
storage = True
|
|
136
151
|
energy_meter = True
|
|
137
|
-
if any(k in tokens for k in ("hot water", "hotwater", "cylinder", "dhw")):
|
|
152
|
+
if any(k in tokens for k in ("hot water", "hotwater", "cylinder", "dhw", "waterheater")):
|
|
153
|
+
hot_water = True
|
|
154
|
+
if any(k in tokens for k in ("ashw", "heat pump", "heatpump")):
|
|
155
|
+
heat_pump = True
|
|
138
156
|
hot_water = True
|
|
139
157
|
|
|
140
158
|
boost = True
|
|
141
159
|
away = True
|
|
160
|
+
advance = True
|
|
142
161
|
open_window = True
|
|
143
162
|
eco_start = True
|
|
144
163
|
setback_read = True
|
|
@@ -162,17 +181,26 @@ def capabilities_for(
|
|
|
162
181
|
if status.RoomTemperature is not None or status.ActiveSetPointTemperature is not None:
|
|
163
182
|
climate = True
|
|
164
183
|
|
|
184
|
+
# Advance only means something for a scheduled room heater; a cylinder has
|
|
185
|
+
# no "next comfort period" to jump to.
|
|
186
|
+
if hot_water and not climate:
|
|
187
|
+
advance = False
|
|
188
|
+
|
|
165
189
|
return ApplianceCapabilities(
|
|
166
190
|
boost=boost,
|
|
167
191
|
away=away,
|
|
192
|
+
advance=advance,
|
|
168
193
|
open_window=open_window,
|
|
169
194
|
eco_start=eco_start,
|
|
170
195
|
setback_read=setback_read,
|
|
171
|
-
setback_write=
|
|
196
|
+
setback_write=True,
|
|
172
197
|
frost=frost,
|
|
173
198
|
timer=timer,
|
|
199
|
+
setpoint_write=True,
|
|
174
200
|
energy_meter=energy_meter,
|
|
175
201
|
storage=storage,
|
|
176
202
|
hot_water=hot_water,
|
|
203
|
+
heat_pump=heat_pump,
|
|
204
|
+
hygiene=hot_water,
|
|
177
205
|
climate=climate,
|
|
178
206
|
)
|
|
@@ -18,6 +18,7 @@ import contextlib
|
|
|
18
18
|
import json
|
|
19
19
|
import os
|
|
20
20
|
import sys
|
|
21
|
+
from collections.abc import Awaitable, Callable
|
|
21
22
|
from pathlib import Path
|
|
22
23
|
from typing import Any
|
|
23
24
|
|
|
@@ -25,7 +26,11 @@ import aiohttp
|
|
|
25
26
|
|
|
26
27
|
from .auth import TokenBundle
|
|
27
28
|
from .client import DimplexControl
|
|
29
|
+
from .const import DEFAULT_AWAY_TEMPERATURE, DEFAULT_BOOST_TEMPERATURE
|
|
28
30
|
from .exceptions import DimplexError
|
|
31
|
+
from .models import SetbackStatus
|
|
32
|
+
|
|
33
|
+
_CoroFactory = Callable[[DimplexControl], Awaitable[int]]
|
|
29
34
|
|
|
30
35
|
|
|
31
36
|
def _load_tokens(path: Path | None) -> TokenBundle:
|
|
@@ -57,7 +62,7 @@ def _redact(value: str | None, *, show: bool) -> str:
|
|
|
57
62
|
|
|
58
63
|
async def _with_client(
|
|
59
64
|
args: argparse.Namespace,
|
|
60
|
-
coro_factory:
|
|
65
|
+
coro_factory: _CoroFactory,
|
|
61
66
|
) -> int:
|
|
62
67
|
tokens = _load_tokens(Path(args.tokens_file) if args.tokens_file else None)
|
|
63
68
|
if not tokens.refresh_token and not tokens.access_token:
|
|
@@ -139,7 +144,11 @@ async def cmd_status(client: DimplexControl, args: argparse.Namespace) -> int:
|
|
|
139
144
|
print("(no status — appliance offline or empty overview)")
|
|
140
145
|
return 0
|
|
141
146
|
status = overview[0]
|
|
142
|
-
|
|
147
|
+
payload = status.model_dump(mode="json")
|
|
148
|
+
# Decoded views the raw payload does not give you.
|
|
149
|
+
payload["_active_modes"] = status.active_modes
|
|
150
|
+
payload["_active_setpoint_temperature"] = status.active_setpoint_temperature
|
|
151
|
+
print(json.dumps(payload, indent=2, default=str))
|
|
143
152
|
return 0
|
|
144
153
|
|
|
145
154
|
|
|
@@ -177,6 +186,8 @@ async def cmd_away(client: DimplexControl, args: argparse.Namespace) -> int:
|
|
|
177
186
|
[args.appliance],
|
|
178
187
|
temperature=args.temperature,
|
|
179
188
|
enable=not args.clear,
|
|
189
|
+
until=args.until,
|
|
190
|
+
number_of_days=args.days,
|
|
180
191
|
)
|
|
181
192
|
print("ok")
|
|
182
193
|
return 0
|
|
@@ -191,6 +202,54 @@ async def cmd_eco(client: DimplexControl, args: argparse.Namespace) -> int:
|
|
|
191
202
|
return 0
|
|
192
203
|
|
|
193
204
|
|
|
205
|
+
async def cmd_setpoint(client: DimplexControl, args: argparse.Namespace) -> int:
|
|
206
|
+
"""Set the active setpoint via the dedicated (non-destructive) endpoint."""
|
|
207
|
+
if not args.yes:
|
|
208
|
+
print("error: control commands require --yes", file=sys.stderr)
|
|
209
|
+
return 2
|
|
210
|
+
await client.set_appliance_setpoint_temperature(args.hub, [args.appliance], args.temperature)
|
|
211
|
+
print("ok")
|
|
212
|
+
return 0
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
async def cmd_off(client: DimplexControl, args: argparse.Namespace) -> int:
|
|
216
|
+
"""Turn the appliance off the way the app does — frost protection at 7 °C."""
|
|
217
|
+
if not args.yes:
|
|
218
|
+
print("error: control commands require --yes", file=sys.stderr)
|
|
219
|
+
return 2
|
|
220
|
+
await client.set_frost_protect(args.hub, [args.appliance], enable=not args.clear)
|
|
221
|
+
print("ok")
|
|
222
|
+
return 0
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
async def cmd_advance(client: DimplexControl, args: argparse.Namespace) -> int:
|
|
226
|
+
if not args.yes:
|
|
227
|
+
print("error: control commands require --yes", file=sys.stderr)
|
|
228
|
+
return 2
|
|
229
|
+
await client.set_advance(
|
|
230
|
+
args.hub,
|
|
231
|
+
[args.appliance],
|
|
232
|
+
enable=not args.clear,
|
|
233
|
+
temperature=args.temperature,
|
|
234
|
+
)
|
|
235
|
+
print("ok")
|
|
236
|
+
return 0
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
async def cmd_setback(client: DimplexControl, args: argparse.Namespace) -> int:
|
|
240
|
+
if not args.yes:
|
|
241
|
+
print("error: control commands require --yes", file=sys.stderr)
|
|
242
|
+
return 2
|
|
243
|
+
await client.set_setback_temperature(
|
|
244
|
+
args.hub,
|
|
245
|
+
[args.appliance],
|
|
246
|
+
temperature=args.temperature,
|
|
247
|
+
status=SetbackStatus.INACTIVE if args.clear else SetbackStatus.ACTIVE,
|
|
248
|
+
)
|
|
249
|
+
print("ok")
|
|
250
|
+
return 0
|
|
251
|
+
|
|
252
|
+
|
|
194
253
|
def build_parser() -> argparse.ArgumentParser:
|
|
195
254
|
parser = argparse.ArgumentParser(
|
|
196
255
|
prog="dimplex",
|
|
@@ -233,21 +292,54 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
233
292
|
p_energy.add_argument("--days", type=int, default=30)
|
|
234
293
|
p_energy.set_defaults(func=cmd_energy)
|
|
235
294
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
295
|
+
_CONTROL_COMMANDS: dict[str, Callable[..., Awaitable[int]]] = {
|
|
296
|
+
"boost": cmd_boost,
|
|
297
|
+
"away": cmd_away,
|
|
298
|
+
"eco": cmd_eco,
|
|
299
|
+
"setpoint": cmd_setpoint,
|
|
300
|
+
"off": cmd_off,
|
|
301
|
+
"advance": cmd_advance,
|
|
302
|
+
"setback": cmd_setback,
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
for name, help_text, opts in (
|
|
306
|
+
(
|
|
307
|
+
"boost",
|
|
308
|
+
"Enable or clear timed Boost (--yes required)",
|
|
309
|
+
{"temperature": DEFAULT_BOOST_TEMPERATURE, "minutes": 60},
|
|
310
|
+
),
|
|
311
|
+
(
|
|
312
|
+
"away",
|
|
313
|
+
"Enable or clear Away setback, 7-30 °C (--yes required)",
|
|
314
|
+
{"temperature": DEFAULT_AWAY_TEMPERATURE, "away_until": True},
|
|
315
|
+
),
|
|
239
316
|
("eco", "Enable or clear EcoStart (--yes required)", {}),
|
|
317
|
+
(
|
|
318
|
+
"setpoint",
|
|
319
|
+
"Set the active setpoint, non-destructive (--yes required)",
|
|
320
|
+
{"temperature": 21.0},
|
|
321
|
+
),
|
|
322
|
+
("off", "Turn off via frost protection at 7 °C (--yes required)", {}),
|
|
323
|
+
("advance", "Advance to the next schedule period (--yes required)", {"temperature": None}),
|
|
324
|
+
(
|
|
325
|
+
"setback",
|
|
326
|
+
"Write the setback temperature (--yes required; untested)",
|
|
327
|
+
{"temperature": 16.0},
|
|
328
|
+
),
|
|
240
329
|
):
|
|
241
330
|
p = sub.add_parser(name, help=help_text)
|
|
242
331
|
p.add_argument("hub")
|
|
243
332
|
p.add_argument("appliance")
|
|
244
333
|
p.add_argument("--yes", action="store_true", help="Confirm control write")
|
|
245
334
|
p.add_argument("--clear", action="store_true", help="Disable the mode")
|
|
246
|
-
if "temperature" in
|
|
247
|
-
p.add_argument("--temperature", type=float, default=
|
|
248
|
-
if "minutes" in
|
|
249
|
-
p.add_argument("--minutes", type=int, default=
|
|
250
|
-
|
|
335
|
+
if "temperature" in opts:
|
|
336
|
+
p.add_argument("--temperature", type=float, default=opts["temperature"])
|
|
337
|
+
if "minutes" in opts:
|
|
338
|
+
p.add_argument("--minutes", type=int, default=opts["minutes"])
|
|
339
|
+
if opts.get("away_until"):
|
|
340
|
+
p.add_argument("--days", type=int, default=0, help="Away duration in days (converted to a date)")
|
|
341
|
+
p.add_argument("--until", help="Away-until datetime, ISO-8601 (overrides --days)")
|
|
342
|
+
p.set_defaults(func=_CONTROL_COMMANDS[name])
|
|
251
343
|
|
|
252
344
|
return parser
|
|
253
345
|
|
|
@@ -257,7 +349,8 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
257
349
|
args = parser.parse_args(argv)
|
|
258
350
|
|
|
259
351
|
async def run(client: DimplexControl) -> int:
|
|
260
|
-
|
|
352
|
+
func: Callable[..., Awaitable[int]] = args.func
|
|
353
|
+
return await func(client, args)
|
|
261
354
|
|
|
262
355
|
return asyncio.run(_with_client(args, run))
|
|
263
356
|
|