emerald-hws 0.0.23__py3-none-any.whl → 0.0.24__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
@@ -228,7 +228,9 @@ class EmeraldHWS():
228
228
  on_lifecycle_attempting_connect = self.on_lifecycle_attempting_connect,
229
229
  on_lifecycle_disconnection = self.on_lifecycle_disconnection,
230
230
  on_lifecycle_connection_failure = self.on_lifecycle_connection_failure,
231
- on_publish_received = self.mqttCallback
231
+ on_publish_received = self.mqttCallback,
232
+ # The default keep-alive is 20 minutes, which we might want to reduce
233
+ # keep_alive_interval_sec = 60,
232
234
  )
233
235
 
234
236
  client.start()
@@ -288,7 +290,7 @@ class EmeraldHWS():
288
290
  def on_lifecycle_connection_failure(self, lifecycle_connection_failure: mqtt5.LifecycleConnectFailureData):
289
291
  """ Log message when connection failed
290
292
  """
291
- error = lifecycle_connection_failure.error
293
+ error = lifecycle_connection_failure.exception
292
294
  error_code = getattr(error, 'code', 'unknown')
293
295
  error_name = getattr(error, 'name', 'unknown')
294
296
  error_message = str(error)
@@ -317,6 +319,11 @@ class EmeraldHWS():
317
319
  # Log all CONNACK properties if available
318
320
  if hasattr(connack, '__dict__'):
319
321
  self.logger.debug(f"emeraldhws: awsiot: CONNACK details: {connack.__dict__}")
322
+
323
+ if reason_code == mqtt5.ConnectReasonCode.CLIENT_IDENTIFIER_NOT_VALID:
324
+ self.logger.debug("emeraldhws: awsiot: The client identifier is not valid. Getting a new login token.")
325
+ self.getLoginToken()
326
+ self.reconnectMQTT(reason="invalid_client_id")
320
327
  else:
321
328
  self.logger.debug("emeraldhws: awsiot: no CONNACK packet available in failure data")
322
329
 
@@ -357,6 +364,7 @@ class EmeraldHWS():
357
364
 
358
365
  # Clear connection event when disconnected
359
366
  self._connection_event.clear()
367
+ self._is_connected = False
360
368
  return
361
369
 
362
370
  def on_lifecycle_attempting_connect(self, lifecycle_attempting_connect_data: mqtt5.LifecycleAttemptingConnectData):
@@ -433,8 +441,12 @@ class EmeraldHWS():
433
441
  :param id: The UUID of the requested HWS
434
442
  """
435
443
  with self._mqtt_lock:
436
- if not self.mqttClient:
444
+ retry = 0
445
+ while not self.mqttClient:
437
446
  self.connectMQTT()
447
+ if retry >= 3:
448
+ raise Exception("MQTT client not connected after multiple attempts")
449
+ retry += 1
438
450
 
439
451
  mqtt_topic = "ep/heat_pump/from_gw/{}".format(id)
440
452
  subscribe_future = self.mqttClient.subscribe(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: emerald_hws
3
- Version: 0.0.23
3
+ Version: 0.0.24
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
@@ -8,7 +8,7 @@ Project-URL: Homepage, https://github.com/ross-w/emerald_hws_py
8
8
  Project-URL: Bug Tracker, https://github.com/ross-w/emerald_hws_py/issues
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.7
11
+ Requires-Python: >=3.9
12
12
  Description-Content-Type: text/markdown
13
13
  Requires-Dist: boto3<2.0.0,>=1.40.0
14
14
  Requires-Dist: awsiotsdk<2.0.0,>=1.24.0
@@ -0,0 +1,7 @@
1
+ emerald_hws/__init__.py,sha256=uukjQ-kiPYKWvGT3jLL6kJA1DCNAxtw4HlLKqPSypXs,61
2
+ emerald_hws/emeraldhws.py,sha256=Cwk-4ixiJPATY9EuPOoWAdOu2o5v64BHIr610tfVeck,30048
3
+ emerald_hws/__assets__/SFSRootCAG2.pem,sha256=hw9W0AnYrrlbcWsOewAgIl1ULEsoO57Ylu35dCjWcS4,1424
4
+ emerald_hws-0.0.24.dist-info/METADATA,sha256=yUDQKxj5YRXw42KgqTkh2pDDXkOtzj0VtQ7txOf2-Y0,2534
5
+ emerald_hws-0.0.24.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ emerald_hws-0.0.24.dist-info/top_level.txt,sha256=ZCiUmnBkDr2n4QVkTet1s_AKiGJjuz3heuCR5w5ZqLY,12
7
+ emerald_hws-0.0.24.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- emerald_hws/__init__.py,sha256=uukjQ-kiPYKWvGT3jLL6kJA1DCNAxtw4HlLKqPSypXs,61
2
- emerald_hws/emeraldhws.py,sha256=_g8nIqNZxaZvM9ofLiRJsU4mJQ9Z2-Dw63sRFCwnXPA,29386
3
- emerald_hws/__assets__/SFSRootCAG2.pem,sha256=hw9W0AnYrrlbcWsOewAgIl1ULEsoO57Ylu35dCjWcS4,1424
4
- emerald_hws-0.0.23.dist-info/METADATA,sha256=cDH3P_sN-EPP5nQIwiviHPJNqynWHppoJ6w4sTt5bbQ,2534
5
- emerald_hws-0.0.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- emerald_hws-0.0.23.dist-info/top_level.txt,sha256=ZCiUmnBkDr2n4QVkTet1s_AKiGJjuz3heuCR5w5ZqLY,12
7
- emerald_hws-0.0.23.dist-info/RECORD,,