python-hotspring 3.0.1__tar.gz → 3.0.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-hotspring
3
- Version: 3.0.1
3
+ Version: 3.0.2
4
4
  Summary: Asynchronous Python client for Hot Spring Connected Spa Kit 2.
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -23,7 +23,7 @@ packages = [
23
23
  readme = "README.md"
24
24
  repository = "https://github.com/Moustachauve/python-hotspring"
25
25
  # The CI/CD and GitHub Actions release workflows are responsible for setting the version tag
26
- version = "3.0.1"
26
+ version = "3.0.2"
27
27
 
28
28
  [tool.poetry.dependencies]
29
29
  aiohttp = ">=3.0.0"
@@ -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.info.is_sna:
227
+ if self.validate_device and self.spa.is_sna:
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.info.is_sna:
306
+ if self.validate_device and self.spa.is_sna:
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) "
@@ -213,6 +213,26 @@ class Spa:
213
213
  """
214
214
  self.freshwater_iq = FreshWaterIQ.from_dict(data)
215
215
 
216
+ @property
217
+ def is_hna(self) -> bool:
218
+ """Return True if this device is the Home Network Adapter (HNA)."""
219
+ if self.info.is_sna:
220
+ return False
221
+
222
+ if self.info.sna_ready:
223
+ return True
224
+
225
+ return (
226
+ self.heater.current_temperature is not None
227
+ or self.heater.set_temperature is not None
228
+ or bool(getattr(self.versions, "control_box", ""))
229
+ )
230
+
231
+ @property
232
+ def is_sna(self) -> bool:
233
+ """Return True if this device is the Spa Network Adapter (SNA)."""
234
+ return not self.is_hna
235
+
216
236
 
217
237
  @dataclass
218
238
  class SpaInfo:
@@ -317,22 +337,25 @@ class SpaInfo:
317
337
  The HNA (Home Network Adapter) is the intended API bridge.
318
338
  The SNA (Spa Network Adapter) is the tub-side module.
319
339
 
320
- On the HNA, the hostname suffix (last 6 characters, e.g. from
321
- 'ConnectedSpa_112233') matches the last 6 characters of the root_topic
322
- (e.g. 'mySpaAABBCC112233').
323
- On the SNA, root_topic still points to the paired HNA topic, but
324
- the hostname reflects the SNA's own MAC address.
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.
325
345
 
326
346
  Returns
327
347
  -------
328
- DeviceType.HNA if hostname matches root_topic,
329
- DeviceType.SNA if hostname differs from root_topic,
348
+ DeviceType.HNA if sna_ready is True or hostname matches root_topic,
349
+ DeviceType.SNA if hostname differs from root_topic and sna_ready is False,
330
350
  DeviceType.UNKNOWN if information is missing.
331
351
 
332
352
  """
333
353
  if not self.hostname or not self.root_topic:
334
354
  return DeviceType.UNKNOWN
335
355
 
356
+ if self.sna_ready:
357
+ return DeviceType.HNA
358
+
336
359
  mac_suffix = self.hostname.rsplit("_", 1)[-1]
337
360
  if self.root_topic.lower().endswith(mac_suffix.lower()):
338
361
  return DeviceType.HNA