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.
- {pymammotion-0.2.3 → pymammotion-0.2.5}/PKG-INFO +1 -1
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/cloud_gateway.py +1 -1
- pymammotion-0.2.5/pymammotion/data/model/account.py +8 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/mammotion_command.py +2 -1
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/devices/mammotion.py +60 -33
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mqtt/mammotion_mqtt.py +1 -2
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pyproject.toml +3 -3
- pymammotion-0.2.3/pymammotion/data/model/account.py +0 -8
- {pymammotion-0.2.3 → pymammotion-0.2.5}/LICENSE +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/README.md +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/cloud_service.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/aep_response.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/connect_response.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/dev_by_account_response.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/login_by_oauth_response.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/regions_response.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/session_by_authcode_response.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/tmp_constant.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/ble.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/ble_message.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/const.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/data/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/data/convert.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/data/framectrldata.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/bluetooth/data/notifydata.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/const.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/device.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/device_config.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/enums.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/excute_boarder_params.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/execute_boarder.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/generate_route_information.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/hash_list.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/location.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/mowing_modes.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/plan.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/rapid_state.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/region_data.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/report_info.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/mqtt/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/mqtt/event.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/mqtt/properties.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/mqtt/status.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/state_manager.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/event/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/event/event.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/http/_init_.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/http/http.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/abstract_message.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/driver.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/media.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/navigation.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/network.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/ota.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/system.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/video.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/control/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/control/joystick.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/devices/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mqtt/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/basestation.proto +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/basestation.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/basestation_pb2.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/basestation_pb2.pyi +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/common.proto +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/common.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/common_pb2.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/common_pb2.pyi +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/dev_net.proto +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/dev_net.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/dev_net_pb2.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/dev_net_pb2.pyi +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_msg.proto +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_msg.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_msg_pb2.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_msg_pb2.pyi +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_mul.proto +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_mul.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_mul_pb2.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/luba_mul_pb2.pyi +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_driver.proto +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_driver.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_driver_pb2.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_driver_pb2.pyi +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_nav.proto +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_nav.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_nav_pb2.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_nav_pb2.pyi +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_ota.proto +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_ota.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_ota_pb2.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_ota_pb2.pyi +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_pept.proto +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_pept.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_pept_pb2.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_pept_pb2.pyi +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_sys.proto +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_sys.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_sys_pb2.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/proto/mctrl_sys_pb2.pyi +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/py.typed +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/utility/constant/__init__.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/utility/constant/device_constant.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/utility/datatype_converter.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/utility/device_type.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/utility/map.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/utility/periodic.py +0 -0
- {pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/utility/rocker_util.py +0 -0
|
@@ -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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
197
|
-
|
|
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
|
-
|
|
208
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
976
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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
|
+
version = "0.2.5"
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "pymammotion"
|
|
7
|
-
version = "0.2.
|
|
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.
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/dev_by_account_response.py
RENAMED
|
File without changes
|
{pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/login_by_oauth_response.py
RENAMED
|
File without changes
|
|
File without changes
|
{pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/aliyun/dataclass/session_by_authcode_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/data/model/generate_route_information.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pymammotion-0.2.3 → pymammotion-0.2.5}/pymammotion/mammotion/commands/messages/navigation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|