pymammotion 0.2.3__tar.gz → 0.2.5__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.

Potentially problematic release.


This version of pymammotion might be problematic. Click here for more details.

Files changed (117) hide show
  1. {pymammotion-0.2.3 → pymammotion-0.2.5}/PKG-INFO +1 -1
  2. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/cloud_gateway.py +1 -1
  3. pymammotion-0.2.5/pymammotion/data/model/account.py +8 -0
  4. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/mammotion_command.py +2 -1
  5. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/devices/mammotion.py +60 -33
  6. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mqtt/mammotion_mqtt.py +1 -2
  7. {pymammotion-0.2.3 → pymammotion-0.2.5}/pyproject.toml +3 -3
  8. pymammotion-0.2.3/pymammotion/data/model/account.py +0 -8
  9. {pymammotion-0.2.3 → pymammotion-0.2.5}/LICENSE +0 -0
  10. {pymammotion-0.2.3 → pymammotion-0.2.5}/README.md +0 -0
  11. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/__init__.py +0 -0
  12. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/__init__.py +0 -0
  13. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/cloud_service.py +0 -0
  14. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/aep_response.py +0 -0
  15. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/connect_response.py +0 -0
  16. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/dev_by_account_response.py +0 -0
  17. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/login_by_oauth_response.py +0 -0
  18. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/regions_response.py +0 -0
  19. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/session_by_authcode_response.py +0 -0
  20. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/tmp_constant.py +0 -0
  21. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/__init__.py +0 -0
  22. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/ble.py +0 -0
  23. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/ble_message.py +0 -0
  24. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/const.py +0 -0
  25. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/data/__init__.py +0 -0
  26. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/data/convert.py +0 -0
  27. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/data/framectrldata.py +0 -0
  28. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/data/notifydata.py +0 -0
  29. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/const.py +0 -0
  30. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/__init__.py +0 -0
  31. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/__init__.py +0 -0
  32. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/device.py +0 -0
  33. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/device_config.py +0 -0
  34. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/enums.py +0 -0
  35. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/excute_boarder_params.py +0 -0
  36. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/execute_boarder.py +0 -0
  37. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/generate_route_information.py +0 -0
  38. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/hash_list.py +0 -0
  39. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/location.py +0 -0
  40. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/mowing_modes.py +0 -0
  41. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/plan.py +0 -0
  42. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/rapid_state.py +0 -0
  43. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/region_data.py +0 -0
  44. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/report_info.py +0 -0
  45. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/mqtt/__init__.py +0 -0
  46. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/mqtt/event.py +0 -0
  47. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/mqtt/properties.py +0 -0
  48. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/mqtt/status.py +0 -0
  49. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/state_manager.py +0 -0
  50. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/event/__init__.py +0 -0
  51. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/event/event.py +0 -0
  52. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/http/_init_.py +0 -0
  53. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/http/http.py +0 -0
  54. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/__init__.py +0 -0
  55. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/__init__.py +0 -0
  56. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/abstract_message.py +0 -0
  57. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/__init__.py +0 -0
  58. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/driver.py +0 -0
  59. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/media.py +0 -0
  60. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/navigation.py +0 -0
  61. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/network.py +0 -0
  62. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/ota.py +0 -0
  63. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/system.py +0 -0
  64. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/video.py +0 -0
  65. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/control/__init__.py +0 -0
  66. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/control/joystick.py +0 -0
  67. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/devices/__init__.py +0 -0
  68. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mqtt/__init__.py +0 -0
  69. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/__init__.py +0 -0
  70. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/basestation.proto +0 -0
  71. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/basestation.py +0 -0
  72. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/basestation_pb2.py +0 -0
  73. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/basestation_pb2.pyi +0 -0
  74. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/common.proto +0 -0
  75. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/common.py +0 -0
  76. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/common_pb2.py +0 -0
  77. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/common_pb2.pyi +0 -0
  78. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/dev_net.proto +0 -0
  79. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/dev_net.py +0 -0
  80. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/dev_net_pb2.py +0 -0
  81. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/dev_net_pb2.pyi +0 -0
  82. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_msg.proto +0 -0
  83. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_msg.py +0 -0
  84. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_msg_pb2.py +0 -0
  85. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_msg_pb2.pyi +0 -0
  86. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_mul.proto +0 -0
  87. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_mul.py +0 -0
  88. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_mul_pb2.py +0 -0
  89. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_mul_pb2.pyi +0 -0
  90. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_driver.proto +0 -0
  91. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_driver.py +0 -0
  92. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_driver_pb2.py +0 -0
  93. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_driver_pb2.pyi +0 -0
  94. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_nav.proto +0 -0
  95. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_nav.py +0 -0
  96. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_nav_pb2.py +0 -0
  97. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_nav_pb2.pyi +0 -0
  98. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_ota.proto +0 -0
  99. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_ota.py +0 -0
  100. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_ota_pb2.py +0 -0
  101. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_ota_pb2.pyi +0 -0
  102. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_pept.proto +0 -0
  103. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_pept.py +0 -0
  104. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_pept_pb2.py +0 -0
  105. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_pept_pb2.pyi +0 -0
  106. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_sys.proto +0 -0
  107. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_sys.py +0 -0
  108. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_sys_pb2.py +0 -0
  109. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_sys_pb2.pyi +0 -0
  110. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/py.typed +0 -0
  111. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/utility/constant/__init__.py +0 -0
  112. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/utility/constant/device_constant.py +0 -0
  113. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/utility/datatype_converter.py +0 -0
  114. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/utility/device_type.py +0 -0
  115. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/utility/map.py +0 -0
  116. {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/utility/periodic.py +0 -0
  117. {pymammotion-0.2.3 → pymammotion-0.2.5}/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.3
3
+ Version: 0.2.5
4
4
  Summary:
5
5
  License: GNU-3.0
6
6
  Author: Michael Arthur
@@ -522,7 +522,7 @@ class CloudIOTGateway:
522
522
  logger.error(
523
523
  "Error in sending cloud command: %s - %s",
524
524
  str(response_body_dict.get("code")),
525
- str(response_body_dict["msg"]),
525
+ str(response_body_dict.get("msg")),
526
526
  )
527
527
  return ""
528
528
 
@@ -0,0 +1,8 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass
5
+ class Credentials:
6
+ email: str = None
7
+ password: str = None
8
+ account_id: str = None
@@ -1,3 +1,4 @@
1
+ from pymammotion.mammotion.commands.messages.driver import MessageDriver
1
2
  from pymammotion.mammotion.commands.messages.navigation import MessageNavigation
2
3
  from pymammotion.mammotion.commands.messages.network import MessageNetwork
3
4
  from pymammotion.mammotion.commands.messages.ota import MessageOta
@@ -6,7 +7,7 @@ from pymammotion.mammotion.commands.messages.video import MessageVideo
6
7
  from pymammotion.proto import dev_net_pb2, luba_msg_pb2
7
8
 
8
9
 
9
- class MammotionCommand(MessageSystem, MessageNavigation, MessageNetwork, MessageOta, MessageVideo):
10
+ class MammotionCommand(MessageSystem, MessageNavigation, MessageNetwork, MessageOta, MessageVideo, MessageDriver):
10
11
  """MQTT commands for Luba."""
11
12
 
12
13
  def __init__(self, device_name: str) -> None:
@@ -9,6 +9,7 @@ import json
9
9
  import logging
10
10
  from abc import abstractmethod
11
11
  from enum import Enum
12
+ from functools import cache
12
13
  from typing import Any, Callable, Optional, cast
13
14
  from uuid import UUID
14
15
 
@@ -172,12 +173,13 @@ class MammotionMixedDeviceManager:
172
173
 
173
174
  class MammotionDevices:
174
175
 
175
- devices = dict[str, MammotionMixedDeviceManager] = {}
176
+ devices: dict[str, MammotionMixedDeviceManager] = {}
176
177
 
177
178
  def add_device(self, mammotion_device: MammotionMixedDeviceManager) -> None:
178
179
  exists: MammotionMixedDeviceManager | None = self.devices.get(mammotion_device.name)
179
- if not exists:
180
+ if exists is None:
180
181
  self.devices[mammotion_device.name] = mammotion_device
182
+ return
181
183
  if mammotion_device.has_cloud():
182
184
  exists.replace_cloud(mammotion_device.cloud())
183
185
  if mammotion_device.has_ble():
@@ -186,16 +188,31 @@ class MammotionDevices:
186
188
  def get_device(self, mammotion_device_name: str) -> MammotionMixedDeviceManager:
187
189
  return self.devices.get(mammotion_device_name)
188
190
 
189
- class Mammotion:
191
+ async def create_devices(ble_device: BLEDevice,
192
+ cloud_credentials: Credentials | None = None,
193
+ preference: ConnectionPreference = ConnectionPreference.BLUETOOTH):
194
+ cloud_client = await Mammotion.login(cloud_credentials.account_id or cloud_credentials.email, cloud_credentials.password)
195
+ mammotion = Mammotion(ble_device, preference)
196
+
197
+ if cloud_credentials:
198
+ await mammotion.initiate_cloud_connection(cloud_client)
199
+
200
+ return mammotion
201
+
202
+
203
+ @cache
204
+ class Mammotion(object):
190
205
  """Represents a Mammotion device."""
191
206
 
192
207
  devices = MammotionDevices()
208
+ _mammotion_mqtt: MammotionMQTT | None = None
209
+
210
+
193
211
 
194
212
  def __init__(
195
213
  self,
196
- ble_device: BLEDevice,
197
- cloud_credentials: Credentials | None = None,
198
- preference: ConnectionPreference = ConnectionPreference.BLUETOOTH,
214
+ ble_device: BLEDevice,
215
+ preference: ConnectionPreference = ConnectionPreference.BLUETOOTH
199
216
  ) -> None:
200
217
  """Initialize MammotionDevice."""
201
218
  if ble_device:
@@ -204,25 +221,28 @@ class Mammotion:
204
221
  if preference:
205
222
  self._preference = preference
206
223
 
207
- if cloud_credentials:
208
- self.initiate_cloud_connection(cloud_credentials.account_id or cloud_credentials.email, cloud_credentials.password)
224
+ async def initiate_cloud_connection(self, cloud_client: CloudIOTGateway) -> None:
225
+ if self._mammotion_mqtt is not None:
226
+ if not self._mammotion_mqtt.is_connected:
227
+ loop = asyncio.get_running_loop()
228
+ await loop.run_in_executor(None, self._mammotion_mqtt.connect_async)
229
+ return
209
230
 
210
- async def initiate_cloud_connection(self, account: str, password: str):
211
- cloud_client = await self.login(account, password)
212
231
 
213
- _mammotion_mqtt = MammotionMQTT(region_id=cloud_client._region.data.regionId,
232
+ self._mammotion_mqtt = MammotionMQTT(region_id=cloud_client._region.data.regionId,
214
233
  product_key=cloud_client._aep_response.data.productKey,
215
234
  device_name=cloud_client._aep_response.data.deviceName,
216
235
  device_secret=cloud_client._aep_response.data.deviceSecret,
217
236
  iot_token=cloud_client._session_by_authcode_response.data.iotToken,
218
237
  client_id=cloud_client._client_id)
219
238
 
220
- _mammotion_mqtt._cloud_client = cloud_client
221
- _mammotion_mqtt.connect_async()
239
+ self._mammotion_mqtt._cloud_client = cloud_client
240
+ loop = asyncio.get_running_loop()
241
+ await loop.run_in_executor(None, self._mammotion_mqtt.connect_async)
222
242
 
223
243
  for device in cloud_client.listing_dev_by_account_response.data.data:
224
244
  if device.deviceName.startswith(("Luba-", "Yuka-")):
225
- self.devices.add_device(MammotionMixedDeviceManager(name=device.deviceName, cloud_device=device, mqtt=_mammotion_mqtt))
245
+ self.devices.add_device(MammotionMixedDeviceManager(name=device.deviceName, cloud_device=device, mqtt=self._mammotion_mqtt))
226
246
 
227
247
 
228
248
  @staticmethod
@@ -234,15 +254,17 @@ class Mammotion:
234
254
  country_code = mammotion_http.login_info.userInformation.domainAbbreviation
235
255
  _LOGGER.debug("CountryCode: " + country_code)
236
256
  _LOGGER.debug("AuthCode: " + mammotion_http.login_info.authorization_code)
237
- cloud_client.get_region(country_code, mammotion_http.login_info.authorization_code)
257
+ loop = asyncio.get_running_loop()
258
+ await loop.run_in_executor(None, cloud_client.get_region, country_code, mammotion_http.login_info.authorization_code)
238
259
  await cloud_client.connect()
239
260
  await cloud_client.login_by_oauth(country_code, mammotion_http.login_info.authorization_code)
240
- cloud_client.aep_handle()
241
- cloud_client.session_by_auth_code()
261
+ await loop.run_in_executor(None, cloud_client.aep_handle)
262
+ await loop.run_in_executor(None, cloud_client.session_by_auth_code)
242
263
 
243
- cloud_client.list_binding_by_account()
264
+ await loop.run_in_executor(None, cloud_client.list_binding_by_account)
244
265
  return cloud_client
245
266
 
267
+
246
268
  def get_device_by_name(self, name: str) -> MammotionMixedDeviceManager:
247
269
  return self.devices.get_device(name)
248
270
 
@@ -256,7 +278,7 @@ class Mammotion:
256
278
  return await device.cloud().command(key)
257
279
  # TODO work with both with EITHER
258
280
 
259
- async def send_command_with_args(self,name: str, key: str, kwargs):
281
+ async def send_command_with_args(self,name: str, key: str, **kwargs: any):
260
282
  """Send a command with args to the device."""
261
283
  device = self.get_device_by_name(name)
262
284
  if device:
@@ -287,7 +309,7 @@ class Mammotion:
287
309
  def mower(self, name: str):
288
310
  device = self.get_device_by_name(name)
289
311
  if device:
290
- return device.mower_state
312
+ return device.mower_state()
291
313
 
292
314
  def has_field(message: betterproto.Message) -> bool:
293
315
  """Check if the message has any fields serialized on wire."""
@@ -905,22 +927,26 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
905
927
  if self.on_ready_callback:
906
928
  self.on_ready_callback()
907
929
 
930
+ asyncio.run(self._ble_sync())
931
+ asyncio.run(self.run_periodic_sync_task())
932
+
908
933
  def on_connected(self):
909
934
  """Callback for when MQTT connects."""
910
- self._ble_sync()
911
- self.run_periodic_sync_task()
935
+
912
936
 
913
937
  def on_disconnected(self):
914
938
  """Callback for when MQTT disconnects."""
915
939
 
916
- def _ble_sync(self):
940
+ async def _ble_sync(self):
917
941
  command_bytes = self._commands.send_todev_ble_sync(3)
918
- self._mqtt_client.get_cloud_client().send_cloud_command(self.iot_id, command_bytes)
942
+ loop = asyncio.get_running_loop()
943
+ await loop.run_in_executor(None, self._mqtt_client.get_cloud_client().send_cloud_command, self.iot_id, command_bytes)
944
+
919
945
 
920
946
  async def run_periodic_sync_task(self) -> None:
921
947
  """Send ble sync to robot."""
922
948
  try:
923
- self._ble_sync()
949
+ await self._ble_sync()
924
950
  finally:
925
951
  self.schedule_ble_sync()
926
952
 
@@ -943,14 +969,14 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
943
969
  async def _send_command(self, key: str, retry: int | None = None) -> bytes | None:
944
970
  """Send command to device via MQTT and read response."""
945
971
  if self._operation_lock.locked():
946
- _LOGGER.debug("%s: Operation already in progress, waiting for it to complete;", self.nick_name)
972
+ _LOGGER.debug("%s: Operation already in progress, waiting for it to complete;", self.device.nickName)
947
973
 
948
974
  async with self._operation_lock:
949
975
  try:
950
976
  command_bytes = getattr(self._commands, key)()
951
977
  return await self._send_command_locked(key, command_bytes)
952
978
  except Exception as ex:
953
- _LOGGER.exception("%s: error in sending command - %s", self.nick_name, ex)
979
+ _LOGGER.exception("%s: error in sending command - %s", self.device.nickName, ex)
954
980
  raise
955
981
 
956
982
  async def _send_command_locked(self, key: str, command: bytes) -> bytes:
@@ -962,7 +988,7 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
962
988
  await asyncio.sleep(DBUS_ERROR_BACKOFF_TIME)
963
989
  _LOGGER.debug(
964
990
  "%s: error in _send_command_locked: %s",
965
- self.nick_name,
991
+ self.device.nickName,
966
992
  ex,
967
993
  )
968
994
  raise
@@ -972,8 +998,9 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
972
998
  assert self._mqtt_client is not None
973
999
  self._notify_future = self.loop.create_future()
974
1000
  self._key = key
975
- _LOGGER.debug("%s: Sending command: %s", self.nick_name, key)
976
- self._mqtt_client.get_cloud_client().send_cloud_command(self.iot_id, command)
1001
+ _LOGGER.debug("%s: Sending command: %s", self.device.nickName, key)
1002
+ loop = asyncio.get_running_loop()
1003
+ await loop.run_in_executor(None, self._mqtt_client.get_cloud_client().send_cloud_command, self.iot_id, command)
977
1004
 
978
1005
  retry_handle = self.loop.call_at(
979
1006
  self.loop.time() + 20,
@@ -997,20 +1024,20 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
997
1024
  retry_handle.cancel()
998
1025
  self._notify_future = None
999
1026
 
1000
- _LOGGER.debug("%s: Message received", self.nick_name)
1027
+ _LOGGER.debug("%s: Message received", self.device.nickName)
1001
1028
 
1002
1029
  return notify_msg
1003
1030
 
1004
1031
  async def _send_command_with_args(self, key: str, **kwargs: any) -> bytes | None:
1005
1032
  """Send command with arguments to device via MQTT and read response."""
1006
1033
  if self._operation_lock.locked():
1007
- _LOGGER.debug("%s: Operation already in progress, waiting for it to complete;", self.nick_name)
1034
+ _LOGGER.debug("%s: Operation already in progress, waiting for it to complete;", self.device.nickName)
1008
1035
  async with self._operation_lock:
1009
1036
  try:
1010
1037
  command_bytes = getattr(self._commands, key)(**kwargs)
1011
1038
  return await self._send_command_locked(key, command_bytes)
1012
1039
  except Exception as ex:
1013
- _LOGGER.exception("%s: error in sending command - %s", self.nick_name, ex)
1040
+ _LOGGER.exception("%s: error in sending command - %s", self.device.nickName, ex)
1014
1041
  raise
1015
1042
 
1016
1043
  def _extract_message_id(self, payload: dict) -> str:
@@ -147,12 +147,11 @@ class MammotionMQTT:
147
147
 
148
148
  # self._linkkit_client.subscribe_topic(f"/sys/{self._product_key}/{self._device_name}/#")
149
149
 
150
- def _on_disconnect(self, _client, _userdata, rc: int):
150
+ def _on_disconnect(self, _client, _userdata):
151
151
  """Is called on disconnect."""
152
152
  logger.info("Disconnected")
153
153
  self.is_connected = False
154
154
  self.is_ready = False
155
- logger.debug(rc)
156
155
  if self.on_disconnected:
157
156
  self.on_disconnected()
158
157
 
@@ -1,10 +1,10 @@
1
1
  [project]
2
2
  name = "pymammotion"
3
- version = "0.2.3"
3
+ version = "0.2.5"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "pymammotion"
7
- version = "0.2.3"
7
+ version = "0.2.5"
8
8
  license = "GNU-3.0"
9
9
  description = ""
10
10
  readme = "README.md"
@@ -52,7 +52,7 @@ mypy = "^1.10.0"
52
52
  pre-commit = "^3.7.1"
53
53
 
54
54
  [tool.bumpver]
55
- current_version = "0.2.3"
55
+ current_version = "0.2.5"
56
56
  version_pattern = "MAJOR.MINOR.PATCH"
57
57
  commit_message = "Bump version {old_version} -> {new_version}"
58
58
  commit = true
@@ -1,8 +0,0 @@
1
- from dataclasses import dataclass
2
-
3
-
4
- @dataclass
5
- class Credentials:
6
- email: str
7
- password: str
8
- account_id: str
File without changes
File without changes