pymammotion 0.2.84__py3-none-any.whl → 0.2.86__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.
@@ -66,4 +66,7 @@ class DataEvent:
66
66
  self.on_data_event += obj_method
67
67
 
68
68
  def remove_subscribers(self, obj_method) -> None:
69
- self.on_data_event -= obj_method
69
+ try:
70
+ self.on_data_event -= obj_method
71
+ except ValueError:
72
+ """Subscription object no longer there."""
@@ -37,6 +37,7 @@ class MammotionCloud:
37
37
  self.mqtt_properties_event = DataEvent()
38
38
  self.on_ready_event = DataEvent()
39
39
  self.on_disconnected_event = DataEvent()
40
+ self.on_connected_event = DataEvent()
40
41
  self._operation_lock = asyncio.Lock()
41
42
  self._mqtt_client = mqtt_client
42
43
  self._mqtt_client.on_connected = self.on_connected
@@ -66,6 +67,7 @@ class MammotionCloud:
66
67
 
67
68
  async def on_connected(self) -> None:
68
69
  """Callback for when MQTT connects."""
70
+ await self.on_connected_event.data_event(None)
69
71
 
70
72
  async def on_disconnected(self) -> None:
71
73
  """Callback for when MQTT disconnects."""
@@ -165,19 +167,26 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
165
167
  self._mqtt.mqtt_properties_event.add_subscribers(self._parse_message_properties_for_device)
166
168
  self._mqtt.on_ready_event.add_subscribers(self.on_ready)
167
169
  self._mqtt.on_disconnected_event.add_subscribers(self.on_disconnect)
170
+ self._mqtt.on_connected_event.add_subscribers(self.on_connect)
168
171
  self.set_queue_callback(self.queue_command)
169
172
 
170
173
  if self._mqtt.is_ready:
171
174
  self.run_periodic_sync_task()
172
175
 
176
+ def __del__(self):
177
+ self._mqtt.on_ready_event.remove_subscribers(self.on_ready)
178
+ self._mqtt.on_disconnected_event.remove_subscribers(self.on_disconnect)
179
+ self._mqtt.on_connected_event.remove_subscribers(self.on_connect)
180
+ self._mqtt.mqtt_message_event.remove_subscribers(self._parse_message_for_device)
181
+ if self._ble_sync_task:
182
+ self._ble_sync_task.cancel()
183
+
184
+
173
185
  async def on_ready(self) -> None:
174
186
  """Callback for when MQTT is subscribed to events."""
175
187
  if self.stopped:
176
188
  return
177
189
  try:
178
- await self._ble_sync()
179
- if self._ble_sync_task is None or self._ble_sync_task.cancelled():
180
- await self.run_periodic_sync_task()
181
190
  if self.on_ready_callback:
182
191
  await self.on_ready_callback()
183
192
  except DeviceOfflineException:
@@ -188,11 +197,15 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
188
197
  self._ble_sync_task.cancel()
189
198
  self._mqtt.disconnect()
190
199
 
200
+ async def on_connect(self) -> None:
201
+ await self._ble_sync()
202
+ if self._ble_sync_task is None or self._ble_sync_task.cancelled():
203
+ await self.run_periodic_sync_task()
204
+
191
205
  async def stop(self) -> None:
192
206
  """Stop all tasks and disconnect."""
193
207
  if self._ble_sync_task:
194
208
  self._ble_sync_task.cancel()
195
- self._mqtt.on_ready_event.remove_subscribers(self.on_ready)
196
209
  self.stopped = True
197
210
 
198
211
  async def start(self) -> None:
@@ -200,7 +213,6 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
200
213
  if self._ble_sync_task is None or self._ble_sync_task.cancelled():
201
214
  await self.run_periodic_sync_task()
202
215
  self.stopped = False
203
- self._mqtt.on_ready_event.add_subscribers(self.on_ready)
204
216
  if not self.mqtt.is_connected():
205
217
  self.mqtt.connect_async()
206
218
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymammotion
3
- Version: 0.2.84
3
+ Version: 0.2.86
4
4
  Summary:
5
5
  License: GNU-3.0
6
6
  Author: Michael Arthur
@@ -42,7 +42,7 @@ pymammotion/data/mqtt/properties.py,sha256=kvphcjrDuJHuX8Az98-wKeFv_rSmu2Fz9YKLG
42
42
  pymammotion/data/mqtt/status.py,sha256=zqnlo-MzejEQZszl0i0Wucoc3E76x6UtI9JLxoBnu54,1067
