pymammotion 0.2.8__tar.gz → 0.2.10__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.
Files changed (117) hide show
  1. {pymammotion-0.2.8 → pymammotion-0.2.10}/PKG-INFO +1 -1
  2. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/aliyun/cloud_gateway.py +1 -1
  3. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/devices/mammotion.py +56 -12
  4. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mqtt/mammotion_mqtt.py +3 -2
  5. {pymammotion-0.2.8 → pymammotion-0.2.10}/pyproject.toml +3 -3
  6. {pymammotion-0.2.8 → pymammotion-0.2.10}/LICENSE +0 -0
  7. {pymammotion-0.2.8 → pymammotion-0.2.10}/README.md +0 -0
  8. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/__init__.py +0 -0
  9. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/aliyun/__init__.py +0 -0
  10. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/aliyun/cloud_service.py +0 -0
  11. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/aliyun/dataclass/aep_response.py +0 -0
  12. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/aliyun/dataclass/connect_response.py +0 -0
  13. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/aliyun/dataclass/dev_by_account_response.py +0 -0
  14. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/aliyun/dataclass/login_by_oauth_response.py +0 -0
  15. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/aliyun/dataclass/regions_response.py +0 -0
  16. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/aliyun/dataclass/session_by_authcode_response.py +0 -0
  17. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/aliyun/tmp_constant.py +0 -0
  18. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/bluetooth/__init__.py +0 -0
  19. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/bluetooth/ble.py +0 -0
  20. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/bluetooth/ble_message.py +0 -0
  21. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/bluetooth/const.py +0 -0
  22. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/bluetooth/data/__init__.py +0 -0
  23. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/bluetooth/data/convert.py +0 -0
  24. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/bluetooth/data/framectrldata.py +0 -0
  25. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/bluetooth/data/notifydata.py +0 -0
  26. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/const.py +0 -0
  27. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/__init__.py +0 -0
  28. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/__init__.py +0 -0
  29. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/account.py +0 -0
  30. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/device.py +0 -0
  31. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/device_config.py +0 -0
  32. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/enums.py +0 -0
  33. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/excute_boarder_params.py +0 -0
  34. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/execute_boarder.py +0 -0
  35. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/generate_route_information.py +0 -0
  36. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/hash_list.py +0 -0
  37. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/location.py +0 -0
  38. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/mowing_modes.py +0 -0
  39. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/plan.py +0 -0
  40. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/rapid_state.py +0 -0
  41. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/region_data.py +0 -0
  42. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/model/report_info.py +0 -0
  43. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/mqtt/__init__.py +0 -0
  44. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/mqtt/event.py +0 -0
  45. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/mqtt/properties.py +0 -0
  46. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/mqtt/status.py +0 -0
  47. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/data/state_manager.py +0 -0
  48. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/event/__init__.py +0 -0
  49. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/event/event.py +0 -0
  50. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/http/_init_.py +0 -0
  51. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/http/http.py +0 -0
  52. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/__init__.py +0 -0
  53. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/commands/__init__.py +0 -0
  54. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/commands/abstract_message.py +0 -0
  55. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/commands/mammotion_command.py +0 -0
  56. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/commands/messages/__init__.py +0 -0
  57. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/commands/messages/driver.py +0 -0
  58. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/commands/messages/media.py +0 -0
  59. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/commands/messages/navigation.py +0 -0
  60. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/commands/messages/network.py +0 -0
  61. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/commands/messages/ota.py +0 -0
  62. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/commands/messages/system.py +0 -0
  63. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/commands/messages/video.py +0 -0
  64. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/control/__init__.py +0 -0
  65. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/control/joystick.py +0 -0
  66. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mammotion/devices/__init__.py +0 -0
  67. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mqtt/__init__.py +0 -0
  68. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/mqtt/mammotion_future.py +0 -0
  69. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/__init__.py +0 -0
  70. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/basestation.proto +0 -0
  71. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/basestation.py +0 -0
  72. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/basestation_pb2.py +0 -0
  73. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/basestation_pb2.pyi +0 -0
  74. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/common.proto +0 -0
  75. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/common.py +0 -0
  76. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/common_pb2.py +0 -0
  77. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/common_pb2.pyi +0 -0
  78. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/dev_net.proto +0 -0
  79. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/dev_net.py +0 -0
  80. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/dev_net_pb2.py +0 -0
  81. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/dev_net_pb2.pyi +0 -0
  82. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/luba_msg.proto +0 -0
  83. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/luba_msg.py +0 -0
  84. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/luba_msg_pb2.py +0 -0
  85. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/luba_msg_pb2.pyi +0 -0
  86. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/luba_mul.proto +0 -0
  87. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/luba_mul.py +0 -0
  88. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/luba_mul_pb2.py +0 -0
  89. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/luba_mul_pb2.pyi +0 -0
  90. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_driver.proto +0 -0
  91. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_driver.py +0 -0
  92. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_driver_pb2.py +0 -0
  93. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_driver_pb2.pyi +0 -0
  94. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_nav.proto +0 -0
  95. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_nav.py +0 -0
  96. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_nav_pb2.py +0 -0
  97. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_nav_pb2.pyi +0 -0
  98. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_ota.proto +0 -0
  99. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_ota.py +0 -0
  100. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_ota_pb2.py +0 -0
  101. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_ota_pb2.pyi +0 -0
  102. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_pept.proto +0 -0
  103. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_pept.py +0 -0
  104. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_pept_pb2.py +0 -0
  105. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_pept_pb2.pyi +0 -0
  106. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_sys.proto +0 -0
  107. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_sys.py +0 -0
  108. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_sys_pb2.py +0 -0
  109. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/proto/mctrl_sys_pb2.pyi +0 -0
  110. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/py.typed +0 -0
  111. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/utility/constant/__init__.py +0 -0
  112. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/utility/constant/device_constant.py +0 -0
  113. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/utility/datatype_converter.py +0 -0
  114. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/utility/device_type.py +0 -0
  115. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/utility/map.py +0 -0
  116. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/utility/periodic.py +0 -0
  117. {pymammotion-0.2.8 → pymammotion-0.2.10}/pymammotion/utility/rocker_util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymammotion
