emerald-hws 0.0.14__py3-none-any.whl → 0.0.15__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.
- emerald_hws/emeraldhws.py +41 -23
- {emerald_hws-0.0.14.dist-info → emerald_hws-0.0.15.dist-info}/METADATA +1 -1
- emerald_hws-0.0.15.dist-info/RECORD +7 -0
- emerald_hws-0.0.14.dist-info/RECORD +0 -7
- {emerald_hws-0.0.14.dist-info → emerald_hws-0.0.15.dist-info}/WHEEL +0 -0
- {emerald_hws-0.0.14.dist-info → emerald_hws-0.0.15.dist-info}/top_level.txt +0 -0
emerald_hws/emeraldhws.py
CHANGED
@@ -39,6 +39,7 @@ class EmeraldHWS():
|
|
39
39
|
self.properties = {}
|
40
40
|
self.logger = logging.getLogger(__name__)
|
41
41
|
self.update_callback = update_callback
|
42
|
+
self._state_lock = threading.RLock() # Thread-safe lock for state operations
|
42
43
|
|
43
44
|
# Convert minutes to seconds for internal use
|
44
45
|
self.connection_timeout = connection_timeout_minutes * 60.0
|
@@ -332,11 +333,14 @@ class EmeraldHWS():
|
|
332
333
|
:param value: value to set
|
333
334
|
"""
|
334
335
|
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
heat_pump['
|
336
|
+
with self._state_lock:
|
337
|
+
for properties in self.properties:
|
338
|
+
heat_pumps = properties.get('heat_pump', [])
|
339
|
+
for heat_pump in heat_pumps:
|
340
|
+
if heat_pump['id'] == id:
|
341
|
+
heat_pump['last_state'][key] = value
|
342
|
+
|
343
|
+
# Call callback AFTER releasing lock to avoid potential deadlocks
|
340
344
|
if self.update_callback is not None:
|
341
345
|
self.update_callback()
|
342
346
|
|
@@ -365,11 +369,13 @@ class EmeraldHWS():
|
|
365
369
|
if not self.properties:
|
366
370
|
self.connect()
|
367
371
|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
372
|
+
with self._state_lock:
|
373
|
+
for properties in self.properties:
|
374
|
+
heat_pumps = properties.get('heat_pump', [])
|
375
|
+
for heat_pump in heat_pumps:
|
376
|
+
if heat_pump['id'] == id:
|
377
|
+
return heat_pump
|
378
|
+
return None
|
373
379
|
|
374
380
|
def sendControlMessage(self, id, payload):
|
375
381
|
""" Sends a message via MQTT to the HWS
|
@@ -381,6 +387,8 @@ class EmeraldHWS():
|
|
381
387
|
self.connect()
|
382
388
|
|
383
389
|
hwsdetail = self.getFullStatus(id)
|
390
|
+
if not hwsdetail:
|
391
|
+
raise Exception(f"Unable to find HWS with ID {id}")
|
384
392
|
|
385
393
|
msg = [{"device_id":id,
|
386
394
|
"namespace":"business",
|
@@ -439,35 +447,45 @@ class EmeraldHWS():
|
|
439
447
|
""" Returns true if the specified HWS is currently on
|
440
448
|
:param id: The UUID of the HWS to query
|
441
449
|
"""
|
442
|
-
|
443
|
-
|
450
|
+
full_status = self.getFullStatus(id)
|
451
|
+
if full_status and full_status.get("last_state"):
|
452
|
+
switch_status = full_status.get("last_state").get("switch")
|
453
|
+
return (switch_status == 1 or switch_status == "on")
|
454
|
+
return False
|
444
455
|
|
445
456
|
def isHeating(self, id):
|
446
457
|
""" Returns true if the specified HWS is currently heating
|
447
458
|
:param id: The UUID of the HWS to query
|
448
459
|
"""
|
449
|
-
|
450
|
-
|
460
|
+
full_status = self.getFullStatus(id)
|
461
|
+
if full_status:
|
462
|
+
heating_status = full_status.get("device_operation_status")
|
463
|
+
return (heating_status == 1)
|
464
|
+
return False
|
451
465
|
|
452
466
|
def currentMode(self, id):
|
453
467
|
""" Returns an integer specifying the current mode (0==boost, 1==normal, 2==quiet)
|
454
468
|
:param id: The UUID of the HWS to query
|
455
469
|
"""
|
456
|
-
|
457
|
-
|
470
|
+
full_status = self.getFullStatus(id)
|
471
|
+
if full_status and full_status.get("last_state"):
|
472
|
+
mode_status = full_status.get("last_state").get("mode")
|
473
|
+
return mode_status
|
474
|
+
return None
|
458
475
|
|
459
476
|
def getInfo(self, id):
|
460
477
|
""" Returns identifying details for the specified HWS
|
461
478
|
:param id: The UUID of the HWS to query
|
462
479
|
"""
|
463
480
|
full_status = self.getFullStatus(id)
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
481
|
+
if full_status:
|
482
|
+
return {'id': id,
|
483
|
+
'serial_number': full_status.get("serial_number"),
|
484
|
+
'brand': full_status.get("brand"),
|
485
|
+
'hw_version': full_status.get("hw_version"),
|
486
|
+
'soft_version': full_status.get("soft_version")
|
487
|
+
}
|
488
|
+
return None
|
471
489
|
|
472
490
|
def listHWS(self):
|
473
491
|
""" Returns a list of UUIDs of all discovered HWS
|
@@ -0,0 +1,7 @@
|
|
1
|
+
emerald_hws/__init__.py,sha256=uukjQ-kiPYKWvGT3jLL6kJA1DCNAxtw4HlLKqPSypXs,61
|
2
|
+
emerald_hws/emeraldhws.py,sha256=0yvazkMtwEfimqGsBe6Q3zGEfpQbCKgCiXDpRYwKFL4,22876
|
3
|
+
emerald_hws/__assets__/SFSRootCAG2.pem,sha256=hw9W0AnYrrlbcWsOewAgIl1ULEsoO57Ylu35dCjWcS4,1424
|
4
|
+
emerald_hws-0.0.15.dist-info/METADATA,sha256=6SQeBxgNLAu_nHDnT4VqJdFB_z7GtkKLixAlSbikCK0,2534
|
5
|
+
emerald_hws-0.0.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
emerald_hws-0.0.15.dist-info/top_level.txt,sha256=ZCiUmnBkDr2n4QVkTet1s_AKiGJjuz3heuCR5w5ZqLY,12
|
7
|
+
emerald_hws-0.0.15.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
emerald_hws/__init__.py,sha256=uukjQ-kiPYKWvGT3jLL6kJA1DCNAxtw4HlLKqPSypXs,61
|
2
|
-
emerald_hws/emeraldhws.py,sha256=7q-T6jaujtxplGXb4GdnuiBHZLwMrdSlJT14pmn6nw0,22100
|
3
|
-
emerald_hws/__assets__/SFSRootCAG2.pem,sha256=hw9W0AnYrrlbcWsOewAgIl1ULEsoO57Ylu35dCjWcS4,1424
|
4
|
-
emerald_hws-0.0.14.dist-info/METADATA,sha256=RRcMNq_lWNHsZigorD4i1tlYfOlAf-9PCBPYMGUlUDs,2534
|
5
|
-
emerald_hws-0.0.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
-
emerald_hws-0.0.14.dist-info/top_level.txt,sha256=ZCiUmnBkDr2n4QVkTet1s_AKiGJjuz3heuCR5w5ZqLY,12
|
7
|
-
emerald_hws-0.0.14.dist-info/RECORD,,
|
File without changes
|
File without changes
|