emerald-hws 0.0.21__py3-none-any.whl → 0.0.22__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 CHANGED
@@ -157,8 +157,21 @@ class EmeraldHWS():
157
157
  self.logger.info(f"emeraldhws: awsiot: Reconnecting MQTT connection (reason: {reason})")
158
158
 
159
159
  if self.mqttClient is not None:
160
- self.mqttClient.stop()
161
- self.mqttClient = None # Clear the client so a new one can be created
160
+ # Clear connection event before stopping
161
+ self._connection_event.clear()
162
+
163
+ try:
164
+ # Stop the client and wait for it to fully stop
165
+ stop_future = self.mqttClient.stop()
166
+ if stop_future:
167
+ # Wait up to 10 seconds for clean shutdown
168
+ stop_future.result(timeout=10)
169
+ self.logger.debug("emeraldhws: awsiot: MQTT client stopped successfully")
170
+ except Exception as e:
171
+ self.logger.warning(f"emeraldhws: awsiot: Error stopping MQTT client: {e}")
172
+ finally:
173
+ # Always clear the client reference
174
+ self.mqttClient = None
162
175
 
163
176
  self.connectMQTT()
164
177
  self.subscribeAllHWS()
@@ -306,6 +319,8 @@ class EmeraldHWS():
306
319
  """ Log message when stopped
307
320
  """
308
321
  self.logger.debug("emeraldhws: awsiot: stopped")
322
+ # Clear connection event when stopped
323
+ self._connection_event.clear()
309
324
  return
310
325
 
311
326
  def on_lifecycle_disconnection(self, lifecycle_disconnect_data: mqtt5.LifecycleDisconnectData):
@@ -328,6 +343,9 @@ class EmeraldHWS():
328
343
  self.logger.debug(f"emeraldhws: awsiot: disconnect data: {lifecycle_disconnect_data.__dict__}")
329
344
 
330
345
  self.logger.info(f"emeraldhws: awsiot: disconnected - {reason}")
346
+
347
+ # Clear connection event when disconnected
348
+ self._connection_event.clear()
331
349
  return
332
350
 
333
351
  def on_lifecycle_attempting_connect(self, lifecycle_attempting_connect_data: mqtt5.LifecycleAttemptingConnectData):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: emerald_hws
3
- Version: 0.0.21
3
+ Version: 0.0.22
4
4
  Summary: A package to manipulate and monitor Emerald Heat Pump Hot Water Systems
5
5
  Author-email: Ross Williamson <ross@inertia.net.nz>
6
6
  License-Expression: MIT
@@ -0,0 +1,7 @@
1
+ emerald_hws/__init__.py,sha256=uukjQ-kiPYKWvGT3jLL6kJA1DCNAxtw4HlLKqPSypXs,61
2
+ emerald_hws/emeraldhws.py,sha256=DI3yaAoL_iNRqM480AuSKwVKa_nfbsvEVMdnrlW7OIA,28936
3
+ emerald_hws/__assets__/SFSRootCAG2.pem,sha256=hw9W0AnYrrlbcWsOewAgIl1ULEsoO57Ylu35dCjWcS4,1424
4
+ emerald_hws-0.0.22.dist-info/METADATA,sha256=aOWR41PKiop_mbtnkokueGiQuw46tFUB7nm84wnxvZk,2534
5
+ emerald_hws-0.0.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ emerald_hws-0.0.22.dist-info/top_level.txt,sha256=ZCiUmnBkDr2n4QVkTet1s_AKiGJjuz3heuCR5w5ZqLY,12
7
+ emerald_hws-0.0.22.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- emerald_hws/__init__.py,sha256=uukjQ-kiPYKWvGT3jLL6kJA1DCNAxtw4HlLKqPSypXs,61
2
- emerald_hws/emeraldhws.py,sha256=e9IILqA_OUunTRBDtdutO8KIcMnUv8JJ1c5pmoFX2po,28124
3
- emerald_hws/__assets__/SFSRootCAG2.pem,sha256=hw9W0AnYrrlbcWsOewAgIl1ULEsoO57Ylu35dCjWcS4,1424
4
- emerald_hws-0.0.21.dist-info/METADATA,sha256=ZIVIV_DK89_pebFmddygh7QvxN9LpaGKiWwYw0ndavk,2534
5
- emerald_hws-0.0.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- emerald_hws-0.0.21.dist-info/top_level.txt,sha256=ZCiUmnBkDr2n4QVkTet1s_AKiGJjuz3heuCR5w5ZqLY,12
7
- emerald_hws-0.0.21.dist-info/RECORD,,