3
- Version: 0.2.8
3
+ Version: 0.2.10
4
4
  Summary:
5
5
  License: GNU-3.0
6
6
  Author: Michael Arthur
@@ -71,7 +71,7 @@ class CloudIOTGateway:
71
71
 
72
72
  converter = DatatypeConverter()
73
73
 
74
- def __init__(self, connect_response: ConnectResponse | None, login_by_oauth_response: LoginByOAuthResponse | None, aep_response: AepResponse | None, session_by_authcode_response: SessionByAuthCodeResponse | None, region_response: RegionResponse | None, dev_by_account: ListingDevByAccountResponse | None):
74
+ def __init__(self, connect_response: ConnectResponse | None = None, login_by_oauth_response: LoginByOAuthResponse | None = None, aep_response: AepResponse | None = None, session_by_authcode_response: SessionByAuthCodeResponse | None = None, region_response: RegionResponse | None = None, dev_by_account: ListingDevByAccountResponse | None = None):
75
75
  """Initialize the CloudIOTGateway."""
76
76
  self._app_key = APP_KEY
77
77
  self._app_secret = APP_SECRET
@@ -198,10 +198,11 @@ class MammotionDevices:
198
198
  async def create_devices(ble_device: BLEDevice,
199
199
  cloud_credentials: Credentials | None = None,
200
200
  preference: ConnectionPreference = ConnectionPreference.BLUETOOTH):
201
- cloud_client = await Mammotion.login(cloud_credentials.account_id or cloud_credentials.email, cloud_credentials.password)
202
201
  mammotion = Mammotion(ble_device, preference)
203
202
 
204
203
  if cloud_credentials:
204
+ cloud_client = await Mammotion.login(cloud_credentials.account_id or cloud_credentials.email,
205
+ cloud_credentials.password)
205
206
  await mammotion.initiate_cloud_connection(cloud_client)
206
207
 
207
208
  return mammotion
@@ -235,7 +236,7 @@ class Mammotion(object):
235
236
  return
236
237
 
237
238
  self.cloud_client = cloud_client
