emerald-hws 0.0.21__tar.gz → 0.0.23__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: emerald_hws
3
- Version: 0.0.21
3
+ Version: 0.0.23
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
@@ -109,13 +109,24 @@ class EmeraldHWS():
109
109
 
110
110
  if post_response_json.get("code") == 200:
111
111
  self.logger.debug("emeraldhws: Successfully logged into Emerald API")
112
- property_data = post_response_json.get("info", {}).get("property")
112
+ info = post_response_json.get("info", {})
113
+
114
+ # Retrieve both property and shared_property arrays
115
+ property_data = info.get("property", [])
116
+ shared_property_data = info.get("shared_property", [])
117
+
118
+ # Combine both arrays into a single list
119
+ combined_properties = []
120
+ if isinstance(property_data, list):
121
+ combined_properties.extend(property_data)
122
+ if isinstance(shared_property_data, list):
123
+ combined_properties.extend(shared_property_data)
113
124
 
114
125
  with self._state_lock:
115
- self.properties = property_data
126
+ self.properties = combined_properties
116
127
 
117
128
  # Check if we got valid data
118
- if not isinstance(property_data, list) or len(property_data) == 0:
129
+ if len(combined_properties) == 0:
119
130
  # Log the full response when properties are invalid to help diagnose the issue
120
131
  self.logger.debug(f"emeraldhws: Poperties empty/invalid, full response: {post_response_json}")
121
132
  raise Exception("No heat pumps found on account - API returned empty or invalid property list")
@@ -157,8 +168,21 @@ class EmeraldHWS():
157
168
  self.logger.info(f"emeraldhws: awsiot: Reconnecting MQTT connection (reason: {reason})")
158
169
 
159
170
  if self.mqttClient is not None:
160
- self.mqttClient.stop()
161
- self.mqttClient = None # Clear the client so a new one can be created
171
+ # Clear connection event before stopping
172
+ self._connection_event.clear()
173
+
174
+ try:
175
+ # Stop the client and wait for it to fully stop
176
+ stop_future = self.mqttClient.stop()
177
+ if stop_future:
178
+ # Wait up to 10 seconds for clean shutdown
179
+ stop_future.result(timeout=10)
180
+ self.logger.debug("emeraldhws: awsiot: MQTT client stopped successfully")
181
+ except Exception as e:
182
+ self.logger.warning(f"emeraldhws: awsiot: Error stopping MQTT client: {e}")
183
+ finally:
184
+ # Always clear the client reference
185
+ self.mqttClient = None
162
186
 
163
187
  self.connectMQTT()
164
188
  self.subscribeAllHWS()
@@ -306,6 +330,8 @@ class EmeraldHWS():
306
330
  """ Log message when stopped
307
331
  """
308
332
  self.logger.debug("emeraldhws: awsiot: stopped")
333
+ # Clear connection event when stopped
334
+ self._connection_event.clear()
309
335
  return
310
336
 
311
337
  def on_lifecycle_disconnection(self, lifecycle_disconnect_data: mqtt5.LifecycleDisconnectData):
@@ -328,6 +354,9 @@ class EmeraldHWS():
328
354
  self.logger.debug(f"emeraldhws: awsiot: disconnect data: {lifecycle_disconnect_data.__dict__}")
329
355
 
330
356
  self.logger.info(f"emeraldhws: awsiot: disconnected - {reason}")
357
+
358
+ # Clear connection event when disconnected
359
+ self._connection_event.clear()
331
360
  return
332
361
 
333
362
  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.23
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
File without changes
File without changes
File without changes
File without changes