python-hotspring 4.0.1__py3-none-any.whl → 5.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hotspring/__init__.py +4 -0
- hotspring/const.py +17 -1
- hotspring/hotspring.py +234 -54
- hotspring/models.py +392 -135
- {python_hotspring-4.0.1.dist-info → python_hotspring-5.0.0.dist-info}/METADATA +6 -8
- python_hotspring-5.0.0.dist-info/RECORD +10 -0
- python_hotspring-4.0.1.dist-info/RECORD +0 -10
- {python_hotspring-4.0.1.dist-info → python_hotspring-5.0.0.dist-info}/WHEEL +0 -0
- {python_hotspring-4.0.1.dist-info → python_hotspring-5.0.0.dist-info}/licenses/LICENSE +0 -0
hotspring/__init__.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from .const import (
|
|
4
4
|
BrightnessLevel,
|
|
5
5
|
DeviceType,
|
|
6
|
+
Endpoint,
|
|
6
7
|
EnergySavingMode,
|
|
7
8
|
HeatingMode,
|
|
8
9
|
JetSpeed,
|
|
@@ -34,6 +35,7 @@ from .models import (
|
|
|
34
35
|
Jet,
|
|
35
36
|
LightZone,
|
|
36
37
|
LogoLight,
|
|
38
|
+
PowerMetrics,
|
|
37
39
|
Spa,
|
|
38
40
|
SpaInfo,
|
|
39
41
|
SpaLock,
|
|
@@ -49,6 +51,7 @@ __all__ = [
|
|
|
49
51
|
"ConnectionStatus",
|
|
50
52
|
"DeviceType",
|
|
51
53
|
"Diagnostics",
|
|
54
|
+
"Endpoint",
|
|
52
55
|
"EnergySaving",
|
|
53
56
|
"EnergySavingMode",
|
|
54
57
|
"FreshWaterIQ",
|
|
@@ -69,6 +72,7 @@ __all__ = [
|
|
|
69
72
|
"LightWheelMode",
|
|
70
73
|
"LightZone",
|
|
71
74
|
"LogoLight",
|
|
75
|
+
"PowerMetrics",
|
|
72
76
|
"Spa",
|
|
73
77
|
"SpaBrand",
|
|
74
78
|
"SpaFailureState",
|
hotspring/const.py
CHANGED
|
@@ -2,7 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from enum import Enum
|
|
5
|
+
from enum import Enum, StrEnum
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Endpoint(StrEnum):
|
|
9
|
+
"""HTTP path served by the Home Network Adapter (HNA).
|
|
10
|
+
|
|
11
|
+
Each member's value is the request path, so members can be passed anywhere
|
|
12
|
+
a plain ``str`` URI is accepted.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
STATUS = "/status"
|
|
16
|
+
STARTUP = "/startup"
|
|
17
|
+
SPA_MODEL = "/spamodel"
|
|
18
|
+
SPA_CONNECT_STATUS = "/spaConnectStatus"
|
|
19
|
+
FRESHWATER_IQ = "/getFWIQData"
|
|
20
|
+
DEBUG_DATA = "/addDebugData"
|
|
21
|
+
SPA_MANAGER = "/spaManager"
|
|
6
22
|
|
|
7
23
|
|
|
8
24
|
class HeatingMode(Enum):
|
hotspring/hotspring.py
CHANGED
|
@@ -8,7 +8,8 @@ import json
|
|
|
8
8
|
import logging
|
|
9
9
|
import time
|
|
10
10
|
from dataclasses import dataclass
|
|
11
|
-
from
|
|
11
|
+
from http import HTTPMethod
|
|
12
|
+
from typing import TYPE_CHECKING, Self
|
|
12
13
|
|
|
13
14
|
import aiohttp
|
|
14
15
|
from yarl import URL
|
|
@@ -17,6 +18,7 @@ from .const import (
|
|
|
17
18
|
_BRIGHTNESS_TO_WIRE,
|
|
18
19
|
VALID_ENERGY_SAVING_SCHEDULE_IDS,
|
|
19
20
|
BrightnessLevel,
|
|
21
|
+
Endpoint,
|
|
20
22
|
HeatingMode,
|
|
21
23
|
JetSpeed,
|
|
22
24
|
LightColor,
|
|
@@ -38,6 +40,9 @@ from .models import (
|
|
|
38
40
|
SpaInfo,
|
|
39
41
|
)
|
|
40
42
|
|
|
43
|
+
if TYPE_CHECKING:
|
|
44
|
+
from collections.abc import Callable, Iterator
|
|
45
|
+
|
|
41
46
|
_LOGGER = logging.getLogger(__name__)
|
|
42
47
|
|
|
43
48
|
|
|
@@ -48,6 +53,16 @@ def _describe_exception(exception: BaseException) -> str:
|
|
|
48
53
|
return type(exception).__name__
|
|
49
54
|
|
|
50
55
|
|
|
56
|
+
@contextlib.contextmanager
|
|
57
|
+
def _parsing(uri: str) -> Iterator[None]:
|
|
58
|
+
"""Raise a model parser's failure on a malformed payload as HotSpringError."""
|
|
59
|
+
try:
|
|
60
|
+
yield
|
|
61
|
+
except (AttributeError, KeyError, TypeError, ValueError) as exception:
|
|
62
|
+
msg = f"Unexpected data from {uri}: {exception!r}"
|
|
63
|
+
raise HotSpringError(msg) from exception
|
|
64
|
+
|
|
65
|
+
|
|
51
66
|
@dataclass
|
|
52
67
|
class HotSpring: # pylint: disable=too-many-public-methods
|
|
53
68
|
"""Main class for handling connections with a Hot Spring Spa.
|
|
@@ -77,7 +92,7 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
77
92
|
async def request(
|
|
78
93
|
self,
|
|
79
94
|
uri: str = "",
|
|
80
|
-
method: str =
|
|
95
|
+
method: HTTPMethod | str = HTTPMethod.GET,
|
|
81
96
|
data: dict[str, object] | None = None,
|
|
82
97
|
) -> dict[str, object]:
|
|
83
98
|
"""Handle a request to the Hot Spring HNA.
|
|
@@ -89,7 +104,7 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
89
104
|
Args:
|
|
90
105
|
----
|
|
91
106
|
uri: Request URI, for example ``/status``.
|
|
92
|
-
method: HTTP method
|
|
107
|
+
method: HTTP method (``HTTPMethod`` or its string value).
|
|
93
108
|
data: Dictionary of data to send to the HNA.
|
|
94
109
|
|
|
95
110
|
Returns:
|
|
@@ -207,12 +222,32 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
207
222
|
)
|
|
208
223
|
return response_data
|
|
209
224
|
|
|
210
|
-
async def _safe_request(self,
|
|
225
|
+
async def _safe_request(self, endpoint: Endpoint) -> dict[str, object] | None:
|
|
211
226
|
"""Fetch an endpoint, returning None on error."""
|
|
212
227
|
with contextlib.suppress(HotSpringError):
|
|
213
|
-
return await self.request(
|
|
228
|
+
return await self.request(endpoint)
|
|
214
229
|
return None
|
|
215
230
|
|
|
231
|
+
async def _fetch[T](
|
|
232
|
+
self,
|
|
233
|
+
endpoint: Endpoint,
|
|
234
|
+
parse: Callable[[dict[str, object]], T],
|
|
235
|
+
*,
|
|
236
|
+
method: HTTPMethod | str = HTTPMethod.GET,
|
|
237
|
+
data: dict[str, object] | None = None,
|
|
238
|
+
) -> T:
|
|
239
|
+
"""Request an endpoint and parse its response, naming it on bad data.
|
|
240
|
+
|
|
241
|
+
Raises
|
|
242
|
+
------
|
|
243
|
+
HotSpringError: If the request fails or ``parse`` rejects the
|
|
244
|
+
payload as malformed (attributed to ``endpoint``).
|
|
245
|
+
|
|
246
|
+
"""
|
|
247
|
+
response = await self.request(endpoint, method=method, data=data)
|
|
248
|
+
with _parsing(endpoint):
|
|
249
|
+
return parse(response)
|
|
250
|
+
|
|
216
251
|
async def update(self, *, refresh_identity: bool = False) -> Spa:
|
|
217
252
|
"""Get all spa information.
|
|
218
253
|
|
|
@@ -223,7 +258,9 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
223
258
|
|
|
224
259
|
On subsequent routine polling cycles, it queries /status and /spaConnectStatus
|
|
225
260
|
sequentially, avoiding redundant radio (LoRA) queries for static identity data
|
|
226
|
-
while keeping telemetry and connection status fresh.
|
|
261
|
+
while keeping telemetry and connection status fresh. When power monitoring is
|
|
262
|
+
supported and /addDebugData is needed for initial baseline current or active
|
|
263
|
+
loads, it is also fetched opportunistically.
|
|
227
264
|
|
|
228
265
|
Args:
|
|
229
266
|
----
|
|
@@ -238,28 +275,32 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
238
275
|
------
|
|
239
276
|
HotSpringSNADetectedError: If connected to a Spa Network Adapter (SNA)
|
|
240
277
|
and ``validate_device`` is True.
|
|
241
|
-
HotSpringError: If no data is returned from the spa.
|
|
278
|
+
HotSpringError: If no data, or malformed data, is returned from the spa.
|
|
242
279
|
|
|
243
280
|
"""
|
|
244
281
|
if not self._identity_loaded or refresh_identity:
|
|
245
|
-
status_res = await self.request(
|
|
246
|
-
startup_res = await self._safe_request(
|
|
247
|
-
connect_res = await self._safe_request(
|
|
248
|
-
model_res = await self._safe_request(
|
|
282
|
+
status_res = await self.request(Endpoint.STATUS)
|
|
283
|
+
startup_res = await self._safe_request(Endpoint.STARTUP)
|
|
284
|
+
connect_res = await self._safe_request(Endpoint.SPA_CONNECT_STATUS)
|
|
285
|
+
model_res = await self._safe_request(Endpoint.SPA_MODEL)
|
|
249
286
|
|
|
250
|
-
|
|
251
|
-
self.spa
|
|
252
|
-
|
|
253
|
-
|
|
287
|
+
with _parsing(Endpoint.STATUS):
|
|
288
|
+
if self.spa is None:
|
|
289
|
+
self.spa = Spa(status_res)
|
|
290
|
+
else:
|
|
291
|
+
self.spa.update_from_dict(status_res)
|
|
254
292
|
|
|
255
293
|
if startup_res:
|
|
256
|
-
|
|
294
|
+
with _parsing(Endpoint.STARTUP):
|
|
295
|
+
self.spa.update_info(startup_res)
|
|
257
296
|
|
|
258
297
|
if model_res:
|
|
259
|
-
|
|
298
|
+
with _parsing(Endpoint.SPA_MODEL):
|
|
299
|
+
self.spa.update_info(model_res)
|
|
260
300
|
|
|
261
301
|
if connect_res:
|
|
262
|
-
|
|
302
|
+
with _parsing(Endpoint.SPA_CONNECT_STATUS):
|
|
303
|
+
self.spa.update_connection_status(connect_res)
|
|
263
304
|
elif (
|
|
264
305
|
self.spa.connection_status
|
|
265
306
|
and not self.spa.connection_status.spa_connected
|
|
@@ -275,26 +316,40 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
275
316
|
)
|
|
276
317
|
raise HotSpringSNADetectedError(msg)
|
|
277
318
|
|
|
319
|
+
await self._refresh_power_diagnostics(self.spa)
|
|
278
320
|
self._identity_loaded = True
|
|
279
321
|
return self.spa
|
|
280
322
|
|
|
281
|
-
status_res = await self.request(
|
|
282
|
-
connect_res = await self._safe_request(
|
|
323
|
+
status_res = await self.request(Endpoint.STATUS)
|
|
324
|
+
connect_res = await self._safe_request(Endpoint.SPA_CONNECT_STATUS)
|
|
283
325
|
|
|
284
|
-
|
|
285
|
-
self.spa
|
|
286
|
-
|
|
287
|
-
|
|
326
|
+
with _parsing(Endpoint.STATUS):
|
|
327
|
+
if self.spa is None: # Safety guard; spa is always set after cold sync
|
|
328
|
+
self.spa = Spa(status_res)
|
|
329
|
+
else:
|
|
330
|
+
self.spa.update_from_dict(status_res)
|
|
288
331
|
|
|
289
332
|
if connect_res:
|
|
290
|
-
|
|
333
|
+
with _parsing(Endpoint.SPA_CONNECT_STATUS):
|
|
334
|
+
self.spa.update_connection_status(connect_res)
|
|
291
335
|
elif (
|
|
292
336
|
self.spa.connection_status and not self.spa.connection_status.spa_connected
|
|
293
337
|
):
|
|
294
338
|
self.spa.connection_status.spa_connected = True
|
|
295
339
|
|
|
340
|
+
await self._refresh_power_diagnostics(self.spa)
|
|
296
341
|
return self.spa
|
|
297
342
|
|
|
343
|
+
async def _refresh_power_diagnostics(self, spa: Spa) -> None:
|
|
344
|
+
"""Fetch /addDebugData when needed for baseline current or active loads."""
|
|
345
|
+
if (
|
|
346
|
+
not spa.connection_status.spa_connected
|
|
347
|
+
or not spa.needs_diagnostics_for_power
|
|
348
|
+
):
|
|
349
|
+
return
|
|
350
|
+
with contextlib.suppress(HotSpringError):
|
|
351
|
+
await self._fetch(Endpoint.DEBUG_DATA, spa.update_diagnostics)
|
|
352
|
+
|
|
298
353
|
async def get_device_info(self) -> SpaInfo:
|
|
299
354
|
"""Fetch lightweight device identity directly from /startup.
|
|
300
355
|
|
|
@@ -312,8 +367,7 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
312
367
|
HotSpringError: If the response is invalid.
|
|
313
368
|
|
|
314
369
|
"""
|
|
315
|
-
|
|
316
|
-
return SpaInfo.from_dict(data)
|
|
370
|
+
return await self._fetch(Endpoint.STARTUP, SpaInfo.from_dict)
|
|
317
371
|
|
|
318
372
|
async def update_identity(self) -> SpaInfo:
|
|
319
373
|
"""Fetch and update static spa identity info (/startup and /spamodel).
|
|
@@ -333,8 +387,8 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
333
387
|
msg = "Call update() before update_identity()"
|
|
334
388
|
raise HotSpringError(msg)
|
|
335
389
|
|
|
336
|
-
startup_res = await self._safe_request(
|
|
337
|
-
model_res = await self._safe_request(
|
|
390
|
+
startup_res = await self._safe_request(Endpoint.STARTUP)
|
|
391
|
+
model_res = await self._safe_request(Endpoint.SPA_MODEL)
|
|
338
392
|
|
|
339
393
|
identity_data: dict[str, object] = {}
|
|
340
394
|
if startup_res:
|
|
@@ -343,7 +397,8 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
343
397
|
identity_data.update(model_res)
|
|
344
398
|
|
|
345
399
|
if identity_data:
|
|
346
|
-
|
|
400
|
+
with _parsing(f"{Endpoint.STARTUP} and {Endpoint.SPA_MODEL}"):
|
|
401
|
+
self.spa.update_info(identity_data)
|
|
347
402
|
|
|
348
403
|
if self.validate_device and not self.spa.is_hna:
|
|
349
404
|
msg = (
|
|
@@ -372,14 +427,15 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
372
427
|
HotSpringError: If no data is returned.
|
|
373
428
|
|
|
374
429
|
"""
|
|
375
|
-
data = await self.request("/getFWIQData")
|
|
376
430
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
431
|
+
def parse(data: dict[str, object]) -> FreshWaterIQ:
|
|
432
|
+
if self.spa is None:
|
|
433
|
+
msg = "Call update() before update_water_care()"
|
|
434
|
+
raise HotSpringError(msg)
|
|
435
|
+
self.spa.update_freshwater_iq(data)
|
|
436
|
+
return self.spa.freshwater_iq
|
|
380
437
|
|
|
381
|
-
self.
|
|
382
|
-
return self.spa.freshwater_iq
|
|
438
|
+
return await self._fetch(Endpoint.FRESHWATER_IQ, parse)
|
|
383
439
|
|
|
384
440
|
async def update_diagnostics(self) -> Diagnostics:
|
|
385
441
|
"""Update diagnostic and power metrics.
|
|
@@ -396,14 +452,15 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
396
452
|
HotSpringError: If no data is returned.
|
|
397
453
|
|
|
398
454
|
"""
|
|
399
|
-
data = await self.request("/addDebugData")
|
|
400
455
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
456
|
+
def parse(data: dict[str, object]) -> Diagnostics:
|
|
457
|
+
if self.spa is None:
|
|
458
|
+
msg = "Call update() before update_diagnostics()"
|
|
459
|
+
raise HotSpringError(msg)
|
|
460
|
+
self.spa.update_diagnostics(data)
|
|
461
|
+
return self.spa.diagnostics
|
|
404
462
|
|
|
405
|
-
self.
|
|
406
|
-
return self.spa.diagnostics
|
|
463
|
+
return await self._fetch(Endpoint.DEBUG_DATA, parse)
|
|
407
464
|
|
|
408
465
|
async def update_connection_status(self) -> ConnectionStatus:
|
|
409
466
|
"""Update HNA/SNA/cloud connection status.
|
|
@@ -417,14 +474,20 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
417
474
|
HotSpringError: If no data is returned.
|
|
418
475
|
|
|
419
476
|
"""
|
|
420
|
-
data = await self.request("/spaConnectStatus")
|
|
421
477
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
478
|
+
def parse(data: dict[str, object]) -> ConnectionStatus:
|
|
479
|
+
if self.spa is None:
|
|
480
|
+
msg = "Call update() before update_connection_status()"
|
|
481
|
+
raise HotSpringError(msg)
|
|
482
|
+
self.spa.update_connection_status(data)
|
|
483
|
+
return self.spa.connection_status
|
|
425
484
|
|
|
426
|
-
self.
|
|
427
|
-
|
|
485
|
+
return await self._fetch(Endpoint.SPA_CONNECT_STATUS, parse)
|
|
486
|
+
|
|
487
|
+
def _apply_command_response(self, response: dict[str, object]) -> None:
|
|
488
|
+
"""Fold a command's echoed state into the spa, if one is loaded."""
|
|
489
|
+
if self.spa is not None:
|
|
490
|
+
self.spa.update_from_dict(response)
|
|
428
491
|
|
|
429
492
|
async def _send_command(self, payload: dict[str, object]) -> None:
|
|
430
493
|
"""Send a control command to the spa via POST /spaManager.
|
|
@@ -444,7 +507,9 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
444
507
|
Raises:
|
|
445
508
|
------
|
|
446
509
|
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
447
|
-
|
|
510
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
511
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
512
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
448
513
|
|
|
449
514
|
"""
|
|
450
515
|
if self.spa is not None and not self.spa.connection_status.spa_connected:
|
|
@@ -455,13 +520,16 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
455
520
|
raise HotSpringNotReadyError(msg)
|
|
456
521
|
|
|
457
522
|
try:
|
|
458
|
-
|
|
459
|
-
|
|
523
|
+
await self._fetch(
|
|
524
|
+
Endpoint.SPA_MANAGER,
|
|
525
|
+
self._apply_command_response,
|
|
526
|
+
method=HTTPMethod.POST,
|
|
527
|
+
data=payload,
|
|
460
528
|
)
|
|
461
|
-
|
|
462
|
-
|
|
529
|
+
except HotSpringConnectionError:
|
|
530
|
+
raise
|
|
463
531
|
except HotSpringError as exception:
|
|
464
|
-
msg = f"Command failed: {payload}"
|
|
532
|
+
msg = f"Command failed: {payload}: {exception}"
|
|
465
533
|
raise HotSpringCommandError(msg) from exception
|
|
466
534
|
|
|
467
535
|
async def set_temperature(self, temperature: float) -> None:
|
|
@@ -472,6 +540,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
472
540
|
temperature: Target temperature in the spa's configured unit
|
|
473
541
|
(Fahrenheit or Celsius). Supports integer or half-degree float values.
|
|
474
542
|
|
|
543
|
+
Raises:
|
|
544
|
+
------
|
|
545
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
546
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
547
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
548
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
549
|
+
|
|
475
550
|
"""
|
|
476
551
|
await self._send_command(
|
|
477
552
|
{"heater": {"control": {"temperatureABS": str(temperature)}}}
|
|
@@ -485,6 +560,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
485
560
|
mode: The heating mode value. Use HeatingMode enum values or string,
|
|
486
561
|
e.g. ``HeatingMode.HEAT_WITH_BOOST.value`` or ``"heatWithBoost"``.
|
|
487
562
|
|
|
563
|
+
Raises:
|
|
564
|
+
------
|
|
565
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
566
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
567
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
568
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
569
|
+
|
|
488
570
|
"""
|
|
489
571
|
mode_val = mode.value if isinstance(mode, HeatingMode) else str(mode)
|
|
490
572
|
await self._send_command({"heater": {"control": {"heatingMode": mode_val}}})
|
|
@@ -498,6 +580,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
498
580
|
speed: The speed value. Use JetSpeed enum values or string,
|
|
499
581
|
e.g. ``JetSpeed.HIGH_SPEED.value`` or ``"highSpeed"``.
|
|
500
582
|
|
|
583
|
+
Raises:
|
|
584
|
+
------
|
|
585
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
586
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
587
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
588
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
589
|
+
|
|
501
590
|
"""
|
|
502
591
|
speed_val = speed.value if isinstance(speed, JetSpeed) else str(speed)
|
|
503
592
|
await self._send_command({"JET": {f"JET{jet}": {"control": speed_val}}})
|
|
@@ -515,6 +604,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
515
604
|
color: The color value. Use LightColor enum values or string,
|
|
516
605
|
e.g. ``LightColor.BLUE.value`` or ``"BLUE"``.
|
|
517
606
|
|
|
607
|
+
Raises:
|
|
608
|
+
------
|
|
609
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
610
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
611
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
612
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
613
|
+
|
|
518
614
|
"""
|
|
519
615
|
color_val = color.value if isinstance(color, LightColor) else str(color)
|
|
520
616
|
await self._send_command(
|
|
@@ -538,6 +634,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
538
634
|
----
|
|
539
635
|
zone: The light zone number (1-based).
|
|
540
636
|
|
|
637
|
+
Raises:
|
|
638
|
+
------
|
|
639
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
640
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
641
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
642
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
643
|
+
|
|
541
644
|
"""
|
|
542
645
|
await self._send_command(
|
|
543
646
|
{
|
|
@@ -564,6 +667,10 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
564
667
|
Raises:
|
|
565
668
|
------
|
|
566
669
|
ValueError: If brightness is not an integer between 0 and 5.
|
|
670
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
671
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
672
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
673
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
567
674
|
|
|
568
675
|
"""
|
|
569
676
|
if not 0 <= brightness <= 5:
|
|
@@ -598,6 +705,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
598
705
|
e.g. ``LightWheelMode.ON.value``, ``"loopUp"``,
|
|
599
706
|
``"loopDown"``, or ``"off"``. Defaults to LightWheelMode.ON.
|
|
600
707
|
|
|
708
|
+
Raises:
|
|
709
|
+
------
|
|
710
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
711
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
712
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
713
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
714
|
+
|
|
601
715
|
"""
|
|
602
716
|
mode_val = mode.value if isinstance(mode, LightWheelMode) else str(mode)
|
|
603
717
|
await self._send_command(
|
|
@@ -633,6 +747,10 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
633
747
|
Raises:
|
|
634
748
|
------
|
|
635
749
|
ValueError: If any RGB component is not between 0 and 255.
|
|
750
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
751
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
752
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
753
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
636
754
|
|
|
637
755
|
"""
|
|
638
756
|
for component in (red, green, blue):
|
|
@@ -668,6 +786,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
668
786
|
----
|
|
669
787
|
enabled: True to enable, False to disable.
|
|
670
788
|
|
|
789
|
+
Raises:
|
|
790
|
+
------
|
|
791
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
792
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
793
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
794
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
795
|
+
|
|
671
796
|
"""
|
|
672
797
|
value = "on" if enabled else "off"
|
|
673
798
|
await self._send_command({"cleanCycle": {"control": {"cleanCycle": value}}})
|
|
@@ -679,6 +804,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
679
804
|
----
|
|
680
805
|
on: True to turn on, False to turn off.
|
|
681
806
|
|
|
807
|
+
Raises:
|
|
808
|
+
------
|
|
809
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
810
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
811
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
812
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
813
|
+
|
|
682
814
|
"""
|
|
683
815
|
value = "on" if on else "off"
|
|
684
816
|
await self._send_command({"blower": {"control": value}})
|
|
@@ -690,6 +822,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
690
822
|
----
|
|
691
823
|
locked: True to lock, False to unlock.
|
|
692
824
|
|
|
825
|
+
Raises:
|
|
826
|
+
------
|
|
827
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
828
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
829
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
830
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
831
|
+
|
|
693
832
|
"""
|
|
694
833
|
value = "on" if locked else "off"
|
|
695
834
|
await self._send_command({"spaLock": {"control": value}})
|
|
@@ -701,6 +840,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
701
840
|
----
|
|
702
841
|
locked: True to lock, False to unlock.
|
|
703
842
|
|
|
843
|
+
Raises:
|
|
844
|
+
------
|
|
845
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
846
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
847
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
848
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
849
|
+
|
|
704
850
|
"""
|
|
705
851
|
value = "on" if locked else "off"
|
|
706
852
|
await self._send_command({"heater": {"control": {"temperatureLock": value}}})
|
|
@@ -716,6 +862,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
716
862
|
----
|
|
717
863
|
enabled: True to enable, False to disable.
|
|
718
864
|
|
|
865
|
+
Raises:
|
|
866
|
+
------
|
|
867
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
868
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
869
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
870
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
871
|
+
|
|
719
872
|
"""
|
|
720
873
|
value = "on" if enabled else "off"
|
|
721
874
|
await self._send_command({"cleanCycle": {"control": {"vanishingAct": value}}})
|
|
@@ -728,6 +881,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
728
881
|
The underlying ESP32 firmware endpoint only supports toggling
|
|
729
882
|
the boost state via ``{"waterCare": {"control": {"boost": "toggle"}}}``.
|
|
730
883
|
|
|
884
|
+
Raises:
|
|
885
|
+
------
|
|
886
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
887
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
888
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
889
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
890
|
+
|
|
731
891
|
"""
|
|
732
892
|
await self._send_command({"waterCare": {"control": {"boost": "toggle"}}})
|
|
733
893
|
|
|
@@ -745,6 +905,10 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
745
905
|
Raises:
|
|
746
906
|
------
|
|
747
907
|
ValueError: If level is not an integer between 0 and 10.
|
|
908
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
909
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
910
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
911
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
748
912
|
|
|
749
913
|
"""
|
|
750
914
|
if not 0 <= level <= 10:
|
|
@@ -768,6 +932,10 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
768
932
|
Raises:
|
|
769
933
|
------
|
|
770
934
|
ValueError: If neither power_a nor power_b is specified.
|
|
935
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
936
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
937
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
938
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
771
939
|
|
|
772
940
|
"""
|
|
773
941
|
cfg: dict[str, object] = {}
|
|
@@ -791,6 +959,10 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
791
959
|
Raises:
|
|
792
960
|
------
|
|
793
961
|
ValueError: If the brightness level is unrecognized.
|
|
962
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
963
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
964
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
965
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
794
966
|
|
|
795
967
|
"""
|
|
796
968
|
brightness = (
|
|
@@ -830,6 +1002,10 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
830
1002
|
Raises:
|
|
831
1003
|
------
|
|
832
1004
|
ValueError: If schedule_id or time/duration parameters are invalid.
|
|
1005
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
1006
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
1007
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
1008
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
833
1009
|
|
|
834
1010
|
"""
|
|
835
1011
|
if schedule_id not in VALID_ENERGY_SAVING_SCHEDULE_IDS:
|
|
@@ -884,6 +1060,10 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
884
1060
|
Raises:
|
|
885
1061
|
------
|
|
886
1062
|
ValueError: If time parameters are out of range.
|
|
1063
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
1064
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
1065
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
1066
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
887
1067
|
|
|
888
1068
|
"""
|
|
889
1069
|
if not 0 <= start_hour <= 23:
|