238
- self.mqtt = MammotionMQTT(region_id=cloud_client._region.data.regionId,
239
+ self.mqtt = MammotionMQTT(region_id=cloud_client._region_response.data.regionId,
239
240
  product_key=cloud_client._aep_response.data.productKey,
240
241
  device_name=cloud_client._aep_response.data.deviceName,
241
242
  device_secret=cloud_client._aep_response.data.deviceSecret,
@@ -332,8 +333,9 @@ class MammotionBaseDevice:
332
333
 
333
334
  _mower: MowingDevice
334
335
  _state_manager: StateManager
336
+ _cloud_device: Device | None = None
335
337
 
336
- def __init__(self, device: MowingDevice) -> None:
338
+ def __init__(self, device: MowingDevice, cloud_device: Device | None = None) -> None:
337
339
  """Initialize MammotionBaseDevice."""
338
340
  self.loop = asyncio.get_event_loop()
339
341
  self._raw_data = LubaMsg().to_dict(casing=betterproto.Casing.SNAKE)
@@ -342,12 +344,13 @@ class MammotionBaseDevice:
342
344
  self._state_manager.gethash_ack_callback = self.datahash_response
343
345
  self._state_manager.get_commondata_ack_callback = self.commdata_response
344
346
  self._notify_future: asyncio.Future[bytes] | None = None
347
+ self._cloud_device = cloud_device
345
348
 
346
349
  async def datahash_response(self, hash_ack: NavGetHashListAck):
347
350
  """Handle datahash responses."""
348
351
  result_hash = 0
349
352
  while hash_ack.data_couple[0] != result_hash:
350
- data = await self._send_command_with_args("synchronize_hash_data", hash_num=hash_ack.data_couple[0])
353
+ data = await self.queue_command("synchronize_hash_data", hash_num=hash_ack.data_couple[0])
351
354
  msg = LubaMsg().parse(data)
352
355
  if betterproto.serialized_on_wire(msg.nav.toapp_get_commondata_ack):
353
356
  result_hash = msg.nav.toapp_get_commondata_ack.hash
@@ -365,7 +368,7 @@ class MammotionBaseDevice:
365
368
  return
366
369
  result_hash = 0
367
370
  while data_hash != result_hash:
368
- data = await self._send_command_with_args("synchronize_hash_data", hash_num=data_hash)
371
+ data = await self.queue_command("synchronize_hash_data", hash_num=data_hash)
369
372
  msg = LubaMsg().parse(data)
370
373
  if betterproto.serialized_on_wire(msg.nav.toapp_get_commondata_ack):
371
374
  result_hash = msg.nav.toapp_get_commondata_ack.hash
@@ -377,7 +380,7 @@ class MammotionBaseDevice:
377
380
  region_data.type = common_data.type
378
381
  region_data.total_frame = total_frame
379
382
  region_data.current_frame = current_frame
380
- await self._send_command_with_args("get_regional_data", regional_data=region_data)
383
+ await self.queue_command("get_regional_data", regional_data=region_data)
381
384
 
382
385
  def _update_raw_data(self, data: bytes) -> None:
383
386
  """Update raw and model data from notifications."""
@@ -475,6 +478,10 @@ class MammotionBaseDevice:
475
478
  """Get the LubaMsg of the device."""
476
479
  return self._mower
477
480
 
481
+ @abstractmethod
482
+ async def queue_command(self, key: str, **kwargs: any) -> bytes:
483
+ """Queue commands to mower."""
484
+
478
485
  @abstractmethod
479
486
  async def _send_command(self, key: str, retry: int | None = None) -> bytes | None:
480
487
  """Send command to device and read response."""
@@ -505,9 +512,15 @@ class MammotionBaseDevice:
505
512
 
506
513
  await self._send_command_with_args("get_hash_response", total_frame=1, current_frame=1)
507
514
 
508
- await self._send_command_with_args(
509
- "get_area_name_list", device_id=self._mower.device.net.toapp_wifi_iot_status.devicename
510
- )
515
+ if self._cloud_device:
516
+ await self._send_command_with_args(
517
+ "get_area_name_list", device_id=self._cloud_device.deviceName
518
+ )
519
+ if has_field(self._mower.net.toapp_wifi_iot_status):
520
+ await self._send_command_with_args(
521
+ "get_area_name_list", device_id=self._mower.net.toapp_wifi_iot_status.devicename
522
+ )
523
+
511
524
 
512
525
  # sub_cmd 3 is job hashes??
513
526
  # sub_cmd 4 is dump location (yuka)
@@ -586,6 +599,9 @@ class MammotionBaseBLEDevice(MammotionBaseDevice):
586
599
  130, lambda: asyncio.ensure_future(self.run_periodic_sync_task())
587
600
  )
588
601
 
602
+ async def queue_command(self, key: str, **kwargs: any) -> bytes | None:
603
+ return await self._send_command_with_args(key, **kwargs)
604
+
589
605
  async def _send_command_with_args(self, key: str, **kwargs) -> bytes | None:
590
606
  """Send command to device and read response."""
591
607
  if self._operation_lock.locked():
@@ -655,7 +671,7 @@ class MammotionBaseBLEDevice(MammotionBaseDevice):
655
671
  def rssi(self) -> int:
656
672
  """Return RSSI of device."""
657
673
  try:
658
- return self._mower.device.sys.toapp_report_data.connect.ble_rssi
674
+ return self._mower.sys.toapp_report_data.connect.ble_rssi
659
675
  finally:
660
676
  return 0
661
677
 
@@ -938,9 +954,11 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
938
954
  mowing_state: MowingDevice
939
955
  ) -> None:
