python-hotspring 4.0.0__py3-none-any.whl → 4.0.2__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 +2 -0
- hotspring/const.py +17 -1
- hotspring/hotspring.py +287 -79
- {python_hotspring-4.0.0.dist-info → python_hotspring-4.0.2.dist-info}/METADATA +1 -1
- python_hotspring-4.0.2.dist-info/RECORD +10 -0
- python_hotspring-4.0.0.dist-info/RECORD +0 -10
- {python_hotspring-4.0.0.dist-info → python_hotspring-4.0.2.dist-info}/WHEEL +0 -0
- {python_hotspring-4.0.0.dist-info → python_hotspring-4.0.2.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,
|
|
@@ -49,6 +50,7 @@ __all__ = [
|
|
|
49
50
|
"ConnectionStatus",
|
|
50
51
|
"DeviceType",
|
|
51
52
|
"Diagnostics",
|
|
53
|
+
"Endpoint",
|
|
52
54
|
"EnergySaving",
|
|
53
55
|
"EnergySavingMode",
|
|
54
56
|
"FreshWaterIQ",
|
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
|
@@ -5,8 +5,11 @@ from __future__ import annotations
|
|
|
5
5
|
import asyncio
|
|
6
6
|
import contextlib
|
|
7
7
|
import json
|
|
8
|
+
import logging
|
|
9
|
+
import time
|
|
8
10
|
from dataclasses import dataclass
|
|
9
|
-
from
|
|
11
|
+
from http import HTTPMethod
|
|
12
|
+
from typing import TYPE_CHECKING, Self
|
|
10
13
|
|
|
11
14
|
import aiohttp
|
|
12
15
|
from yarl import URL
|
|
@@ -15,6 +18,7 @@ from .const import (
|
|
|
15
18
|
_BRIGHTNESS_TO_WIRE,
|
|
16
19
|
VALID_ENERGY_SAVING_SCHEDULE_IDS,
|
|
17
20
|
BrightnessLevel,
|
|
21
|
+
Endpoint,
|
|
18
22
|
HeatingMode,
|
|
19
23
|
JetSpeed,
|
|
20
24
|
LightColor,
|
|
@@ -36,6 +40,28 @@ from .models import (
|
|
|
36
40
|
SpaInfo,
|
|
37
41
|
)
|
|
38
42
|
|
|
43
|
+
if TYPE_CHECKING:
|
|
44
|
+
from collections.abc import Callable, Iterator
|
|
45
|
+
|
|
46
|
+
_LOGGER = logging.getLogger(__name__)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _describe_exception(exception: BaseException) -> str:
|
|
50
|
+
"""Return the exception type, plus its message when it has one."""
|
|
51
|
+
if detail := str(exception):
|
|
52
|
+
return f"{type(exception).__name__}: {detail}"
|
|
53
|
+
return type(exception).__name__
|
|
54
|
+
|
|
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
|
+
|
|
39
65
|
|
|
40
66
|
@dataclass
|
|
41
67
|
class HotSpring: # pylint: disable=too-many-public-methods
|
|
@@ -66,7 +92,7 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
66
92
|
async def request(
|
|
67
93
|
self,
|
|
68
94
|
uri: str = "",
|
|
69
|
-
method: str =
|
|
95
|
+
method: HTTPMethod | str = HTTPMethod.GET,
|
|
70
96
|
data: dict[str, object] | None = None,
|
|
71
97
|
) -> dict[str, object]:
|
|
72
98
|
"""Handle a request to the Hot Spring HNA.
|
|
@@ -78,7 +104,7 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
78
104
|
Args:
|
|
79
105
|
----
|
|
80
106
|
uri: Request URI, for example ``/status``.
|
|
81
|
-
method: HTTP method
|
|
107
|
+
method: HTTP method (``HTTPMethod`` or its string value).
|
|
82
108
|
data: Dictionary of data to send to the HNA.
|
|
83
109
|
|
|
84
110
|
Returns:
|
|
@@ -97,8 +123,11 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
97
123
|
"""
|
|
98
124
|
url = URL.build(scheme="http", host=self.host, port=80, path=uri)
|
|
99
125
|
|
|
126
|
+
# The HNA's single HTTP worker should not be left holding an idle pooled
|
|
127
|
+
# socket from a shared session between polls.
|
|
100
128
|
headers = {
|
|
101
129
|
"Accept": "application/json, text/plain, */*",
|
|
130
|
+
"Connection": "close",
|
|
102
131
|
}
|
|
103
132
|
|
|
104
133
|
if self.session is None:
|
|
@@ -107,70 +136,118 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
107
136
|
|
|
108
137
|
attempts = 0
|
|
109
138
|
while True:
|
|
139
|
+
started = time.monotonic()
|
|
110
140
|
try:
|
|
111
|
-
|
|
112
|
-
|
|
141
|
+
# Bound the body read too: a stalled body would otherwise hold
|
|
142
|
+
# the HNA's single HTTP worker until the caller's session
|
|
143
|
+
# timeout. Exiting mid-body closes the connection, never pools it.
|
|
144
|
+
async with (
|
|
145
|
+
asyncio.timeout(self.request_timeout),
|
|
146
|
+
self.session.request(
|
|
113
147
|
method,
|
|
114
148
|
url,
|
|
115
149
|
json=data,
|
|
116
150
|
headers=headers,
|
|
117
|
-
)
|
|
151
|
+
) as response,
|
|
152
|
+
):
|
|
153
|
+
if response.status // 100 in [4, 5]:
|
|
154
|
+
contents = await response.read()
|
|
155
|
+
|
|
156
|
+
try:
|
|
157
|
+
raise HotSpringError(
|
|
158
|
+
response.status,
|
|
159
|
+
json.loads(contents.decode("utf8")),
|
|
160
|
+
)
|
|
161
|
+
except json.JSONDecodeError:
|
|
162
|
+
raise HotSpringError(
|
|
163
|
+
response.status,
|
|
164
|
+
{"message": contents.decode("utf8")},
|
|
165
|
+
) from None
|
|
166
|
+
|
|
167
|
+
# The spa returns JSON with text/html Content-Type,
|
|
168
|
+
# so always try JSON parsing first.
|
|
169
|
+
body = await response.text()
|
|
118
170
|
|
|
119
|
-
if response.status // 100 in [4, 5]:
|
|
120
|
-
contents = await response.read()
|
|
121
|
-
response.close()
|
|
122
|
-
|
|
123
|
-
try:
|
|
124
|
-
raise HotSpringError(
|
|
125
|
-
response.status,
|
|
126
|
-
json.loads(contents.decode("utf8")),
|
|
127
|
-
)
|
|
128
|
-
except json.JSONDecodeError:
|
|
129
|
-
raise HotSpringError(
|
|
130
|
-
response.status,
|
|
131
|
-
{"message": contents.decode("utf8")},
|
|
132
|
-
) from None
|
|
133
|
-
|
|
134
|
-
# The spa returns JSON with text/html Content-Type,
|
|
135
|
-
# so always try JSON parsing first.
|
|
136
|
-
body = await response.text()
|
|
137
171
|
try:
|
|
138
172
|
response_data = json.loads(body)
|
|
139
|
-
except json.JSONDecodeError as
|
|
173
|
+
except json.JSONDecodeError as exception:
|
|
140
174
|
msg = f"Invalid JSON response from {uri}: {body[:200]}"
|
|
141
|
-
raise HotSpringError(msg) from
|
|
175
|
+
raise HotSpringError(msg) from exception
|
|
142
176
|
|
|
143
177
|
if not isinstance(response_data, dict):
|
|
144
178
|
msg = f"Unexpected response type from {uri}"
|
|
145
179
|
raise HotSpringError(msg)
|
|
146
180
|
|
|
147
|
-
except asyncio.TimeoutError as exception:
|
|
181
|
+
except asyncio.TimeoutError as exception:
|
|
148
182
|
attempts += 1
|
|
183
|
+
_LOGGER.debug(
|
|
184
|
+
"%s %s attempt %d timed out after %.2fs",
|
|
185
|
+
method,
|
|
186
|
+
uri,
|
|
187
|
+
attempts,
|
|
188
|
+
time.monotonic() - started,
|
|
189
|
+
)
|
|
149
190
|
if attempts > self.request_retries:
|
|
150
191
|
msg = (
|
|
151
192
|
f"Timeout occurred while connecting to Hot Spring HNA at "
|
|
152
|
-
f"{self.host}"
|
|
193
|
+
f"{self.host}: no response within {self.request_timeout}s"
|
|
153
194
|
)
|
|
154
195
|
raise HotSpringConnectionTimeoutError(msg) from exception
|
|
155
196
|
await asyncio.sleep(0.5 * (2 ** (attempts - 1)))
|
|
156
197
|
except aiohttp.ClientError as exception:
|
|
157
198
|
attempts += 1
|
|
199
|
+
cause = _describe_exception(exception)
|
|
200
|
+
_LOGGER.debug(
|
|
201
|
+
"%s %s attempt %d failed after %.2fs: %s",
|
|
202
|
+
method,
|
|
203
|
+
uri,
|
|
204
|
+
attempts,
|
|
205
|
+
time.monotonic() - started,
|
|
206
|
+
cause,
|
|
207
|
+
)
|
|
158
208
|
if attempts > self.request_retries:
|
|
159
209
|
msg = (
|
|
160
210
|
f"Error occurred while communicating with Hot Spring HNA at "
|
|
161
|
-
f"{self.host}"
|
|
211
|
+
f"{self.host}: {cause}"
|
|
162
212
|
)
|
|
163
213
|
raise HotSpringConnectionError(msg) from exception
|
|
164
214
|
await asyncio.sleep(0.5 * (2 ** (attempts - 1)))
|
|
165
215
|
else:
|
|
216
|
+
_LOGGER.debug(
|
|
217
|
+
"%s %s -> %d in %.2fs",
|
|
218
|
+
method,
|
|
219
|
+
uri,
|
|
220
|
+
response.status,
|
|
221
|
+
time.monotonic() - started,
|
|
222
|
+
)
|
|
166
223
|
return response_data
|
|
167
224
|
|
|
168
|
-
async def _safe_request(self,
|
|
225
|
+
async def _safe_request(self, endpoint: Endpoint) -> dict[str, object] | None:
|
|
169
226
|
"""Fetch an endpoint, returning None on error."""
|
|
170
227
|
with contextlib.suppress(HotSpringError):
|
|
171
|
-
return await self.request(
|
|
228
|
+
return await self.request(endpoint)
|
|
172
229
|
return None
|
|
173
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
|
+
|
|
174
251
|
async def update(self, *, refresh_identity: bool = False) -> Spa:
|
|
175
252
|
"""Get all spa information.
|
|
176
253
|
|
|
@@ -196,28 +273,32 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
196
273
|
------
|
|
197
274
|
HotSpringSNADetectedError: If connected to a Spa Network Adapter (SNA)
|
|
198
275
|
and ``validate_device`` is True.
|
|
199
|
-
HotSpringError: If no data is returned from the spa.
|
|
276
|
+
HotSpringError: If no data, or malformed data, is returned from the spa.
|
|
200
277
|
|
|
201
278
|
"""
|
|
202
279
|
if not self._identity_loaded or refresh_identity:
|
|
203
|
-
status_res = await self.request(
|
|
204
|
-
startup_res = await self._safe_request(
|
|
205
|
-
connect_res = await self._safe_request(
|
|
206
|
-
model_res = await self._safe_request(
|
|
280
|
+
status_res = await self.request(Endpoint.STATUS)
|
|
281
|
+
startup_res = await self._safe_request(Endpoint.STARTUP)
|
|
282
|
+
connect_res = await self._safe_request(Endpoint.SPA_CONNECT_STATUS)
|
|
283
|
+
model_res = await self._safe_request(Endpoint.SPA_MODEL)
|
|
207
284
|
|
|
208
|
-
|
|
209
|
-
self.spa
|
|
210
|
-
|
|
211
|
-
|
|
285
|
+
with _parsing(Endpoint.STATUS):
|
|
286
|
+
if self.spa is None:
|
|
287
|
+
self.spa = Spa(status_res)
|
|
288
|
+
else:
|
|
289
|
+
self.spa.update_from_dict(status_res)
|
|
212
290
|
|
|
213
291
|
if startup_res:
|
|
214
|
-
|
|
292
|
+
with _parsing(Endpoint.STARTUP):
|
|
293
|
+
self.spa.update_info(startup_res)
|
|
215
294
|
|
|
216
295
|
if model_res:
|
|
217
|
-
|
|
296
|
+
with _parsing(Endpoint.SPA_MODEL):
|
|
297
|
+
self.spa.update_info(model_res)
|
|
218
298
|
|
|
219
299
|
if connect_res:
|
|
220
|
-
|
|
300
|
+
with _parsing(Endpoint.SPA_CONNECT_STATUS):
|
|
301
|
+
self.spa.update_connection_status(connect_res)
|
|
221
302
|
elif (
|
|
222
303
|
self.spa.connection_status
|
|
223
304
|
and not self.spa.connection_status.spa_connected
|
|
@@ -236,16 +317,18 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
236
317
|
self._identity_loaded = True
|
|
237
318
|
return self.spa
|
|
238
319
|
|
|
239
|
-
status_res = await self.request(
|
|
240
|
-
connect_res = await self._safe_request(
|
|
320
|
+
status_res = await self.request(Endpoint.STATUS)
|
|
321
|
+
connect_res = await self._safe_request(Endpoint.SPA_CONNECT_STATUS)
|
|
241
322
|
|
|
242
|
-
|
|
243
|
-
self.spa
|
|
244
|
-
|
|
245
|
-
|
|
323
|
+
with _parsing(Endpoint.STATUS):
|
|
324
|
+
if self.spa is None: # Safety guard; spa is always set after cold sync
|
|
325
|
+
self.spa = Spa(status_res)
|
|
326
|
+
else:
|
|
327
|
+
self.spa.update_from_dict(status_res)
|
|
246
328
|
|
|
247
329
|
if connect_res:
|
|
248
|
-
|
|
330
|
+
with _parsing(Endpoint.SPA_CONNECT_STATUS):
|
|
331
|
+
self.spa.update_connection_status(connect_res)
|
|
249
332
|
elif (
|
|
250
333
|
self.spa.connection_status and not self.spa.connection_status.spa_connected
|
|
251
334
|
):
|
|
@@ -270,8 +353,7 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
270
353
|
HotSpringError: If the response is invalid.
|
|
271
354
|
|
|
272
355
|
"""
|
|
273
|
-
|
|
274
|
-
return SpaInfo.from_dict(data)
|
|
356
|
+
return await self._fetch(Endpoint.STARTUP, SpaInfo.from_dict)
|
|
275
357
|
|
|
276
358
|
async def update_identity(self) -> SpaInfo:
|
|
277
359
|
"""Fetch and update static spa identity info (/startup and /spamodel).
|
|
@@ -291,8 +373,8 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
291
373
|
msg = "Call update() before update_identity()"
|
|
292
374
|
raise HotSpringError(msg)
|
|
293
375
|
|
|
294
|
-
startup_res = await self._safe_request(
|
|
295
|
-
model_res = await self._safe_request(
|
|
376
|
+
startup_res = await self._safe_request(Endpoint.STARTUP)
|
|
377
|
+
model_res = await self._safe_request(Endpoint.SPA_MODEL)
|
|
296
378
|
|
|
297
379
|
identity_data: dict[str, object] = {}
|
|
298
380
|
if startup_res:
|
|
@@ -301,7 +383,8 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
301
383
|
identity_data.update(model_res)
|
|
302
384
|
|
|
303
385
|
if identity_data:
|
|
304
|
-
|
|
386
|
+
with _parsing(f"{Endpoint.STARTUP} and {Endpoint.SPA_MODEL}"):
|
|
387
|
+
self.spa.update_info(identity_data)
|
|
305
388
|
|
|
306
389
|
if self.validate_device and not self.spa.is_hna:
|
|
307
390
|
msg = (
|
|
@@ -330,14 +413,15 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
330
413
|
HotSpringError: If no data is returned.
|
|
331
414
|
|
|
332
415
|
"""
|
|
333
|
-
data = await self.request("/getFWIQData")
|
|
334
416
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
417
|
+
def parse(data: dict[str, object]) -> FreshWaterIQ:
|
|
418
|
+
if self.spa is None:
|
|
419
|
+
msg = "Call update() before update_water_care()"
|
|
420
|
+
raise HotSpringError(msg)
|
|
421
|
+
self.spa.update_freshwater_iq(data)
|
|
422
|
+
return self.spa.freshwater_iq
|
|
338
423
|
|
|
339
|
-
self.
|
|
340
|
-
return self.spa.freshwater_iq
|
|
424
|
+
return await self._fetch(Endpoint.FRESHWATER_IQ, parse)
|
|
341
425
|
|
|
342
426
|
async def update_diagnostics(self) -> Diagnostics:
|
|
343
427
|
"""Update diagnostic and power metrics.
|
|
@@ -354,14 +438,15 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
354
438
|
HotSpringError: If no data is returned.
|
|
355
439
|
|
|
356
440
|
"""
|
|
357
|
-
data = await self.request("/addDebugData")
|
|
358
441
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
442
|
+
def parse(data: dict[str, object]) -> Diagnostics:
|
|
443
|
+
if self.spa is None:
|
|
444
|
+
msg = "Call update() before update_diagnostics()"
|
|
445
|
+
raise HotSpringError(msg)
|
|
446
|
+
self.spa.update_diagnostics(data)
|
|
447
|
+
return self.spa.diagnostics
|
|
362
448
|
|
|
363
|
-
self.
|
|
364
|
-
return self.spa.diagnostics
|
|
449
|
+
return await self._fetch(Endpoint.DEBUG_DATA, parse)
|
|
365
450
|
|
|
366
451
|
async def update_connection_status(self) -> ConnectionStatus:
|
|
367
452
|
"""Update HNA/SNA/cloud connection status.
|
|
@@ -375,14 +460,20 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
375
460
|
HotSpringError: If no data is returned.
|
|
376
461
|
|
|
377
462
|
"""
|
|
378
|
-
data = await self.request("/spaConnectStatus")
|
|
379
463
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
464
|
+
def parse(data: dict[str, object]) -> ConnectionStatus:
|
|
465
|
+
if self.spa is None:
|
|
466
|
+
msg = "Call update() before update_connection_status()"
|
|
467
|
+
raise HotSpringError(msg)
|
|
468
|
+
self.spa.update_connection_status(data)
|
|
469
|
+
return self.spa.connection_status
|
|
470
|
+
|
|
471
|
+
return await self._fetch(Endpoint.SPA_CONNECT_STATUS, parse)
|
|
383
472
|
|
|
384
|
-
|
|
385
|
-
|
|
473
|
+
def _apply_command_response(self, response: dict[str, object]) -> None:
|
|
474
|
+
"""Fold a command's echoed state into the spa, if one is loaded."""
|
|
475
|
+
if self.spa is not None:
|
|
476
|
+
self.spa.update_from_dict(response)
|
|
386
477
|
|
|
387
478
|
async def _send_command(self, payload: dict[str, object]) -> None:
|
|
388
479
|
"""Send a control command to the spa via POST /spaManager.
|
|
@@ -402,7 +493,9 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
402
493
|
Raises:
|
|
403
494
|
------
|
|
404
495
|
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
405
|
-
|
|
496
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
497
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
498
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
406
499
|
|
|
407
500
|
"""
|
|
408
501
|
if self.spa is not None and not self.spa.connection_status.spa_connected:
|
|
@@ -413,13 +506,16 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
413
506
|
raise HotSpringNotReadyError(msg)
|
|
414
507
|
|
|
415
508
|
try:
|
|
416
|
-
|
|
417
|
-
|
|
509
|
+
await self._fetch(
|
|
510
|
+
Endpoint.SPA_MANAGER,
|
|
511
|
+
self._apply_command_response,
|
|
512
|
+
method=HTTPMethod.POST,
|
|
513
|
+
data=payload,
|
|
418
514
|
)
|
|
419
|
-
|
|
420
|
-
|
|
515
|
+
except HotSpringConnectionError:
|
|
516
|
+
raise
|
|
421
517
|
except HotSpringError as exception:
|
|
422
|
-
msg = f"Command failed: {payload}"
|
|
518
|
+
msg = f"Command failed: {payload}: {exception}"
|
|
423
519
|
raise HotSpringCommandError(msg) from exception
|
|
424
520
|
|
|
425
521
|
async def set_temperature(self, temperature: float) -> None:
|
|
@@ -430,6 +526,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
430
526
|
temperature: Target temperature in the spa's configured unit
|
|
431
527
|
(Fahrenheit or Celsius). Supports integer or half-degree float values.
|
|
432
528
|
|
|
529
|
+
Raises:
|
|
530
|
+
------
|
|
531
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
532
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
533
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
534
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
535
|
+
|
|
433
536
|
"""
|
|
434
537
|
await self._send_command(
|
|
435
538
|
{"heater": {"control": {"temperatureABS": str(temperature)}}}
|
|
@@ -443,6 +546,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
443
546
|
mode: The heating mode value. Use HeatingMode enum values or string,
|
|
444
547
|
e.g. ``HeatingMode.HEAT_WITH_BOOST.value`` or ``"heatWithBoost"``.
|
|
445
548
|
|
|
549
|
+
Raises:
|
|
550
|
+
------
|
|
551
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
552
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
553
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
554
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
555
|
+
|
|
446
556
|
"""
|
|
447
557
|
mode_val = mode.value if isinstance(mode, HeatingMode) else str(mode)
|
|
448
558
|
await self._send_command({"heater": {"control": {"heatingMode": mode_val}}})
|
|
@@ -456,6 +566,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
456
566
|
speed: The speed value. Use JetSpeed enum values or string,
|
|
457
567
|
e.g. ``JetSpeed.HIGH_SPEED.value`` or ``"highSpeed"``.
|
|
458
568
|
|
|
569
|
+
Raises:
|
|
570
|
+
------
|
|
571
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
572
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
573
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
574
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
575
|
+
|
|
459
576
|
"""
|
|
460
577
|
speed_val = speed.value if isinstance(speed, JetSpeed) else str(speed)
|
|
461
578
|
await self._send_command({"JET": {f"JET{jet}": {"control": speed_val}}})
|
|
@@ -473,6 +590,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
473
590
|
color: The color value. Use LightColor enum values or string,
|
|
474
591
|
e.g. ``LightColor.BLUE.value`` or ``"BLUE"``.
|
|
475
592
|
|
|
593
|
+
Raises:
|
|
594
|
+
------
|
|
595
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
596
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
597
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
598
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
599
|
+
|
|
476
600
|
"""
|
|
477
601
|
color_val = color.value if isinstance(color, LightColor) else str(color)
|
|
478
602
|
await self._send_command(
|
|
@@ -496,6 +620,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
496
620
|
----
|
|
497
621
|
zone: The light zone number (1-based).
|
|
498
622
|
|
|
623
|
+
Raises:
|
|
624
|
+
------
|
|
625
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
626
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
627
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
628
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
629
|
+
|
|
499
630
|
"""
|
|
500
631
|
await self._send_command(
|
|
501
632
|
{
|
|
@@ -522,6 +653,10 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
522
653
|
Raises:
|
|
523
654
|
------
|
|
524
655
|
ValueError: If brightness is not an integer between 0 and 5.
|
|
656
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
657
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
658
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
659
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
525
660
|
|
|
526
661
|
"""
|
|
527
662
|
if not 0 <= brightness <= 5:
|
|
@@ -556,6 +691,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
556
691
|
e.g. ``LightWheelMode.ON.value``, ``"loopUp"``,
|
|
557
692
|
``"loopDown"``, or ``"off"``. Defaults to LightWheelMode.ON.
|
|
558
693
|
|
|
694
|
+
Raises:
|
|
695
|
+
------
|
|
696
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
697
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
698
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
699
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
700
|
+
|
|
559
701
|
"""
|
|
560
702
|
mode_val = mode.value if isinstance(mode, LightWheelMode) else str(mode)
|
|
561
703
|
await self._send_command(
|
|
@@ -591,6 +733,10 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
591
733
|
Raises:
|
|
592
734
|
------
|
|
593
735
|
ValueError: If any RGB component is not between 0 and 255.
|
|
736
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
737
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
738
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
739
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
594
740
|
|
|
595
741
|
"""
|
|
596
742
|
for component in (red, green, blue):
|
|
@@ -626,6 +772,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
626
772
|
----
|
|
627
773
|
enabled: True to enable, False to disable.
|
|
628
774
|
|
|
775
|
+
Raises:
|
|
776
|
+
------
|
|
777
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
778
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
779
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
780
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
781
|
+
|
|
629
782
|
"""
|
|
630
783
|
value = "on" if enabled else "off"
|
|
631
784
|
await self._send_command({"cleanCycle": {"control": {"cleanCycle": value}}})
|
|
@@ -637,6 +790,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
637
790
|
----
|
|
638
791
|
on: True to turn on, False to turn off.
|
|
639
792
|
|
|
793
|
+
Raises:
|
|
794
|
+
------
|
|
795
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
796
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
797
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
798
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
799
|
+
|
|
640
800
|
"""
|
|
641
801
|
value = "on" if on else "off"
|
|
642
802
|
await self._send_command({"blower": {"control": value}})
|
|
@@ -648,6 +808,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
648
808
|
----
|
|
649
809
|
locked: True to lock, False to unlock.
|
|
650
810
|
|
|
811
|
+
Raises:
|
|
812
|
+
------
|
|
813
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
814
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
815
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
816
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
817
|
+
|
|
651
818
|
"""
|
|
652
819
|
value = "on" if locked else "off"
|
|
653
820
|
await self._send_command({"spaLock": {"control": value}})
|
|
@@ -659,6 +826,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
659
826
|
----
|
|
660
827
|
locked: True to lock, False to unlock.
|
|
661
828
|
|
|
829
|
+
Raises:
|
|
830
|
+
------
|
|
831
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
832
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
833
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
834
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
835
|
+
|
|
662
836
|
"""
|
|
663
837
|
value = "on" if locked else "off"
|
|
664
838
|
await self._send_command({"heater": {"control": {"temperatureLock": value}}})
|
|
@@ -674,6 +848,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
674
848
|
----
|
|
675
849
|
enabled: True to enable, False to disable.
|
|
676
850
|
|
|
851
|
+
Raises:
|
|
852
|
+
------
|
|
853
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
854
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
855
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
856
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
857
|
+
|
|
677
858
|
"""
|
|
678
859
|
value = "on" if enabled else "off"
|
|
679
860
|
await self._send_command({"cleanCycle": {"control": {"vanishingAct": value}}})
|
|
@@ -686,6 +867,13 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
686
867
|
The underlying ESP32 firmware endpoint only supports toggling
|
|
687
868
|
the boost state via ``{"waterCare": {"control": {"boost": "toggle"}}}``.
|
|
688
869
|
|
|
870
|
+
Raises:
|
|
871
|
+
------
|
|
872
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
873
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
874
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
875
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
876
|
+
|
|
689
877
|
"""
|
|
690
878
|
await self._send_command({"waterCare": {"control": {"boost": "toggle"}}})
|
|
691
879
|
|
|
@@ -703,6 +891,10 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
703
891
|
Raises:
|
|
704
892
|
------
|
|
705
893
|
ValueError: If level is not an integer between 0 and 10.
|
|
894
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
895
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
896
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
897
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
706
898
|
|
|
707
899
|
"""
|
|
708
900
|
if not 0 <= level <= 10:
|
|
@@ -726,6 +918,10 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
726
918
|
Raises:
|
|
727
919
|
------
|
|
728
920
|
ValueError: If neither power_a nor power_b is specified.
|
|
921
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
922
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
923
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
924
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
729
925
|
|
|
730
926
|
"""
|
|
731
927
|
cfg: dict[str, object] = {}
|
|
@@ -749,6 +945,10 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
749
945
|
Raises:
|
|
750
946
|
------
|
|
751
947
|
ValueError: If the brightness level is unrecognized.
|
|
948
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
949
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
950
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
951
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
752
952
|
|
|
753
953
|
"""
|
|
754
954
|
brightness = (
|
|
@@ -788,6 +988,10 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
788
988
|
Raises:
|
|
789
989
|
------
|
|
790
990
|
ValueError: If schedule_id or time/duration parameters are invalid.
|
|
991
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
992
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
993
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
994
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
791
995
|
|
|
792
996
|
"""
|
|
793
997
|
if schedule_id not in VALID_ENERGY_SAVING_SCHEDULE_IDS:
|
|
@@ -842,6 +1046,10 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
842
1046
|
Raises:
|
|
843
1047
|
------
|
|
844
1048
|
ValueError: If time parameters are out of range.
|
|
1049
|
+
HotSpringNotReadyError: If the SNA bridge is not connected.
|
|
1050
|
+
HotSpringConnectionTimeoutError: If the command times out.
|
|
1051
|
+
HotSpringConnectionError: If the HNA cannot be reached.
|
|
1052
|
+
HotSpringCommandError: If the command fails for any other reason.
|
|
845
1053
|
|
|
846
1054
|
"""
|
|
847
1055
|
if not 0 <= start_hour <= 23:
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
hotspring/__init__.py,sha256=h1_vvOrnPsuT4FRVjoLKT5SsxyDBGCtDKCC0kqpZHrc,1590
|
|
2
|
+
hotspring/const.py,sha256=GtzcIq6ZVsvQo6XiA7jDF0fRgOQZnExk1hEuecA0rxU,14908
|
|
3
|
+
hotspring/exceptions.py,sha256=R8YwGfi6mXZ5DcHw4_fmtrRuvgkfOrLRCH-d3x6OUIw,1184
|
|
4
|
+
hotspring/hotspring.py,sha256=3ge_AoqcV_3cwyKgmNcWtlxY_W8qKVQveLmvifWMwZY,38841
|
|
5
|
+
hotspring/models.py,sha256=dCSZEL-GmnKIBk-u6Z-S-tivrMCUS6cP-06wBGDSy8A,56648
|
|
6
|
+
hotspring/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
python_hotspring-4.0.2.dist-info/METADATA,sha256=QbzlyCNXcTWisBZ0hDUXVWDATF_DuRPp5D4liEiytjY,8037
|
|
8
|
+
python_hotspring-4.0.2.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
|
|
9
|
+
python_hotspring-4.0.2.dist-info/licenses/LICENSE,sha256=4n3vNP1aJ5r8xLfzCCjo5l0EK5-k2-7w9rgucn7WVFM,1080
|
|
10
|
+
python_hotspring-4.0.2.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
hotspring/__init__.py,sha256=wV3giZmeCl0qdz6zStvbQAYOBc6d5qdAFzEaHViYKkA,1560
|
|
2
|
-
hotspring/const.py,sha256=f1iopXr4KVgOAr67dKzI0ra5k965zbEcOzicGu_VzuA,14466
|
|
3
|
-
hotspring/exceptions.py,sha256=R8YwGfi6mXZ5DcHw4_fmtrRuvgkfOrLRCH-d3x6OUIw,1184
|
|
4
|
-
hotspring/hotspring.py,sha256=uQHNk5hTxHGRIxmiWzn-eGv7DVd0wiGrLouXahIIqaE,28896
|
|
5
|
-
hotspring/models.py,sha256=dCSZEL-GmnKIBk-u6Z-S-tivrMCUS6cP-06wBGDSy8A,56648
|
|
6
|
-
hotspring/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
python_hotspring-4.0.0.dist-info/METADATA,sha256=rzVurtvJSzG6pkJwDbJ7oh3QaXQNbKRba-1P8DKeebQ,8037
|
|
8
|
-
python_hotspring-4.0.0.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
|
|
9
|
-
python_hotspring-4.0.0.dist-info/licenses/LICENSE,sha256=4n3vNP1aJ5r8xLfzCCjo5l0EK5-k2-7w9rgucn7WVFM,1080
|
|
10
|
-
python_hotspring-4.0.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|