pymammotion 0.5.44__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/aliyun/model/dev_by_account_response.py +32 -62
- pymammotion/data/model/device.py +21 -9
- pymammotion/data/model/device_info.py +1 -0
- pymammotion/data/model/events.py +14 -0
- pymammotion/data/model/generate_geojson.py +551 -0
- pymammotion/data/model/hash_list.py +17 -1
- pymammotion/data/model/location.py +4 -4
- pymammotion/data/model/report_info.py +7 -0
- pymammotion/data/mower_state_manager.py +58 -4
- pymammotion/event/event.py +5 -2
- pymammotion/homeassistant/mower_api.py +44 -6
- pymammotion/homeassistant/rtk_api.py +16 -16
- pymammotion/http/http.py +8 -2
- pymammotion/mammotion/commands/messages/navigation.py +29 -0
- pymammotion/mammotion/devices/mammotion.py +16 -7
- pymammotion/mammotion/devices/mower_device.py +8 -5
- pymammotion/proto/__init__.py +2 -2
- pymammotion/proto/mctrl_sys_pb2.py +1 -1
- pymammotion/utility/constant/device_constant.py +1 -1
- pymammotion/utility/map.py +238 -51
- pymammotion/utility/mur_mur_hash.py +1 -1
- {pymammotion-0.5.44.dist-info → pymammotion-0.5.53.dist-info}/METADATA +3 -2
- {pymammotion-0.5.44.dist-info → pymammotion-0.5.53.dist-info}/RECORD +25 -23
- {pymammotion-0.5.44.dist-info → pymammotion-0.5.53.dist-info}/WHEEL +0 -0
- {pymammotion-0.5.44.dist-info → pymammotion-0.5.53.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
|
+
from typing import Annotated, Optional
|
|
2
3
|
|
|
3
4
|
from mashumaro.config import BaseConfig
|
|
4
5
|
from mashumaro.mixins.orjson import DataClassORJSONMixin
|
|
6
|
+
from mashumaro.types import Alias
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
@dataclass
|
|
@@ -9,79 +11,47 @@ class Device(DataClassORJSONMixin):
|
|
|
9
11
|
"""Unified device model supporting both Device and ShareNotification data"""
|
|
10
12
|
|
|
11
13
|
# Core device fields (from Device model)
|
|
12
|
-
gmt_modified: int
|
|
13
|
-
node_type: str
|
|
14
|
-
device_name: str
|
|
15
|
-
product_name: str
|
|
14
|
+
gmt_modified: Annotated[int, Alias("gmtModified")]
|
|
15
|
+
node_type: Annotated[str, Alias("nodeType")]
|
|
16
|
+
device_name: Annotated[str, Alias("deviceName")]
|
|
17
|
+
product_name: Annotated[str, Alias("productName")]
|
|
16
18
|
status: int
|
|
17
|
-
identity_id: str
|
|
19
|
+
identity_id: Annotated[str, Alias("identityId")]
|
|
18
20
|
|
|
19
21
|
# Required fields from original Device model
|
|
20
|
-
net_type: str
|
|
21
|
-
category_key: str
|
|
22
|
-
product_key: str
|
|
23
|
-
is_edge_gateway: bool
|
|
24
|
-
category_name: str
|
|
25
|
-
identity_alias: str
|
|
26
|
-
iot_id: str
|
|
27
|
-
bind_time: int
|
|
22
|
+
net_type: Annotated[str, Alias("netType")]
|
|
23
|
+
category_key: Annotated[str, Alias("categoryKey")]
|
|
24
|
+
product_key: Annotated[str, Alias("productKey")]
|
|
25
|
+
is_edge_gateway: Annotated[bool, Alias("isEdgeGateway")]
|
|
26
|
+
category_name: Annotated[str, Alias("categoryName")]
|
|
27
|
+
identity_alias: Annotated[str, Alias("identityAlias")]
|
|
28
|
+
iot_id: Annotated[str, Alias("iotId")]
|
|
29
|
+
bind_time: Annotated[int, Alias("bindTime")]
|
|
28
30
|
owned: int
|
|
29
|
-
thing_type: str
|
|
31
|
+
thing_type: Annotated[str, Alias("thingType")]
|
|
30
32
|
|
|
31
33
|
# Optional fields (common to both or nullable)
|
|
32
|
-
nick_name: str
|
|
33
|
-
description: str
|
|
34
|
-
product_image: str
|
|
35
|
-
category_image: str
|
|
36
|
-
product_model: str
|
|
34
|
+
nick_name: Annotated[Optional[str], Alias("nickName")] = None
|
|
35
|
+
description: Optional[str] = None
|
|
36
|
+
product_image: Annotated[Optional[str], Alias("productImage")] = None
|
|
37
|
+
category_image: Annotated[Optional[str], Alias("categoryImage")] = None
|
|
38
|
+
product_model: Annotated[Optional[str], Alias("productModel")] = None
|
|
37
39
|
|
|
38
40
|
# Optional fields from ShareNotification only
|
|
39
|
-
target_id: str
|
|
40
|
-
receiver_identity_id: str
|
|
41
|
-
target_type: str
|
|
42
|
-
gmt_create: int
|
|
43
|
-
batch_id: str
|
|
44
|
-
record_id: str
|
|
45
|
-
initiator_identity_id: str
|
|
46
|
-
is_receiver: int
|
|
47
|
-
initiator_alias: str
|
|
48
|
-
receiver_alias: str
|
|
41
|
+
target_id: Annotated[Optional[str], Alias("targetId")] = None
|
|
42
|
+
receiver_identity_id: Annotated[Optional[str], Alias("receiverIdentityId")] = None
|
|
43
|
+
target_type: Annotated[Optional[str], Alias("targetType")] = None
|
|
44
|
+
gmt_create: Annotated[Optional[int], Alias("gmtCreate")] = None
|
|
45
|
+
batch_id: Annotated[Optional[str], Alias("batchId")] = None
|
|
46
|
+
record_id: Annotated[Optional[str], Alias("recordId")] = None
|
|
47
|
+
initiator_identity_id: Annotated[Optional[str], Alias("initiatorIdentityId")] = None
|
|
48
|
+
is_receiver: Annotated[Optional[int], Alias("isReceiver")] = None
|
|
49
|
+
initiator_alias: Annotated[Optional[str], Alias("initiatorAlias")] = None
|
|
50
|
+
receiver_alias: Annotated[Optional[str], Alias("receiverAlias")] = None
|
|
49
51
|
|
|
50
52
|
class Config(BaseConfig):
|
|
51
53
|
omit_default = True
|
|
52
|
-
|
|
53
|
-
aliases = {
|
|
54
|
-
# Original Device model aliases
|
|
55
|
-
"gmt_modified": "gmtModified",
|
|
56
|
-
"net_type": "netType",
|
|
57
|
-
"category_key": "categoryKey",
|
|
58
|
-
"product_key": "productKey",
|
|
59
|
-
"node_type": "nodeType",
|
|
60
|
-
"is_edge_gateway": "isEdgeGateway",
|
|
61
|
-
"device_name": "deviceName",
|
|
62
|
-
"category_name": "categoryName",
|
|
63
|
-
"identity_alias": "identityAlias",
|
|
64
|
-
"product_name": "productName",
|
|
65
|
-
"iot_id": "iotId",
|
|
66
|
-
"bind_time": "bindTime",
|
|
67
|
-
"identity_id": "identityId",
|
|
68
|
-
"thing_type": "thingType",
|
|
69
|
-
"nick_name": "nickName",
|
|
70
|
-
"product_image": "productImage",
|
|
71
|
-
"category_image": "categoryImage",
|
|
72
|
-
"product_model": "productModel",
|
|
73
|
-
# ShareNotification specific aliases
|
|
74
|
-
"target_id": "targetId",
|
|
75
|
-
"receiver_identity_id": "receiverIdentityId",
|
|
76
|
-
"target_type": "targetType",
|
|
77
|
-
"gmt_create": "gmtCreate",
|
|
78
|
-
"batch_id": "batchId",
|
|
79
|
-
"record_id": "recordId",
|
|
80
|
-
"initiator_identity_id": "initiatorIdentityId",
|
|
81
|
-
"is_receiver": "isReceiver",
|
|
82
|
-
"initiator_alias": "initiatorAlias",
|
|
83
|
-
"receiver_alias": "receiverAlias",
|
|
84
|
-
}
|
|
54
|
+
allow_deserialization_not_by_alias = True
|
|
85
55
|
|
|
86
56
|
|
|
87
57
|
# # Alternative: Keep them separate but with a common base class
|
pymammotion/data/model/device.py
CHANGED
|
@@ -8,6 +8,7 @@ from mashumaro.mixins.orjson import DataClassORJSONMixin
|
|
|
8
8
|
from pymammotion.data.model import HashList, RapidState
|
|
9
9
|
from pymammotion.data.model.device_info import DeviceFirmwares, DeviceNonWorkingHours, MowerInfo
|
|
10
10
|
from pymammotion.data.model.errors import DeviceErrors
|
|
11
|
+
from pymammotion.data.model.events import Events
|
|
11
12
|
from pymammotion.data.model.location import Location
|
|
12
13
|
from pymammotion.data.model.report_info import ReportData
|
|
13
14
|
from pymammotion.data.model.work import CurrentTaskSettings
|
|
@@ -41,6 +42,7 @@ class MowingDevice(DataClassORJSONMixin):
|
|
|
41
42
|
device_firmwares: DeviceFirmwares = field(default_factory=DeviceFirmwares)
|
|
42
43
|
errors: DeviceErrors = field(default_factory=DeviceErrors)
|
|
43
44
|
non_work_hours: DeviceNonWorkingHours = field(default_factory=DeviceNonWorkingHours)
|
|
45
|
+
events: Events = field(default_factory=Events)
|
|
44
46
|
|
|
45
47
|
def buffer(self, buffer_list: SystemUpdateBufMsg) -> None:
|
|
46
48
|
"""Update the device based on which buffer we are reading from."""
|
|
@@ -51,9 +53,11 @@ class MowingDevice(DataClassORJSONMixin):
|
|
|
51
53
|
self.location.RTK.latitude = parse_double(buffer_list.update_buf_data[5], 8.0)
|
|
52
54
|
self.location.RTK.longitude = parse_double(buffer_list.update_buf_data[6], 8.0)
|
|
53
55
|
if buffer_list.update_buf_data[7] != 0:
|
|
54
|
-
|
|
55
|
-
self.location.dock.longitude = parse_double(buffer_list.update_buf_data[
|
|
56
|
-
self.location.dock.
|
|
56
|
+
# latitude Y longitude X
|
|
57
|
+
self.location.dock.longitude = parse_double(buffer_list.update_buf_data[7], 4.0)
|
|
58
|
+
self.location.dock.latitude = parse_double(buffer_list.update_buf_data[8], 4.0)
|
|
59
|
+
self.location.dock.rotation = buffer_list.update_buf_data[3]
|
|
60
|
+
|
|
57
61
|
case 2:
|
|
58
62
|
self.errors.err_code_list.clear()
|
|
59
63
|
self.errors.err_code_list_time.clear()
|
|
@@ -85,6 +89,20 @@ class MowingDevice(DataClassORJSONMixin):
|
|
|
85
89
|
buffer_list.update_buf_data[22],
|
|
86
90
|
]
|
|
87
91
|
)
|
|
92
|
+
case 3:
|
|
93
|
+
# task state event
|
|
94
|
+
task_area_map: dict[int, int] = {}
|
|
95
|
+
task_area_ids = []
|
|
96
|
+
|
|
97
|
+
for i in range(3, len(buffer_list.update_buf_data), 2):
|
|
98
|
+
area_id = buffer_list.update_buf_data[i]
|
|
99
|
+
|
|
100
|
+
if area_id != 0:
|
|
101
|
+
area_value = int(buffer_list.update_buf_data[i + 1])
|
|
102
|
+
task_area_map[area_id] = area_value
|
|
103
|
+
task_area_ids.append(area_id)
|
|
104
|
+
self.events.work_tasks_event.hash_list = task_area_map
|
|
105
|
+
self.events.work_tasks_event.ids = task_area_ids
|
|
88
106
|
|
|
89
107
|
def update_report_data(self, toapp_report_data: ReportInfoData) -> None:
|
|
90
108
|
"""Set report data for the mower."""
|
|
@@ -101,12 +119,6 @@ class MowingDevice(DataClassORJSONMixin):
|
|
|
101
119
|
self.location.work_zone = (
|
|
102
120
|
location.zone_hash if self.report_data.dev.sys_status == WorkMode.MODE_WORKING else 0
|
|
103
121
|
)
|
|
104
|
-
# if location.bol_hash:
|
|
105
|
-
# for loc in toapp_report_data.locations:
|
|
106
|
-
# if loc.bol_hash:
|
|
107
|
-
# if loc.bol_hash != location.bol_hash:
|
|
108
|
-
# self.map = HashList()
|
|
109
|
-
# MurMurHashUtil.hash_unsigned_list(list(self.map.area.keys()))
|
|
110
122
|
|
|
111
123
|
if toapp_report_data.fw_info:
|
|
112
124
|
self.update_device_firmwares(toapp_report_data.fw_info)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
|
|
3
|
+
from mashumaro.mixins.orjson import DataClassORJSONMixin
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class WorkTaskEvent(DataClassORJSONMixin):
|
|
8
|
+
hash_area_map: dict[int, int] = field(default_factory=dict)
|
|
9
|
+
ids: list[int] = field(default_factory=list)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass
|
|
13
|
+
class Events(DataClassORJSONMixin):
|
|
14
|
+
work_tasks_event: WorkTaskEvent = field(default_factory=WorkTaskEvent)
|