pymammotion 0.5.34__py3-none-any.whl → 0.5.53__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.
Potentially problematic release.
This version of pymammotion might be problematic. Click here for more details.
- pymammotion/__init__.py +3 -3
- pymammotion/aliyun/cloud_gateway.py +106 -18
- pymammotion/aliyun/model/dev_by_account_response.py +169 -21
- pymammotion/const.py +3 -0
- pymammotion/data/model/device.py +22 -9
- pymammotion/data/model/device_config.py +1 -1
- pymammotion/data/model/device_info.py +1 -0
- pymammotion/data/model/enums.py +5 -3
- pymammotion/data/model/events.py +14 -0
- pymammotion/data/model/generate_geojson.py +551 -0
- pymammotion/data/model/generate_route_information.py +2 -2
- pymammotion/data/model/hash_list.py +129 -33
- pymammotion/data/model/location.py +4 -4
- pymammotion/data/model/region_data.py +4 -4
- pymammotion/data/model/report_info.py +7 -0
- pymammotion/data/{state_manager.py → mower_state_manager.py} +75 -11
- pymammotion/data/mqtt/event.py +47 -22
- pymammotion/data/mqtt/mammotion_properties.py +257 -0
- pymammotion/data/mqtt/properties.py +32 -29
- pymammotion/data/mqtt/status.py +17 -16
- pymammotion/event/event.py +5 -2
- pymammotion/homeassistant/__init__.py +3 -0
- pymammotion/homeassistant/mower_api.py +484 -0
- pymammotion/homeassistant/rtk_api.py +54 -0
- pymammotion/http/http.py +394 -14
- pymammotion/http/model/http.py +82 -2
- pymammotion/http/model/response_factory.py +10 -4
- pymammotion/mammotion/commands/mammotion_command.py +6 -0
- pymammotion/mammotion/commands/messages/navigation.py +39 -6
- pymammotion/mammotion/devices/__init__.py +27 -3
- pymammotion/mammotion/devices/base.py +16 -138
- pymammotion/mammotion/devices/mammotion.py +369 -200
- pymammotion/mammotion/devices/mammotion_bluetooth.py +7 -5
- pymammotion/mammotion/devices/mammotion_cloud.py +42 -83
- pymammotion/mammotion/devices/mammotion_mower_ble.py +49 -0
- pymammotion/mammotion/devices/mammotion_mower_cloud.py +39 -0
- pymammotion/mammotion/devices/managers/managers.py +81 -0
- pymammotion/mammotion/devices/mower_device.py +124 -0
- pymammotion/mammotion/devices/mower_manager.py +107 -0
- pymammotion/mammotion/devices/rtk_ble.py +89 -0
- pymammotion/mammotion/devices/rtk_cloud.py +113 -0
- pymammotion/mammotion/devices/rtk_device.py +50 -0
- pymammotion/mammotion/devices/rtk_manager.py +122 -0
- pymammotion/mqtt/__init__.py +2 -1
- pymammotion/mqtt/aliyun_mqtt.py +232 -0
- pymammotion/mqtt/mammotion_mqtt.py +174 -192
- pymammotion/mqtt/mqtt_models.py +66 -0
- pymammotion/proto/__init__.py +3 -3
- pymammotion/proto/mctrl_nav.proto +1 -1
- pymammotion/proto/mctrl_nav_pb2.py +1 -1
- pymammotion/proto/mctrl_nav_pb2.pyi +4 -4
- pymammotion/proto/mctrl_sys.proto +1 -1
- pymammotion/proto/mctrl_sys_pb2.py +1 -1
- pymammotion/utility/constant/device_constant.py +1 -1
- pymammotion/utility/datatype_converter.py +13 -12
- pymammotion/utility/device_type.py +88 -3
- pymammotion/utility/map.py +238 -51
- pymammotion/utility/mur_mur_hash.py +132 -87
- {pymammotion-0.5.34.dist-info → pymammotion-0.5.53.dist-info}/METADATA +26 -31
- {pymammotion-0.5.34.dist-info → pymammotion-0.5.53.dist-info}/RECORD +67 -51
- {pymammotion-0.5.34.dist-info → pymammotion-0.5.53.dist-info}/WHEEL +1 -1
- pymammotion/http/_init_.py +0 -0
- {pymammotion-0.5.34.dist-info → pymammotion-0.5.53.dist-info/licenses}/LICENSE +0 -0
|
@@ -7,19 +7,20 @@ T = TypeVar("T")
|
|
|
7
7
|
|
|
8
8
|
def deserialize_data(value, target_type):
|
|
9
9
|
"""Deserialize data into a specified target type.
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
The function handles deserialization of basic types, lists, and unions. It
|
|
12
12
|
recursively processes list elements and supports optional types by handling
|
|
13
13
|
Union[T, None]. For custom types with a `from_dict` method, it calls this
|
|
14
14
|
method for deserialization. If the target type is unknown or unsupported, it
|
|
15
15
|
returns the value unchanged.
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
Args:
|
|
18
18
|
value: The data to be deserialized.
|
|
19
19
|
target_type (type): The desired type into which the data should be deserialized.
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
Returns:
|
|
22
22
|
The deserialized data in the specified target type.
|
|
23
|
+
|
|
23
24
|
"""
|
|
24
25
|
if value is None:
|
|
25
26
|
return None
|
|
@@ -35,7 +36,12 @@ def deserialize_data(value, target_type):
|
|
|
35
36
|
# Support Optional[T] = Union[T, None]
|
|
36
37
|
non_none_types = [t for t in args if t is not type(None)]
|
|
37
38
|
if len(non_none_types) == 1:
|
|
38
|
-
|
|
39
|
+
target = non_none_types[0]
|
|
40
|
+
# Handle Response[list[type]] case
|
|
41
|
+
if get_origin(target) is list and get_args(target):
|
|
42
|
+
item_type = get_args(target)[0]
|
|
43
|
+
return [deserialize_data(v, item_type) for v in value]
|
|
44
|
+
return deserialize_data(value, target)
|
|
39
45
|
|
|
40
46
|
if hasattr(target_type, "from_dict"):
|
|
41
47
|
return target_type.from_dict(value)
|
|
@@ -44,6 +44,12 @@ class MammotionCommand(
|
|
|
44
44
|
# 1 multipoint turn
|
|
45
45
|
return self.read_write_device(6, context, 1)
|
|
46
46
|
|
|
47
|
+
def get_error_code(self) -> bytes:
|
|
48
|
+
return self.read_write_device(5, 2, 1)
|
|
49
|
+
|
|
50
|
+
def get_error_timestamp(self) -> bytes:
|
|
51
|
+
return self.read_write_device(5, 3, 1)
|
|
52
|
+
|
|
47
53
|
def get_device_product_key(self) -> str:
|
|
48
54
|
return self._product_key
|
|
49
55
|
|
|
@@ -33,7 +33,7 @@ logger = logging.getLogger(__name__)
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
class MessageNavigation(AbstractMessage, ABC):
|
|
36
|
-
def send_order_msg_nav(self, build) -> bytes:
|
|
36
|
+
def send_order_msg_nav(self, build: MctlNav) -> bytes:
|
|
37
37
|
luba_msg = LubaMsg(
|
|
38
38
|
msgtype=MsgCmdType.NAV,
|
|
39
39
|
sender=MsgDevice.DEV_MOBILEAPP,
|
|
@@ -206,9 +206,9 @@ class MessageNavigation(AbstractMessage, ABC):
|
|
|
206
206
|
reserved=plan_bean.reserved,
|
|
207
207
|
weeks=plan_bean.weeks,
|
|
208
208
|
start_date=plan_bean.start_date,
|
|
209
|
-
trigger_type=plan_bean.
|
|
210
|
-
day=plan_bean.
|
|
211
|
-
toward_included_angle=plan_bean.
|
|
209
|
+
trigger_type=plan_bean.trigger_type,
|
|
210
|
+
day=plan_bean.day,
|
|
211
|
+
toward_included_angle=plan_bean.toward_included_angle,
|
|
212
212
|
toward_mode=0,
|
|
213
213
|
)
|
|
214
214
|
logger.debug(f"Send read job plan command planBean={plan_bean}")
|
|
@@ -245,6 +245,35 @@ class MessageNavigation(AbstractMessage, ABC):
|
|
|
245
245
|
logger.debug(f"Send command--Read plan time {sub_cmd}")
|
|
246
246
|
return self.send_order_msg_nav(build2)
|
|
247
247
|
|
|
248
|
+
def read_job_not_not_disturb(self) -> bytes:
|
|
249
|
+
build = NavUnableTimeSet(sub_cmd=2)
|
|
250
|
+
build2 = MctlNav(todev_unable_time_set=build)
|
|
251
|
+
logger.debug(f"Send command--Read job dnd {2}")
|
|
252
|
+
return self.send_order_msg_nav(build2)
|
|
253
|
+
|
|
254
|
+
def job_animal_protect_read(self) -> bytes:
|
|
255
|
+
"""Read animal protection settings."""
|
|
256
|
+
build = NavUnableTimeSet(sub_cmd=2, trigger=99)
|
|
257
|
+
build2 = MctlNav(todev_unable_time_set=build)
|
|
258
|
+
logger.debug(f"Send command - Read job do not disturb time subCmd2 {build}")
|
|
259
|
+
return self.send_order_msg_nav(build2)
|
|
260
|
+
|
|
261
|
+
def job_do_not_disturb(self, unable_start_time: str, unable_end_time: str) -> bytes:
|
|
262
|
+
"""Set do not disturb time period."""
|
|
263
|
+
build = MctlNav(
|
|
264
|
+
todev_unable_time_set=NavUnableTimeSet(
|
|
265
|
+
sub_cmd=1, trigger=1, unable_start_time=unable_start_time, unable_end_time=unable_end_time
|
|
266
|
+
)
|
|
267
|
+
)
|
|
268
|
+
logger.debug(f"Send command - Set job do not disturb time: {unable_start_time} - {unable_end_time}")
|
|
269
|
+
return self.send_order_msg_nav(build)
|
|
270
|
+
|
|
271
|
+
def job_do_not_disturb_del(self) -> bytes:
|
|
272
|
+
"""Delete do not disturb settings."""
|
|
273
|
+
build = MctlNav(todev_unable_time_set=NavUnableTimeSet(sub_cmd=1, trigger=0))
|
|
274
|
+
logger.debug("Send command - Turn off do not disturb time")
|
|
275
|
+
return self.send_order_msg_nav(build)
|
|
276
|
+
|
|
248
277
|
def query_job_history(self) -> bytes:
|
|
249
278
|
return self.send_order_msg_nav(MctlNav(todev_work_report_update_cmd=WorkReportUpdateCmd(sub_cmd=1)))
|
|
250
279
|
|
|
@@ -262,7 +291,7 @@ class MessageNavigation(AbstractMessage, ABC):
|
|
|
262
291
|
toapp_map_name_msg=NavMapNameMsg(
|
|
263
292
|
hash=0,
|
|
264
293
|
result=0,
|
|
265
|
-
device_id=device_id, #
|
|
294
|
+
device_id=device_id, # iot_id
|
|
266
295
|
rw=0,
|
|
267
296
|
)
|
|
268
297
|
)
|
|
@@ -390,7 +419,7 @@ class MessageNavigation(AbstractMessage, ABC):
|
|
|
390
419
|
generate_route_information}")
|
|
391
420
|
return self.send_order_msg_nav(MctlNav(bidire_reqconver_path=build))
|
|
392
421
|
|
|
393
|
-
def
|
|
422
|
+
def modify_route_information(self, generate_route_information: GenerateRouteInformation) -> bytes:
|
|
394
423
|
logger.debug(f"Generate route data source: {generate_route_information}")
|
|
395
424
|
build = NavReqCoverPath(
|
|
396
425
|
pver=1,
|
|
@@ -432,7 +461,11 @@ class MessageNavigation(AbstractMessage, ABC):
|
|
|
432
461
|
return self.send_order_msg_nav(build)
|
|
433
462
|
|
|
434
463
|
def get_line_info_list(self, hash_list: list[int], transaction_id: int) -> bytes:
|
|
464
|
+
"""Get route information (mow path) corresponding to the specified hash list based on time.
|
|
465
|
+
e.g transaction_id = int(time.time() * 1000)
|
|
466
|
+
"""
|
|
435
467
|
logger.debug(f"Sending==========Get route command: {hash_list}")
|
|
468
|
+
|
|
436
469
|
build = MctlNav(
|
|
437
470
|
app_request_cover_paths=AppRequestCoverPathsT(
|
|
438
471
|
pver=1, hash_list=hash_list, transaction_id=transaction_id, sub_cmd=0
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Mammotion devices module."""
|
|
2
2
|
|
|
3
|
-
from .mammotion import
|
|
3
|
+
from .mammotion import Mammotion, MammotionDeviceManager
|
|
4
|
+
from .mammotion_bluetooth import MammotionBaseBLEDevice
|
|
5
|
+
from .mammotion_cloud import MammotionBaseCloudDevice, MammotionCloud
|
|
6
|
+
from .mammotion_mower_ble import MammotionMowerBLEDevice
|
|
7
|
+
from .mammotion_mower_cloud import MammotionMowerCloudDevice
|
|
8
|
+
from .mower_device import MammotionMowerDevice
|
|
9
|
+
from .mower_manager import MammotionMowerDeviceManager
|
|
10
|
+
from .rtk_ble import MammotionRTKBLEDevice
|
|
11
|
+
from .rtk_cloud import MammotionRTKCloudDevice
|
|
12
|
+
from .rtk_device import MammotionRTKDevice
|
|
13
|
+
from .rtk_manager import MammotionRTKDeviceManager
|
|
4
14
|
|
|
5
|
-
__all__ = [
|
|
15
|
+
__all__ = [
|
|
16
|
+
"Mammotion",
|
|
17
|
+
"MammotionDeviceManager",
|
|
18
|
+
"MammotionMowerDeviceManager",
|
|
19
|
+
"MammotionBaseBLEDevice",
|
|
20
|
+
"MammotionBaseCloudDevice",
|
|
21
|
+
"MammotionCloud",
|
|
22
|
+
"MammotionMowerBLEDevice",
|
|
23
|
+
"MammotionMowerCloudDevice",
|
|
24
|
+
"MammotionMowerDevice",
|
|
25
|
+
"MammotionRTKBLEDevice",
|
|
26
|
+
"MammotionRTKCloudDevice",
|
|
27
|
+
"MammotionRTKDevice",
|
|
28
|
+
"MammotionRTKDeviceManager",
|
|
29
|
+
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from abc import abstractmethod
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
2
|
import asyncio
|
|
3
3
|
import logging
|
|
4
4
|
from typing import Any
|
|
@@ -6,35 +6,18 @@ from typing import Any
|
|
|
6
6
|
import betterproto2
|
|
7
7
|
|
|
8
8
|
from pymammotion.aliyun.model.dev_by_account_response import Device
|
|
9
|
-
from pymammotion.data.model import RegionData
|
|
10
9
|
from pymammotion.data.model.device import MowingDevice
|
|
11
10
|
from pymammotion.data.model.raw_data import RawMowerData
|
|
12
|
-
from pymammotion.data.
|
|
13
|
-
from pymammotion.proto import LubaMsg
|
|
14
|
-
from pymammotion.utility.device_type import DeviceType
|
|
11
|
+
from pymammotion.data.mower_state_manager import MowerStateManager
|
|
12
|
+
from pymammotion.proto import LubaMsg
|
|
15
13
|
|
|
16
14
|
_LOGGER = logging.getLogger(__name__)
|
|
17
15
|
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
try:
|
|
21
|
-
# Find the index of the current integer
|
|
22
|
-
current_index = lst.index(current_hash)
|
|
23
|
-
|
|
24
|
-
# Check if there is a next integer in the list
|
|
25
|
-
if current_index + 1 < len(lst):
|
|
26
|
-
return lst[current_index + 1]
|
|
27
|
-
else:
|
|
28
|
-
return None # Or raise an exception or handle it in some other way
|
|
29
|
-
except ValueError:
|
|
30
|
-
# Handle the case where current_int is not in the list
|
|
31
|
-
return None # Or raise an exception or handle it in some other way
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class MammotionBaseDevice:
|
|
17
|
+
class MammotionBaseDevice(ABC):
|
|
35
18
|
"""Base class for Mammotion devices."""
|
|
36
19
|
|
|
37
|
-
def __init__(self, state_manager:
|
|
20
|
+
def __init__(self, state_manager: MowerStateManager, cloud_device: Device) -> None:
|
|
38
21
|
"""Initialize MammotionBaseDevice."""
|
|
39
22
|
self.loop = asyncio.get_event_loop()
|
|
40
23
|
self._state_manager = state_manager
|
|
@@ -43,57 +26,6 @@ class MammotionBaseDevice:
|
|
|
43
26
|
self._notify_future: asyncio.Future[bytes] | None = None
|
|
44
27
|
self._cloud_device = cloud_device
|
|
45
28
|
|
|
46
|
-
async def datahash_response(self, hash_ack: NavGetHashListAck) -> None:
|
|
47
|
-
"""Handle datahash responses for root level hashs."""
|
|
48
|
-
current_frame = hash_ack.current_frame
|
|
49
|
-
|
|
50
|
-
missing_frames = self.mower.map.missing_root_hash_frame(hash_ack)
|
|
51
|
-
if len(missing_frames) == 0:
|
|
52
|
-
if len(self.mower.map.missing_hashlist(hash_ack.sub_cmd)) > 0:
|
|
53
|
-
data_hash = self.mower.map.missing_hashlist(hash_ack.sub_cmd).pop(0)
|
|
54
|
-
await self.queue_command("synchronize_hash_data", hash_num=data_hash)
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
if current_frame != missing_frames[0] - 1:
|
|
58
|
-
current_frame = missing_frames[0] - 1
|
|
59
|
-
await self.queue_command("get_hash_response", total_frame=hash_ack.total_frame, current_frame=current_frame)
|
|
60
|
-
|
|
61
|
-
async def commdata_response(self, common_data: NavGetCommDataAck | SvgMessageAckT) -> None:
|
|
62
|
-
"""Handle common data responses."""
|
|
63
|
-
total_frame = common_data.total_frame
|
|
64
|
-
current_frame = common_data.current_frame
|
|
65
|
-
|
|
66
|
-
missing_frames = self.mower.map.missing_frame(common_data)
|
|
67
|
-
if len(missing_frames) == 0:
|
|
68
|
-
# get next in hash ack list
|
|
69
|
-
|
|
70
|
-
data_hash = (
|
|
71
|
-
self.mower.map.missing_hashlist(common_data.sub_cmd).pop(0)
|
|
72
|
-
if len(self.mower.map.missing_hashlist(common_data.sub_cmd)) > 0
|
|
73
|
-
else None
|
|
74
|
-
)
|
|
75
|
-
if data_hash is None:
|
|
76
|
-
return
|
|
77
|
-
|
|
78
|
-
await self.queue_command("synchronize_hash_data", hash_num=data_hash)
|
|
79
|
-
else:
|
|
80
|
-
if current_frame != missing_frames[0] - 1:
|
|
81
|
-
current_frame = missing_frames[0] - 1
|
|
82
|
-
|
|
83
|
-
region_data = RegionData()
|
|
84
|
-
region_data.hash = common_data.data_hash if isinstance(common_data, SvgMessageAckT) else common_data.hash
|
|
85
|
-
region_data.action = common_data.action if isinstance(common_data, NavGetCommDataAck) else None
|
|
86
|
-
region_data.type = common_data.type
|
|
87
|
-
region_data.sub_cmd = common_data.sub_cmd
|
|
88
|
-
region_data.total_frame = total_frame
|
|
89
|
-
region_data.current_frame = current_frame
|
|
90
|
-
await self.queue_command("get_regional_data", regional_data=region_data)
|
|
91
|
-
|
|
92
|
-
async def plan_callback(self, plan: NavPlanJobSet) -> None:
|
|
93
|
-
if plan.plan_index < plan.total_plan_num - 1:
|
|
94
|
-
index = plan.plan_index + 1
|
|
95
|
-
await self.queue_command("read_plan", sub_cmd=2, plan_index=index)
|
|
96
|
-
|
|
97
29
|
def _update_raw_data(self, data: bytes) -> None:
|
|
98
30
|
"""Update raw and model data from notifications."""
|
|
99
31
|
tmp_msg = LubaMsg().parse(data)
|
|
@@ -127,7 +59,7 @@ class MammotionBaseDevice:
|
|
|
127
59
|
nav[nav_sub_msg[0]] = nav_sub_msg[1].to_dict(casing=betterproto2.Casing.SNAKE)
|
|
128
60
|
self._raw_data["nav"] = nav
|
|
129
61
|
|
|
130
|
-
def _update_sys_data(self, tmp_msg) -> None:
|
|
62
|
+
def _update_sys_data(self, tmp_msg: LubaMsg) -> None:
|
|
131
63
|
"""Update system data."""
|
|
132
64
|
sys_sub_msg = betterproto2.which_one_of(tmp_msg.sys, "SubSysMsg")
|
|
133
65
|
if sys_sub_msg[1] is None:
|
|
@@ -137,7 +69,7 @@ class MammotionBaseDevice:
|
|
|
137
69
|
sys[sys_sub_msg[0]] = sys_sub_msg[1].to_dict(casing=betterproto2.Casing.SNAKE)
|
|
138
70
|
self._raw_data["sys"] = sys
|
|
139
71
|
|
|
140
|
-
def _update_driver_data(self, tmp_msg) -> None:
|
|
72
|
+
def _update_driver_data(self, tmp_msg: LubaMsg) -> None:
|
|
141
73
|
"""Update driver data."""
|
|
142
74
|
drv_sub_msg = betterproto2.which_one_of(tmp_msg.driver, "SubDrvMsg")
|
|
143
75
|
if drv_sub_msg[1] is None:
|
|
@@ -147,7 +79,7 @@ class MammotionBaseDevice:
|
|
|
147
79
|
drv[drv_sub_msg[0]] = drv_sub_msg[1].to_dict(casing=betterproto2.Casing.SNAKE)
|
|
148
80
|
self._raw_data["driver"] = drv
|
|
149
81
|
|
|
150
|
-
def _update_net_data(self, tmp_msg) -> None:
|
|
82
|
+
def _update_net_data(self, tmp_msg: LubaMsg) -> None:
|
|
151
83
|
"""Update network data."""
|
|
152
84
|
net_sub_msg = betterproto2.which_one_of(tmp_msg.net, "NetSubType")
|
|
153
85
|
if net_sub_msg[1] is None:
|
|
@@ -160,7 +92,7 @@ class MammotionBaseDevice:
|
|
|
160
92
|
net[net_sub_msg[0]] = net_sub_msg[1].to_dict(casing=betterproto2.Casing.SNAKE)
|
|
161
93
|
self._raw_data["net"] = net
|
|
162
94
|
|
|
163
|
-
def _update_mul_data(self, tmp_msg) -> None:
|
|
95
|
+
def _update_mul_data(self, tmp_msg: LubaMsg) -> None:
|
|
164
96
|
"""Update mul data."""
|
|
165
97
|
mul_sub_msg = betterproto2.which_one_of(tmp_msg.mul, "SubMul")
|
|
166
98
|
if mul_sub_msg[1] is None:
|
|
@@ -170,7 +102,7 @@ class MammotionBaseDevice:
|
|
|
170
102
|
mul[mul_sub_msg[0]] = mul_sub_msg[1].to_dict(casing=betterproto2.Casing.SNAKE)
|
|
171
103
|
self._raw_data["mul"] = mul
|
|
172
104
|
|
|
173
|
-
def _update_ota_data(self, tmp_msg) -> None:
|
|
105
|
+
def _update_ota_data(self, tmp_msg: LubaMsg) -> None:
|
|
174
106
|
"""Update OTA data."""
|
|
175
107
|
ota_sub_msg = betterproto2.which_one_of(tmp_msg.ota, "SubOtaMsg")
|
|
176
108
|
if ota_sub_msg[1] is None:
|
|
@@ -191,71 +123,17 @@ class MammotionBaseDevice:
|
|
|
191
123
|
return self._state_manager.get_device()
|
|
192
124
|
|
|
193
125
|
@abstractmethod
|
|
194
|
-
async def queue_command(self, key: str, **kwargs:
|
|
126
|
+
async def queue_command(self, key: str, **kwargs: Any) -> None:
|
|
195
127
|
"""Queue commands to mower."""
|
|
196
128
|
|
|
197
129
|
@abstractmethod
|
|
198
|
-
async def _ble_sync(self):
|
|
130
|
+
async def _ble_sync(self) -> None:
|
|
199
131
|
"""Send ble sync command every 3 seconds or sooner."""
|
|
200
132
|
|
|
201
133
|
@abstractmethod
|
|
202
|
-
def stop(self):
|
|
134
|
+
def stop(self) -> None:
|
|
203
135
|
"""Stop everything ready for destroying."""
|
|
204
136
|
|
|
205
|
-
async def start_sync(self, retry: int) -> None:
|
|
206
|
-
"""Start synchronization with the device."""
|
|
207
|
-
await self.queue_command("get_device_base_info")
|
|
208
|
-
await self.queue_command("get_device_product_model")
|
|
209
|
-
await self.queue_command("get_report_cfg")
|
|
210
|
-
"""RTK and dock location."""
|
|
211
|
-
await self.queue_command("read_write_device", rw_id=5, context=1, rw=1)
|
|
212
|
-
await self.async_read_settings()
|
|
213
|
-
|
|
214
|
-
async def start_map_sync(self) -> None:
|
|
215
|
-
"""Start sync of map data."""
|
|
216
|
-
|
|
217
|
-
self.mower.map.update_hash_lists(self.mower.map.hashlist)
|
|
218
|
-
|
|
219
|
-
await self.queue_command("send_todev_ble_sync", sync_type=3)
|
|
220
|
-
|
|
221
|
-
if self._cloud_device and len(self.mower.map.area_name) == 0 and not DeviceType.is_luba1(self.mower.name):
|
|
222
|
-
await self.queue_command("get_area_name_list", device_id=self._cloud_device.iotId)
|
|
223
|
-
|
|
224
|
-
if len(self.mower.map.plan) == 0 or list(self.mower.map.plan.values())[0].total_plan_num != len(
|
|
225
|
-
self.mower.map.plan
|
|
226
|
-
):
|
|
227
|
-
await self.queue_command("read_plan", sub_cmd=2, plan_index=0)
|
|
228
|
-
|
|
229
|
-
for hash_id, frame in list(self.mower.map.area.items()):
|
|
230
|
-
missing_frames = self.mower.map.find_missing_frames(frame)
|
|
231
|
-
if len(missing_frames) > 0:
|
|
232
|
-
del self.mower.map.area[hash_id]
|
|
233
|
-
|
|
234
|
-
for hash_id, frame in list(self.mower.map.path.items()):
|
|
235
|
-
missing_frames = self.mower.map.find_missing_frames(frame)
|
|
236
|
-
if len(missing_frames) > 0:
|
|
237
|
-
del self.mower.map.path[hash_id]
|
|
238
|
-
|
|
239
|
-
for hash_id, frame in list(self.mower.map.obstacle.items()):
|
|
240
|
-
missing_frames = self.mower.map.find_missing_frames(frame)
|
|
241
|
-
if len(missing_frames) > 0:
|
|
242
|
-
del self.mower.map.obstacle[hash_id]
|
|
243
|
-
|
|
244
|
-
# don't know why but total frame on svg is wrong
|
|
245
|
-
# for hash, frame in self.mower.map.svg.items():
|
|
246
|
-
# missing_frames = self.mower.map.find_missing_frames(frame)
|
|
247
|
-
# if len(missing_frames) > 0:
|
|
248
|
-
# del self.mower.map.svg[hash]
|
|
249
|
-
|
|
250
|
-
if len(self.mower.map.root_hash_lists) == 0 or len(self.mower.map.missing_hashlist()) > 0:
|
|
251
|
-
await self.queue_command("get_all_boundary_hash_list", sub_cmd=0)
|
|
252
|
-
|
|
253
|
-
# sub_cmd 3 is job hashes??
|
|
254
|
-
# sub_cmd 4 is dump location (yuka)
|
|
255
|
-
# jobs list
|
|
256
|
-
#
|
|
257
|
-
# await self.queue_command("get_all_boundary_hash_list", sub_cmd=3)
|
|
258
|
-
|
|
259
137
|
async def async_read_settings(self) -> None:
|
|
260
138
|
"""Read settings from device."""
|
|
261
139
|
# no cutting in rain nav_sys_param_cmd (id 3 context 1/0)
|
|
@@ -276,10 +154,10 @@ class MammotionBaseDevice:
|
|
|
276
154
|
await self.queue_command("read_write_device", rw_id=5, rw=1, context=2)
|
|
277
155
|
await self.queue_command("read_write_device", rw_id=5, rw=1, context=3)
|
|
278
156
|
|
|
279
|
-
async def command(self, key: str, **kwargs):
|
|
157
|
+
async def command(self, key: str, **kwargs: Any) -> None:
|
|
280
158
|
"""Send a command to the device."""
|
|
281
|
-
|
|
159
|
+
await self.queue_command(key, **kwargs)
|
|
282
160
|
|
|
283
161
|
@property
|
|
284
|
-
def state_manager(self):
|
|
162
|
+
def state_manager(self) -> MowerStateManager:
|
|
285
163
|
return self._state_manager
|