python-hotspring 3.0.2__tar.gz → 3.1.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-hotspring
3
- Version: 3.0.2
3
+ Version: 3.1.0
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.2"
26
+ version = "3.1.0"
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.is_sna:
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.is_sna:
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) "
@@ -216,22 +216,14 @@ class Spa:
216
216
  @property
217
217
  def is_hna(self) -> bool:
218
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
- )
219
+ return self.info.sna_ready or bool(getattr(self.versions, "control_box", ""))
230
220
 
231
221
  @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
222
+ def device_type(self) -> DeviceType:
223
+ """Determine whether the device is an HNA or SNA."""
224
+ if not self.info.hostname:
225
+ return DeviceType.UNKNOWN
226
+ return DeviceType.HNA if self.is_hna else DeviceType.SNA
235
227
 
236
228
 
237
229
  @dataclass
@@ -334,42 +326,24 @@ class SpaInfo:
334
326
  def device_type(self) -> DeviceType:
335
327
  """Determine whether the device is an HNA or SNA.
336
328
 
337
- The HNA (Home Network Adapter) is the intended API bridge.
338
- The SNA (Spa Network Adapter) is the tub-side module.
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.
329
+ Only the HNA can report 'SNAready' as 'Yes'; the SNA firmware always
330
+ reports 'No'. The hostname/rootTopic MAC suffixes cannot be used,
331
+ since rootTopic is built from the higher of the two adapter MACs.
345
332
 
346
333
  Returns
347
334
  -------
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,
350
- DeviceType.UNKNOWN if information is missing.
335
+ DeviceType.UNKNOWN if /startup data is missing,
336
+ DeviceType.HNA if sna_ready is True, otherwise DeviceType.SNA.
351
337
 
352
338
  """
353
- if not self.hostname or not self.root_topic:
339
+ if not self.hostname:
354
340
  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
341
+ return DeviceType.HNA if self.sna_ready else DeviceType.SNA
363
342
 
364
343
  @property
365
344
  def is_hna(self) -> bool:
366
345
  """Return True if this device is the Home Network Adapter (HNA)."""
367
- return self.device_type == DeviceType.HNA
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
346
+ return self.sna_ready
373
347
 
374
348
 
375
349
  @dataclass