python-hotspring 1.1.0__tar.gz → 1.2.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: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Asynchronous Python client for Hot Spring Connected Spa Kit 2.
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -22,7 +22,7 @@ packages = [
22
22
  ]
23
23
  readme = "README.md"
24
24
  repository = "https://github.com/Moustachauve/python-hotspring"
25
- version = "1.1.0"
25
+ version = "1.2.0"
26
26
 
27
27
  [tool.poetry.dependencies]
28
28
  aiohttp = ">=3.0.0"
@@ -202,6 +202,32 @@ class SpaInfo:
202
202
  volume=int(model_status.get("volume") or 0),
203
203
  )
204
204
 
205
+ @property
206
+ def mac_address(self) -> str:
207
+ """Derive the MAC address from root_topic.
208
+
209
+ The HNA firmware builds root_topic as ``mySpa%02X%02X%02X%02X%02X%02X``
210
+ using the device's 6-byte WiFi MAC, so the 12 hex characters after the
211
+ ``mySpa`` prefix are the full MAC address.
212
+
213
+ Returns
214
+ -------
215
+ Colon-separated uppercase MAC (e.g. ``"AA:BB:CC:11:22:33"``),
216
+ or ``""`` if root_topic does not match the expected format.
217
+
218
+ """
219
+ prefix = "mySpa"
220
+ if not self.root_topic.startswith(prefix):
221
+ return ""
222
+ mac_hex = self.root_topic[len(prefix) :]
223
+ try:
224
+ mac_bytes = bytes.fromhex(mac_hex)
225
+ except ValueError:
226
+ return ""
227
+ if len(mac_bytes) != 6:
228
+ return ""
229
+ return ":".join(f"{b:02X}" for b in mac_bytes)
230
+
205
231
 
206
232
  @dataclass
207
233
  class Heater: # pylint: disable=too-many-instance-attributes