43
43
  pymammotion/data/state_manager.py,sha256=vtBT28-5DY58hJMi_kqOUKnOq6rJ4fx1zX8yU7N96A8,5357
44
44
  pymammotion/event/__init__.py,sha256=mgATR6vPHACNQ-0zH5fi7NdzeTCDV1CZyaWPmtUusi8,115
45
- pymammotion/event/event.py,sha256=UzYnxV5DfvMDK3E06UvSzvzuBbaXOOUwO6xYt_zn9To,2034
45
+ pymammotion/event/event.py,sha256=m7gDAxVcgQAWQBe7AZd3w59eMf9mlcEv27eRT-zz2c0,2133
46
46
  pymammotion/http/_init_.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
47
  pymammotion/http/http.py,sha256=9TnVah-R8nkjlb6oCMk78IZ0Y-2iAcMyIdjcQ54GEPk,3562
48
48
  pymammotion/http/model/http.py,sha256=_hHqe9IfKDukUYKQDrZb_Tt_9rd5BNN1WKsaGIjsexM,1876
@@ -64,7 +64,7 @@ pymammotion/mammotion/devices/__init__.py,sha256=f2qQFPgLGmV85W2hSlMUh5BYuht9o_A
64
64
  pymammotion/mammotion/devices/base.py,sha256=F_L5aDtY6rgRkk7Q4CwilLenTANW6cBe9zIU3a9HRmA,10020
65
65
  pymammotion/mammotion/devices/mammotion.py,sha256=hSO184o1q4ftfLPx9froFPIXk428wGg8Ayw160W3z7c,12482
66
66
  pymammotion/mammotion/devices/mammotion_bluetooth.py,sha256=KjcIta1VcJ8eNJvPFeOtwxV2jl3nrk7PldMmPv_Caqw,18939
67
- pymammotion/mammotion/devices/mammotion_cloud.py,sha256=OW5TqJwoTIYxXc-FqrX4QIYHtFnEGnyKCsMXiULND8k,12136
67
+ pymammotion/mammotion/devices/mammotion_cloud.py,sha256=-l4LRgI4J9_4AJFirocfzlzOMclGl6rliRdD75lbJfo,12613
68
68
  pymammotion/mqtt/__init__.py,sha256=Ocs5e-HLJvTuDpVXyECEsWIvwsUaxzj7lZ9mSYutNDY,105
69
69
  pymammotion/mqtt/mammotion_future.py,sha256=_OWqKOlUGl2yT1xOsXFQYpGd-1zQ63OxqXgy7KRQgYc,710
70
70
  pymammotion/mqtt/mammotion_mqtt.py,sha256=LaySave_hf0gU3crUTLqzpdQtxIwK8vu5DM8F8fbU2Y,8748
@@ -119,7 +119,7 @@ pymammotion/utility/map.py,sha256=GYscVMg2cX3IPlNpCBNHDW0S55yS1WGRf1iHnNZ7TfQ,22
119
119
  pymammotion/utility/movement.py,sha256=N75oAoAgFydqoaOedYIxGUHmuTCtPzAOtb-d_29tpfI,615
120
120
  pymammotion/utility/periodic.py,sha256=MbeSb9cfhxzYmdT_RiE0dZe3H9IfbQW_zSqhmSX2RUc,3321
121
121
  pymammotion/utility/rocker_util.py,sha256=6tX7sS87qoQC_tsxbx3NLL-HgS08wtzXiZkhDiz7uo0,7179
122
- pymammotion-0.2.84.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
123
- pymammotion-0.2.84.dist-info/METADATA,sha256=ea2hs79g7uQDd6Xr4N537FtKoAer6KXtCB34p6tChWQ,3896
124
- pymammotion-0.2.84.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
125
- pymammotion-0.2.84.dist-info/RECORD,,
122
+ pymammotion-0.2.86.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
123
+ pymammotion-0.2.86.dist-info/METADATA,sha256=Nfv6FrCX_R_mkWXgtUsVNwRTrKeTgVaRIp6tiHSgojQ,3896
124
+ pymammotion-0.2.86.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
125
+ pymammotion-0.2.86.dist-info/RECORD,,