940
956
  """Initialize MammotionBaseCloudDevice."""
941
- super().__init__(mowing_state)
957
+ super().__init__(mowing_state, cloud_device)
942
958
  self._ble_sync_task = None
943
959
  self.is_ready = False
960
+ self.command_queue = asyncio.Queue()
961
+ self.processing_task = asyncio.create_task(self._process_queue())
944
962
  self._mqtt_client = mqtt_client
945
963
  self.iot_id = cloud_device.iotId
946
964
  self.device = cloud_device
@@ -966,7 +984,7 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
966
984
  async def on_ready(self):
967
985
  """Callback for when MQTT is subscribed to events."""
968
986
  if self.on_ready_callback:
969
- self.on_ready_callback()
987
+ await self.on_ready_callback()
970
988
 
971
989
  await self._ble_sync()
972
990
  await self.run_periodic_sync_task()
@@ -998,6 +1016,32 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
998
1016
  160, lambda: asyncio.ensure_future(self.run_periodic_sync_task())
999
1017
  )
1000
1018
 
1019
+ async def queue_command(self, key: str, **kwargs: any) -> bytes:
1020
+ # Create a future to hold the result
1021
+ _LOGGER.debug("Queueing command: %s", key)
1022
+ future = asyncio.Future()
1023
+ # Put the command in the queue as a tuple (key, command, future)
1024
+ command_bytes = getattr(self._commands, key)(**kwargs)
1025
+ await self.command_queue.put((key, command_bytes, future))
1026
+ # Wait for the future to be resolved
1027
+ return await future
1028
+
1029
+ async def _process_queue(self):
1030
+ while True:
1031
+ # Get the next item from the queue
1032
+ key, command, future = await self.command_queue.get()
1033
+ try:
1034
+ # Process the command using _execute_command_locked
1035
+ result = await self._execute_command_locked(key, command)
1036
+ # Set the result on the future
1037
+ future.set_result(result)
1038
+ except Exception as ex:
1039
+ # Set the exception on the future if something goes wrong
1040
+ future.set_exception(ex)
1041
+ finally:
1042
+ # Mark the task as done
1043
+ self.command_queue.task_done()
1044
+
1001
1045
  async def _on_mqtt_message(self, topic: str, payload: str, iot_id: str) -> None:
1002
1046
  """Handle incoming MQTT messages."""
1003
1047
  _LOGGER.debug("MQTT message received on topic %s: %s, iot_id: %s", topic, payload, iot_id)
@@ -57,7 +57,7 @@ class MammotionMQTT:
57
57
  ).hexdigest()
58
58
 
59
59
  self._client_id = client_id
60
- self.loop = asyncio.get_event_loop()
60
+ self.loop = asyncio.get_running_loop()
61
61
 
62
62
  self._linkkit_client = LinkKit(
63
63
  region_id,
@@ -139,7 +139,8 @@ class MammotionMQTT:
139
139
  payload = json.loads(payload)
140
140
  iot_id = payload.get("params", {}).get("iotId", "")
141
141
  if iot_id != "" and self.on_message:
142
- asyncio.run_coroutine_threadsafe(self.on_message(topic, payload, iot_id), self.loop).result()
142
+ future = asyncio.run_coroutine_threadsafe(self.on_message(topic, payload, iot_id), self.loop)
143
+ asyncio.wrap_future(future, loop=self.loop)
143
144
 
144
145
 
145
146
  def _thing_on_connect(self, session_flag, rc, user_data):
@@ -1,10 +1,10 @@
1
1
  [project]
2
2
  name = "pymammotion"
3
- version = "0.2.8"
3
+ version = "0.2.10"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "pymammotion"
7
- version = "0.2.8"
7
+ version = "0.2.10"
8
8
  license = "GNU-3.0"
9
9
  description = ""
10
10
  readme = "README.md"
@@ -53,7 +53,7 @@ mypy = "^1.10.0"
53
53
  pre-commit = "^3.7.1"
54
54
 
55
55
  [tool.bumpver]
56
- current_version = "0.2.8"
56
+ current_version = "0.2.10"
57
57
  version_pattern = "MAJOR.MINOR.PATCH"
58
58
  commit_message = "Bump version {old_version} -> {new_version}"
59
59
  commit = true
File without changes
File without changes