python-hotspring 3.0.2__py3-none-any.whl → 4.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/const.py +0 -1
- hotspring/hotspring.py +2 -2
- hotspring/models.py +128 -82
- {python_hotspring-3.0.2.dist-info → python_hotspring-4.0.0.dist-info}/METADATA +1 -3
- python_hotspring-4.0.0.dist-info/RECORD +10 -0
- python_hotspring-3.0.2.dist-info/RECORD +0 -10
- {python_hotspring-3.0.2.dist-info → python_hotspring-4.0.0.dist-info}/WHEEL +0 -0
- {python_hotspring-3.0.2.dist-info → python_hotspring-4.0.0.dist-info}/licenses/LICENSE +0 -0
hotspring/const.py
CHANGED
hotspring/hotspring.py
CHANGED
|
@@ -224,7 +224,7 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
224
224
|
):
|
|
225
225
|
self.spa.connection_status.spa_connected = True
|
|
226
226
|
|
|
227
|
-
if self.validate_device and self.spa.
|
|
227
|
+
if self.validate_device and not self.spa.is_hna:
|
|
228
228
|
msg = (
|
|
229
229
|
f"Connected to Spa Network Adapter (SNA) with hostname "
|
|
230
230
|
f"'{self.spa.info.hostname}'. The Home Network Adapter (HNA) "
|
|
@@ -303,7 +303,7 @@ class HotSpring: # pylint: disable=too-many-public-methods
|
|
|
303
303
|
if identity_data:
|
|
304
304
|
self.spa.update_info(identity_data)
|
|
305
305
|
|
|
306
|
-
if self.validate_device and self.spa.
|
|
306
|
+
if self.validate_device and not self.spa.is_hna:
|
|
307
307
|
msg = (
|
|
308
308
|
f"Connected to Spa Network Adapter (SNA) with hostname "
|
|
309
309
|
f"'{self.spa.info.hostname}'. The Home Network Adapter (HNA) "
|
hotspring/models.py
CHANGED
|
@@ -138,6 +138,8 @@ class Spa:
|
|
|
138
138
|
status if isinstance(status, dict) else {},
|
|
139
139
|
existing=self.versions,
|
|
140
140
|
)
|
|
141
|
+
if self._apply_fwiq_firmware_installed():
|
|
142
|
+
updated.add("freshwater_iq")
|
|
141
143
|
updated.add("versions")
|
|
142
144
|
|
|
143
145
|
return updated
|
|
@@ -211,27 +213,31 @@ class Spa:
|
|
|
211
213
|
data: The JSON response from GET /getFWIQData.
|
|
212
214
|
|
|
213
215
|
"""
|
|
214
|
-
self.freshwater_iq = FreshWaterIQ.from_dict(data)
|
|
216
|
+
self.freshwater_iq = FreshWaterIQ.from_dict(data, existing=self.freshwater_iq)
|
|
217
|
+
self._apply_fwiq_firmware_installed()
|
|
215
218
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
"""Return True if this device is the Home Network Adapter (HNA)."""
|
|
219
|
-
if self.info.is_sna:
|
|
220
|
-
return False
|
|
219
|
+
def _apply_fwiq_firmware_installed(self) -> bool:
|
|
220
|
+
"""Ensure installed=True when FWIQFirmwareVersion is reported.
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
A non-empty FWIQFirmwareVersion takes priority over FWIQinstalled from
|
|
223
|
+
/getFWIQData so pre-sync responses cannot clear hardware presence.
|
|
224
|
+
"""
|
|
225
|
+
if self.versions.fwiq and not self.freshwater_iq.installed:
|
|
226
|
+
self.freshwater_iq = replace(self.freshwater_iq, installed=True)
|
|
223
227
|
return True
|
|
228
|
+
return False
|
|
224
229
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
)
|
|
230
|
+
@property
|
|
231
|
+
def is_hna(self) -> bool:
|
|
232
|
+
"""Return True if this device is the Home Network Adapter (HNA)."""
|
|
233
|
+
return self.info.sna_ready or bool(getattr(self.versions, "control_box", ""))
|
|
230
234
|
|
|
231
235
|
@property
|
|
232
|
-
def
|
|
233
|
-
"""
|
|
234
|
-
|
|
236
|
+
def device_type(self) -> DeviceType:
|
|
237
|
+
"""Determine whether the device is an HNA or SNA."""
|
|
238
|
+
if not self.info.hostname:
|
|
239
|
+
return DeviceType.UNKNOWN
|
|
240
|
+
return DeviceType.HNA if self.is_hna else DeviceType.SNA
|
|
235
241
|
|
|
236
242
|
|
|
237
243
|
@dataclass
|
|
@@ -334,42 +340,24 @@ class SpaInfo:
|
|
|
334
340
|
def device_type(self) -> DeviceType:
|
|
335
341
|
"""Determine whether the device is an HNA or SNA.
|
|
336
342
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
On the HNA with an active link to the SNA, 'SNAready' is 'Yes' (True).
|
|
341
|
-
The SNA firmware always reports 'SNAready' as 'No' (False).
|
|
342
|
-
|
|
343
|
-
When 'root_topic' does not match the hostname MAC suffix and 'sna_ready'
|
|
344
|
-
is False, this indicates an SNA on setups where HNA MAC > SNA MAC.
|
|
343
|
+
Only the HNA can report 'SNAready' as 'Yes'; the SNA firmware always
|
|
344
|
+
reports 'No'. The hostname/rootTopic MAC suffixes cannot be used,
|
|
345
|
+
since rootTopic is built from the higher of the two adapter MACs.
|
|
345
346
|
|
|
346
347
|
Returns
|
|
347
348
|
-------
|
|
348
|
-
DeviceType.
|
|
349
|
-
DeviceType.
|
|
350
|
-
DeviceType.UNKNOWN if information is missing.
|
|
349
|
+
DeviceType.UNKNOWN if /startup data is missing,
|
|
350
|
+
DeviceType.HNA if sna_ready is True, otherwise DeviceType.SNA.
|
|
351
351
|
|
|
352
352
|
"""
|
|
353
|
-
if not self.hostname
|
|
353
|
+
if not self.hostname:
|
|
354
354
|
return DeviceType.UNKNOWN
|
|
355
|
-
|
|
356
|
-
if self.sna_ready:
|
|
357
|
-
return DeviceType.HNA
|
|
358
|
-
|
|
359
|
-
mac_suffix = self.hostname.rsplit("_", 1)[-1]
|
|
360
|
-
if self.root_topic.lower().endswith(mac_suffix.lower()):
|
|
361
|
-
return DeviceType.HNA
|
|
362
|
-
return DeviceType.SNA
|
|
355
|
+
return DeviceType.HNA if self.sna_ready else DeviceType.SNA
|
|
363
356
|
|
|
364
357
|
@property
|
|
365
358
|
def is_hna(self) -> bool:
|
|
366
359
|
"""Return True if this device is the Home Network Adapter (HNA)."""
|
|
367
|
-
return self.
|
|
368
|
-
|
|
369
|
-
@property
|
|
370
|
-
def is_sna(self) -> bool:
|
|
371
|
-
"""Return True if this device is the Spa Network Adapter (SNA)."""
|
|
372
|
-
return self.device_type == DeviceType.SNA
|
|
360
|
+
return self.sna_ready
|
|
373
361
|
|
|
374
362
|
|
|
375
363
|
@dataclass
|
|
@@ -873,14 +861,22 @@ class WaterCare: # pylint: disable=too-many-instance-attributes
|
|
|
873
861
|
|
|
874
862
|
@dataclass
|
|
875
863
|
class FreshWaterIQ:
|
|
876
|
-
"""FreshWater IQ water quality sensor data.
|
|
864
|
+
"""FreshWater IQ water quality sensor data.
|
|
865
|
+
|
|
866
|
+
Sensor reading fields are ``None`` when no valid measurement is available
|
|
867
|
+
(sensor not installed, ``-1`` firmware sentinel, or pre-sync all-zero state).
|
|
868
|
+
"""
|
|
877
869
|
|
|
878
|
-
conductivity: int =
|
|
879
|
-
orp: int =
|
|
880
|
-
chlorine: float =
|
|
881
|
-
ph: float =
|
|
882
|
-
sensor_life_percentage: float =
|
|
870
|
+
conductivity: int | None = None
|
|
871
|
+
orp: int | None = None
|
|
872
|
+
chlorine: float | None = None
|
|
873
|
+
ph: float | None = None
|
|
874
|
+
sensor_life_percentage: float | None = None
|
|
883
875
|
installed: bool = False
|
|
876
|
+
system_enabled: bool = False
|
|
877
|
+
cl_calibration_factor: float | None = None
|
|
878
|
+
ph_calibration_factor: float | None = None
|
|
879
|
+
regional_cl_selection: str = ""
|
|
884
880
|
|
|
885
881
|
@staticmethod
|
|
886
882
|
def from_dict(
|
|
@@ -902,6 +898,8 @@ class FreshWaterIQ:
|
|
|
902
898
|
A FreshWaterIQ instance.
|
|
903
899
|
|
|
904
900
|
"""
|
|
901
|
+
base = existing or FreshWaterIQ()
|
|
902
|
+
|
|
905
903
|
# Handle the nested /getFWIQData format
|
|
906
904
|
water_care = data.get("waterCare")
|
|
907
905
|
fwiq = None
|
|
@@ -913,36 +911,10 @@ class FreshWaterIQ:
|
|
|
913
911
|
fwiq = fwiq_status
|
|
914
912
|
|
|
915
913
|
if fwiq is not None:
|
|
916
|
-
return
|
|
917
|
-
conductivity=int(fwiq.get("Conductivity", 0)),
|
|
918
|
-
orp=int(fwiq.get("ORP", 0)),
|
|
919
|
-
chlorine=float(fwiq.get("Chlorine", 0.0)),
|
|
920
|
-
ph=float(fwiq.get("pH", 0.0)),
|
|
921
|
-
sensor_life_percentage=float(fwiq.get("SensorLife", 0.0)),
|
|
922
|
-
installed=fwiq.get("FWIQinstalled", "notinstalled") != "notinstalled",
|
|
923
|
-
)
|
|
914
|
+
return replace(base, **_parse_fwiq_status(fwiq))
|
|
924
915
|
|
|
925
916
|
# Handle the flat /status FWIQ_Parameters format
|
|
926
|
-
kwargs
|
|
927
|
-
if "current_Current_CompConductivity" in data:
|
|
928
|
-
kwargs["conductivity"] = int(
|
|
929
|
-
data.get("current_Current_CompConductivity", 0)
|
|
930
|
-
)
|
|
931
|
-
if "current_ORP" in data:
|
|
932
|
-
kwargs["orp"] = int(data.get("current_ORP", 0))
|
|
933
|
-
if "current_chlorine" in data:
|
|
934
|
-
kwargs["chlorine"] = float(data.get("current_chlorine", 0.0))
|
|
935
|
-
if "current_pH" in data:
|
|
936
|
-
kwargs["ph"] = float(data.get("current_pH", 0.0))
|
|
937
|
-
if "current_SensorLife_Percentage" in data:
|
|
938
|
-
kwargs["sensor_life_percentage"] = float(
|
|
939
|
-
data.get("current_SensorLife_Percentage", 0.0)
|
|
940
|
-
)
|
|
941
|
-
|
|
942
|
-
if kwargs:
|
|
943
|
-
kwargs["installed"] = True
|
|
944
|
-
|
|
945
|
-
base = existing or FreshWaterIQ()
|
|
917
|
+
kwargs = _parse_fwiq_parameters(data)
|
|
946
918
|
return replace(base, **kwargs)
|
|
947
919
|
|
|
948
920
|
|
|
@@ -1316,13 +1288,15 @@ def _parse_heater_status(status: dict[str, object]) -> dict[str, object]:
|
|
|
1316
1288
|
kwargs["is_on"] = status.get("heater", "off") != "off"
|
|
1317
1289
|
if "heaterLock" in status:
|
|
1318
1290
|
kwargs["heater_lock"] = status.get("heaterLock", "off") != "off"
|
|
1319
|
-
if "heatpumpInstalled"
|
|
1320
|
-
kwargs["heatpump_installed"] =
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1291
|
+
if (raw_hp := status.get("heatpumpInstalled")) is not None:
|
|
1292
|
+
kwargs["heatpump_installed"] = raw_hp != "notinstalled"
|
|
1293
|
+
if kwargs.get("heatpump_installed") is False:
|
|
1294
|
+
# At boot before UART sync, the HNA zero-initializes heater_mode to 0
|
|
1295
|
+
# ("heatWithBoost") even when no CoolZone heat pump is installed.
|
|
1296
|
+
kwargs["heating_mode"] = HeatingMode.UNKNOWN
|
|
1297
|
+
elif (raw_mode := status.get("heatingMode")) is not None:
|
|
1298
|
+
mode = HeatingMode.build(raw_mode)
|
|
1299
|
+
if mode != HeatingMode.UNKNOWN or str(raw_mode).strip().lower() == "invalid":
|
|
1326
1300
|
kwargs["heating_mode"] = mode
|
|
1327
1301
|
if "heaterCurrent" in status:
|
|
1328
1302
|
# Motherboard current registers use Q8.8 fixed point in deciapps (0.1 A):
|
|
@@ -1574,3 +1548,75 @@ def _parse_energy_saving_control(control: dict[str, object]) -> dict[str, object
|
|
|
1574
1548
|
with contextlib.suppress(ValueError, TypeError):
|
|
1575
1549
|
kwargs["duration"] = int(str(control["duration"]))
|
|
1576
1550
|
return kwargs
|
|
1551
|
+
|
|
1552
|
+
|
|
1553
|
+
_FWIQ_STATUS_READING_KEYS: tuple[tuple[str, str, type[int | float]], ...] = (
|
|
1554
|
+
("Conductivity", "conductivity", int),
|
|
1555
|
+
("ORP", "orp", int),
|
|
1556
|
+
("Chlorine", "chlorine", float),
|
|
1557
|
+
("pH", "ph", float),
|
|
1558
|
+
("SensorLife", "sensor_life_percentage", float),
|
|
1559
|
+
)
|
|
1560
|
+
|
|
1561
|
+
_FWIQ_PARAMS_READING_KEYS: tuple[tuple[str, str, type[int | float]], ...] = (
|
|
1562
|
+
("current_Current_CompConductivity", "conductivity", int),
|
|
1563
|
+
("current_ORP", "orp", int),
|
|
1564
|
+
("current_chlorine", "chlorine", float),
|
|
1565
|
+
("current_pH", "ph", float),
|
|
1566
|
+
("current_SensorLife_Percentage", "sensor_life_percentage", float),
|
|
1567
|
+
)
|
|
1568
|
+
|
|
1569
|
+
|
|
1570
|
+
_FWIQ_STATUS_META_KEYS: tuple[tuple[str, str, type[float | str]], ...] = (
|
|
1571
|
+
("Cl_CalibrationFactor", "cl_calibration_factor", float),
|
|
1572
|
+
("pH_CalibrationFactor", "ph_calibration_factor", float),
|
|
1573
|
+
("Regional_Cl_Selection", "regional_cl_selection", str),
|
|
1574
|
+
)
|
|
1575
|
+
|
|
1576
|
+
|
|
1577
|
+
def _normalize_fwiq_readings(
|
|
1578
|
+
source: dict[str, object],
|
|
1579
|
+
key_specs: tuple[tuple[str, str, type[int | float]], ...],
|
|
1580
|
+
) -> dict[str, int | float | None]:
|
|
1581
|
+
"""Parse and normalize FWIQ sensor readings.
|
|
1582
|
+
|
|
1583
|
+
The HNA firmware initializes FWIQ registers to ``0`` at boot before the
|
|
1584
|
+
first UART packet arrives from the control box, and overwrites all five
|
|
1585
|
+
registers with ``-1`` / ``-1.0`` when FWIQ is not installed or no sensor
|
|
1586
|
+
readings are available. Negative values and payloads where no reading is
|
|
1587
|
+
positive are normalized to ``None``.
|
|
1588
|
+
"""
|
|
1589
|
+
readings: dict[str, int | float | None] = {}
|
|
1590
|
+
for json_key, attr_name, converter in key_specs:
|
|
1591
|
+
if (raw := source.get(json_key)) is not None:
|
|
1592
|
+
val = converter(raw)
|
|
1593
|
+
readings[attr_name] = val if val >= 0 else None
|
|
1594
|
+
|
|
1595
|
+
if readings and not any(v is not None and v > 0 for v in readings.values()):
|
|
1596
|
+
return dict.fromkeys(readings, None)
|
|
1597
|
+
return readings
|
|
1598
|
+
|
|
1599
|
+
|
|
1600
|
+
def _parse_fwiq_status(fwiq: dict[str, object]) -> dict[str, object]:
|
|
1601
|
+
"""Parse nested ``waterCare.status.FWIQstatus`` from GET /getFWIQData."""
|
|
1602
|
+
installed = fwiq.get("FWIQinstalled", "notinstalled") != "notinstalled"
|
|
1603
|
+
readings = _normalize_fwiq_readings(fwiq, _FWIQ_STATUS_READING_KEYS)
|
|
1604
|
+
if not installed:
|
|
1605
|
+
readings = dict.fromkeys(readings, None)
|
|
1606
|
+
|
|
1607
|
+
kwargs: dict[str, object] = {**readings, "installed": installed}
|
|
1608
|
+
if (raw_state := fwiq.get("SystemState")) is not None:
|
|
1609
|
+
kwargs["system_enabled"] = str(raw_state).strip().lower() == "enabled"
|
|
1610
|
+
for json_key, attr_name, converter in _FWIQ_STATUS_META_KEYS:
|
|
1611
|
+
if (raw_meta := fwiq.get(json_key)) is not None:
|
|
1612
|
+
kwargs[attr_name] = converter(raw_meta)
|
|
1613
|
+
return kwargs
|
|
1614
|
+
|
|
1615
|
+
|
|
1616
|
+
def _parse_fwiq_parameters(data: dict[str, object]) -> dict[str, object]:
|
|
1617
|
+
"""Parse flat ``FWIQ_Parameters`` from GET /status."""
|
|
1618
|
+
readings = _normalize_fwiq_readings(data, _FWIQ_PARAMS_READING_KEYS)
|
|
1619
|
+
kwargs: dict[str, object] = dict(readings)
|
|
1620
|
+
if any(v is not None for v in readings.values()):
|
|
1621
|
+
kwargs["installed"] = True
|
|
1622
|
+
return kwargs
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-hotspring
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: Asynchronous Python client for Hot Spring Connected Spa Kit 2.
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -22,8 +22,6 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.15
|
|
23
23
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
24
|
Requires-Dist: aiohttp (>=3.0.0)
|
|
25
|
-
Requires-Dist: awesomeversion (>=22.1.0)
|
|
26
|
-
Requires-Dist: python-backoff (>=2.2.0)
|
|
27
25
|
Requires-Dist: yarl (>=1.6.0)
|
|
28
26
|
Project-URL: Bug Tracker, https://github.com/Moustachauve/python-hotspring/issues
|
|
29
27
|
Project-URL: Changelog, https://github.com/Moustachauve/python-hotspring/releases
|
|
@@ -0,0 +1,10 @@
|
|
|
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,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
hotspring/__init__.py,sha256=wV3giZmeCl0qdz6zStvbQAYOBc6d5qdAFzEaHViYKkA,1560
|
|
2
|
-
hotspring/const.py,sha256=ggMcA7ng0pdfquOAQdM7gUoF48J7ha5diya-YkYqFaA,14490
|
|
3
|
-
hotspring/exceptions.py,sha256=R8YwGfi6mXZ5DcHw4_fmtrRuvgkfOrLRCH-d3x6OUIw,1184
|
|
4
|
-
hotspring/hotspring.py,sha256=ME8TDpsF9JCHYxhFbMjRP8b90G1nM3gR7WTIPWOIkhg,28888
|
|
5
|
-
hotspring/models.py,sha256=yP09VLMwCKP2wk8xEuGpWwVeTeEtEkucCe8NhKDIzTs,54278
|
|
6
|
-
hotspring/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
python_hotspring-3.0.2.dist-info/METADATA,sha256=EePlcpJ_wIfMrNKwQFK5_LsAYckvybUJLgLxQ0qs6VY,8118
|
|
8
|
-
python_hotspring-3.0.2.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
|
|
9
|
-
python_hotspring-3.0.2.dist-info/licenses/LICENSE,sha256=4n3vNP1aJ5r8xLfzCCjo5l0EK5-k2-7w9rgucn7WVFM,1080
|
|
10
|
-
python_hotspring-3.0.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|