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.

Files changed (63) hide show
  1. pymammotion/__init__.py +3 -3
  2. pymammotion/aliyun/cloud_gateway.py +106 -18
  3. pymammotion/aliyun/model/dev_by_account_response.py +169 -21
  4. pymammotion/const.py +3 -0
  5. pymammotion/data/model/device.py +22 -9
  6. pymammotion/data/model/device_config.py +1 -1
  7. pymammotion/data/model/device_info.py +1 -0
  8. pymammotion/data/model/enums.py +5 -3
  9. pymammotion/data/model/events.py +14 -0
  10. pymammotion/data/model/generate_geojson.py +551 -0
  11. pymammotion/data/model/generate_route_information.py +2 -2
  12. pymammotion/data/model/hash_list.py +129 -33
  13. pymammotion/data/model/location.py +4 -4
  14. pymammotion/data/model/region_data.py +4 -4
  15. pymammotion/data/model/report_info.py +7 -0
  16. pymammotion/data/{state_manager.py → mower_state_manager.py} +75 -11
  17. pymammotion/data/mqtt/event.py +47 -22
  18. pymammotion/data/mqtt/mammotion_properties.py +257 -0
  19. pymammotion/data/mqtt/properties.py +32 -29
  20. pymammotion/data/mqtt/status.py +17 -16
  21. pymammotion/event/event.py +5 -2
  22. pymammotion/homeassistant/__init__.py +3 -0
  23. pymammotion/homeassistant/mower_api.py +484 -0
  24. pymammotion/homeassistant/rtk_api.py +54 -0
  25. pymammotion/http/http.py +394 -14
  26. pymammotion/http/model/http.py +82 -2
  27. pymammotion/http/model/response_factory.py +10 -4
  28. pymammotion/mammotion/commands/mammotion_command.py +6 -0
  29. pymammotion/mammotion/commands/messages/navigation.py +39 -6
  30. pymammotion/mammotion/devices/__init__.py +27 -3
  31. pymammotion/mammotion/devices/base.py +16 -138
  32. pymammotion/mammotion/devices/mammotion.py +369 -200
  33. pymammotion/mammotion/devices/mammotion_bluetooth.py +7 -5
  34. pymammotion/mammotion/devices/mammotion_cloud.py +42 -83
  35. pymammotion/mammotion/devices/mammotion_mower_ble.py +49 -0
  36. pymammotion/mammotion/devices/mammotion_mower_cloud.py +39 -0
  37. pymammotion/mammotion/devices/managers/managers.py +81 -0
  38. pymammotion/mammotion/devices/mower_device.py +124 -0
  39. pymammotion/mammotion/devices/mower_manager.py +107 -0
  40. pymammotion/mammotion/devices/rtk_ble.py +89 -0
  41. pymammotion/mammotion/devices/rtk_cloud.py +113 -0
  42. pymammotion/mammotion/devices/rtk_device.py +50 -0
  43. pymammotion/mammotion/devices/rtk_manager.py +122 -0
  44. pymammotion/mqtt/__init__.py +2 -1
  45. pymammotion/mqtt/aliyun_mqtt.py +232 -0
  46. pymammotion/mqtt/mammotion_mqtt.py +174 -192
  47. pymammotion/mqtt/mqtt_models.py +66 -0
  48. pymammotion/proto/__init__.py +3 -3
  49. pymammotion/proto/mctrl_nav.proto +1 -1
  50. pymammotion/proto/mctrl_nav_pb2.py +1 -1
  51. pymammotion/proto/mctrl_nav_pb2.pyi +4 -4
  52. pymammotion/proto/mctrl_sys.proto +1 -1
  53. pymammotion/proto/mctrl_sys_pb2.py +1 -1
  54. pymammotion/utility/constant/device_constant.py +1 -1
  55. pymammotion/utility/datatype_converter.py +13 -12
  56. pymammotion/utility/device_type.py +88 -3
  57. pymammotion/utility/map.py +238 -51
  58. pymammotion/utility/mur_mur_hash.py +132 -87
  59. {pymammotion-0.5.34.dist-info → pymammotion-0.5.53.dist-info}/METADATA +26 -31
  60. {pymammotion-0.5.34.dist-info → pymammotion-0.5.53.dist-info}/RECORD +67 -51
  61. {pymammotion-0.5.34.dist-info → pymammotion-0.5.53.dist-info}/WHEEL +1 -1
  62. pymammotion/http/_init_.py +0 -0
  63. {pymammotion-0.5.34.dist-info → pymammotion-0.5.53.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1,257 @@
1
+ from dataclasses import dataclass
2
+ from typing import Annotated
3
+
4
+ from mashumaro.config import BaseConfig
5
+ from mashumaro.mixins.orjson import DataClassORJSONMixin
6
+ from mashumaro.types import Alias
7
+
8
+
9
+ @dataclass
10
+ class FirmwareInfo(DataClassORJSONMixin):
11
+ t: str
12
+ c: str
13
+ v: str
14
+
15
+
16
+ @dataclass
17
+ class DeviceVersionInfo(DataClassORJSONMixin):
18
+ dev_ver: Annotated[str, Alias("devVer")]
19
+ whole: int
20
+ fw_info: Annotated[list[FirmwareInfo], Alias("fwInfo")]
21
+
22
+
23
+ @dataclass
24
+ class Coordinate(DataClassORJSONMixin):
25
+ lon: float
26
+ lat: float
27
+
28
+
29
+ @dataclass
30
+ class InternalNavigation(DataClassORJSONMixin):
31
+ nav: Annotated[str, Alias("NAV")]
32
+ pau: Annotated[str, Alias("Pau")]
33
+ r_pau: Annotated[str, Alias("rPau")]
34
+ mcu: Annotated[str, Alias("MCU")]
35
+ app: Annotated[str, Alias("APP")]
36
+ w_slp: Annotated[str, Alias("wSlp")]
37
+ i_slp: Annotated[str, Alias("iSlp")]
38
+
39
+
40
+ @dataclass
41
+ class BandwidthTraffic(DataClassORJSONMixin):
42
+ iot: Annotated[str, Alias("IoT")]
43
+ roi: Annotated[str, Alias("RoI")]
44
+ fpv: Annotated[str, Alias("FPV")]
45
+ inav: InternalNavigation
46
+
47
+
48
+ @dataclass
49
+ class TrafficPeriod(DataClassORJSONMixin):
50
+ r: str
51
+ t: str
52
+ s: str
53
+
54
+
55
+ @dataclass
56
+ class TrafficData(DataClassORJSONMixin):
57
+ upt: str
58
+ hour: Annotated[dict[str, TrafficPeriod], Alias("Hour")]
59
+ day: Annotated[dict[str, TrafficPeriod], Alias("Day")]
60
+ mon: Annotated[dict[str, TrafficPeriod], Alias("Mon")]
61
+
62
+
63
+ @dataclass
64
+ class NetworkInfo(DataClassORJSONMixin):
65
+ ssid: str
66
+ ip: str
67
+ wifi_sta_mac: str
68
+ wifi_rssi: int
69
+ wifi_available: int
70
+ bt_mac: str
71
+ mnet_model: str
72
+ imei: str
73
+ fw_ver: str
74
+ sim: str
75
+ imsi: str
76
+ iccid: str
77
+ sim_source: str
78
+ mnet_rssi: int
79
+ signal: int
80
+ mnet_link: int
81
+ mnet_option: str
82
+ mnet_ip: str
83
+ mnet_reg: str
84
+ mnet_rsrp: str
85
+ mnet_snr: str
86
+ mnet_enable: int
87
+ apn_num: int
88
+ apn_info: str
89
+ apn_cid: int
90
+ used_net: int
91
+ hub_reset: int
92
+ mnet_dis: int
93
+ airplane_times: int
94
+ lsusb_num: int
95
+ b_tra: Annotated[BandwidthTraffic, Alias("bTra")]
96
+ bw_tra: Annotated[BandwidthTraffic, Alias("bwTra")]
97
+ mnet_rx: str
98
+ mnet_tx: str
99
+ m_tra: Annotated[TrafficData, Alias("mTra")]
100
+ mnet_uniot: int
101
+ mnet_un_getiot: int
102
+ ssh_flag: str
103
+ mileage: str
104
+ work_time: str
105
+ wt_sec: int
106
+ bat_cycles: str
107
+
108
+
109
+ @dataclass
110
+ class DeviceOtherInfo(DataClassORJSONMixin):
111
+ soc_up_time: Annotated[int, Alias("socUpTime")]
112
+ mcu_up_time: Annotated[int, Alias("mcuUpTime")]
113
+ soc_loads: Annotated[str, Alias("socLoads")]
114
+ soc_mem_free: Annotated[int, Alias("socMemFree")]
115
+ soc_mem_total: Annotated[int, Alias("socMemTotal")]
116
+ soc_mmc_life_time: Annotated[int, Alias("socMmcLifeTime")]
117
+ usb_dis_cnt: Annotated[int, Alias("usbDisCnt")]
118
+ soc_pstore: Annotated[int, Alias("socPstore")]
119
+ soc_coredump: Annotated[int, Alias("socCoredump")]
120
+ soc_tmp: Annotated[int, Alias("socTmp")]
121
+ mc_mcu: Annotated[str, Alias("mcMcu")]
122
+ tilt_degree: str
123
+ i_msg_free: Annotated[int, Alias("iMsgFree")]
124
+ i_msg_limit: Annotated[int, Alias("iMsgLimit")]
125
+ i_msg_raw: Annotated[int, Alias("iMsgRaw")]
126
+ i_msg_prop: Annotated[int, Alias("iMsgprop")]
127
+ i_msg_serv: Annotated[int, Alias("iMsgServ")]
128
+ i_msg_info: Annotated[int, Alias("iMsgInfo")]
129
+ i_msg_warn: Annotated[int, Alias("iMsgWarn")]
130
+ i_msg_fault: Annotated[int, Alias("iMsgFault")]
131
+ i_msg_ota_stage: Annotated[int, Alias("iMsgOtaStage")]
132
+ i_msg_protobuf: Annotated[int, Alias("iMsgProtobuf")]
133
+ i_msg_notify: Annotated[int, Alias("iMsgNotify")]
134
+ i_msg_log_prog: Annotated[int, Alias("iMsgLogProg")]
135
+ i_msg_biz_req: Annotated[int, Alias("iMsgBizReq")]
136
+ i_msg_cfg_req: Annotated[int, Alias("iMsgCfgReq")]
137
+ i_msg_voice: Annotated[int, Alias("iMsgVoice")]
138
+ i_msg_warn_code: Annotated[int, Alias("iMsgWarnCode")]
139
+ pb_net: Annotated[int, Alias("pbNet")]
140
+ pb_sys: Annotated[int, Alias("pbSys")]
141
+ pb_nav: Annotated[int, Alias("pbNav")]
142
+ pb_local: Annotated[int, Alias("pbLocal")]
143
+ pb_plan: Annotated[int, Alias("pbPlan")]
144
+ pb_e_drv: Annotated[int, Alias("pbEDrv")]
145
+ pb_e_sys: Annotated[int, Alias("pbESys")]
146
+ pb_midware: Annotated[int, Alias("pbMidware")]
147
+ pb_ota: Annotated[int, Alias("pbOta")]
148
+ pb_appl: Annotated[int, Alias("pbAppl")]
149
+ pb_mul: Annotated[int, Alias("pbMul")]
150
+ pb_other: Annotated[int, Alias("pbOther")]
151
+ lora_connect: Annotated[int, Alias("loraConnect")]
152
+ base_status: Annotated[int, Alias("Basestatus")]
153
+ mqtt_rtk_switch: int
154
+ mqtt_rtk_channel: int
155
+ mqtt_rtk_status: int
156
+ mqtt_rtcm_cnt: int
157
+ mqtt_conn_cnt: int
158
+ mqtt_disconn_cnt: int
159
+ mqtt_rtk_hb_flag: int
160
+ mqtt_rtk_hb_count: int
161
+ mqtt_start_cnt: int
162
+ mqtt_close_cnt: int
163
+ mqtt_rtk_ssl_fail: int
164
+ mqtt_rtk_wifi_config: int
165
+ nrtk_svc_prov: int
166
+ nrtk_svc_err: int
167
+ base_stn_id: int
168
+ rtk_status: int
169
+ charge_status: int
170
+ chassis_state: int
171
+ nav: str
172
+ ins_fusion: str
173
+ perception: str
174
+ vision_proxy: str
175
+ vslam_vio: str
176
+ iot_con_timeout: int
177
+ iot_con: int
178
+ iot_con_fail_max: str
179
+ iot_con_fail_min: Annotated[str, Alias("iot_con__fail_min")]
180
+ iot_url_count: int
181
+ iot_url_max: str
182
+ iot_url_min: str
183
+ iot_cn: int
184
+ iot_ap: int
185
+ iot_us: int
186
+ iot_eu: int
187
+ task_area: float
188
+ task_count: int
189
+ task_hash: str
190
+ systemio_boot_time: Annotated[str, Alias("systemioBootTime")]
191
+ dds_no_gdc: int
192
+
193
+
194
+ @dataclass
195
+ class CheckData(DataClassORJSONMixin):
196
+ result: str
197
+ error: Annotated[list[int], Alias("Error")]
198
+ warn: Annotated[list[int], Alias("Warn")]
199
+ ok: Annotated[list[int], Alias("OK")]
200
+
201
+
202
+ @dataclass
203
+ class DeviceProperties(DataClassORJSONMixin):
204
+ device_state: Annotated[int, Alias("deviceState")]
205
+ battery_percentage: Annotated[int, Alias("batteryPercentage")]
206
+ device_version: Annotated[str, Alias("deviceVersion")]
207
+ knife_height: Annotated[int, Alias("knifeHeight")]
208
+ lora_general_config: Annotated[str, Alias("loraGeneralConfig")]
209
+ ext_mod: Annotated[str, Alias("extMod")]
210
+ int_mod: Annotated[str, Alias("intMod")]
211
+ iot_state: Annotated[int, Alias("iotState")]
212
+ iot_msg_total: Annotated[int, Alias("iotMsgTotal")]
213
+ iot_msg_hz: Annotated[int, Alias("iotMsgHz")]
214
+ lt_mr_mod: Annotated[str, Alias("ltMrMod")]
215
+ rt_mr_mod: Annotated[str, Alias("rtMrMod")]
216
+ bms_hardware_version: Annotated[str, Alias("bmsHardwareVersion")]
217
+ stm32_h7_version: Annotated[str, Alias("stm32H7Version")]
218
+ left_motor_version: Annotated[str, Alias("leftMotorVersion")]
219
+ right_motor_version: Annotated[str, Alias("rightMotorVersion")]
220
+ rtk_version: Annotated[str, Alias("rtkVersion")]
221
+ bms_version: Annotated[str, Alias("bmsVersion")]
222
+ mc_boot_version: Annotated[str, Alias("mcBootVersion")]
223
+ left_motor_boot_version: Annotated[str, Alias("leftMotorBootVersion")]
224
+ right_motor_boot_version: Annotated[str, Alias("rightMotorBootVersion")]
225
+
226
+ # Nested JSON objects
227
+ device_version_info: Annotated[DeviceVersionInfo, Alias("deviceVersionInfo")]
228
+ coordinate: Coordinate
229
+ device_other_info: Annotated[DeviceOtherInfo, Alias("deviceOtherInfo")]
230
+ network_info: Annotated[NetworkInfo, Alias("networkInfo")]
231
+ check_data: Annotated[CheckData, Alias("checkData")]
232
+ iot_id: str = ""
233
+
234
+ class Config(BaseConfig):
235
+ # Custom deserializer for nested JSON strings
236
+ serialization_strategy = {
237
+ DeviceVersionInfo: {
238
+ "deserialize": lambda x: DeviceVersionInfo.from_json(x) if isinstance(x, str) else x,
239
+ "serialize": lambda x: x.to_json() if hasattr(x, "to_json") else x,
240
+ },
241
+ Coordinate: {
242
+ "deserialize": lambda x: Coordinate.from_json(x) if isinstance(x, str) else x,
243
+ "serialize": lambda x: x.to_json() if hasattr(x, "to_json") else x,
244
+ },
245
+ DeviceOtherInfo: {
246
+ "deserialize": lambda x: DeviceOtherInfo.from_json(x) if isinstance(x, str) else x,
247
+ "serialize": lambda x: x.to_json() if hasattr(x, "to_json") else x,
248
+ },
249
+ NetworkInfo: {
250
+ "deserialize": lambda x: NetworkInfo.from_json(x) if isinstance(x, str) else x,
251
+ "serialize": lambda x: x.to_json() if hasattr(x, "to_json") else x,
252
+ },
253
+ CheckData: {
254
+ "deserialize": lambda x: CheckData.from_json(x) if isinstance(x, str) else x,
255
+ "serialize": lambda x: x.to_json() if hasattr(x, "to_json") else x,
256
+ },
257
+ }
@@ -1,16 +1,11 @@
1
1
  from dataclasses import dataclass
2
- from typing import Any, Generic, Literal, TypeVar, Union
2
+ from typing import Annotated, Any, Literal, Union
3
3
 
4
4
  from mashumaro import DataClassDictMixin
5
5
  from mashumaro.mixins.orjson import DataClassORJSONMixin
6
+ from mashumaro.types import Alias
6
7
 
7
- DataT = TypeVar("DataT")
8
-
9
-
10
- @dataclass
11
- class Item(DataClassDictMixin, Generic[DataT]):
12
- time: int
13
- value: DataT
8
+ from pymammotion.data.mqtt.mammotion_properties import DeviceProperties
14
9
 
15
10
 
16
11
  @dataclass
@@ -163,29 +158,29 @@ class Items(DataClassDictMixin):
163
158
 
164
159
  @dataclass
165
160
  class Params(DataClassORJSONMixin):
166
- deviceType: Literal["LawnMower", "Tracker"]
167
- checkFailedData: dict
168
- groupIdList: list[str]
169
- _tenantId: str
170
- groupId: str
171
- categoryKey: Literal["LawnMower", "Tracker"]
172
- batchId: str
173
- gmtCreate: int
174
- productKey: str
175
- generateTime: int
176
- deviceName: str
177
- _traceId: str
178
- iotId: str
179
- JMSXDeliveryCount: int
180
- checkLevel: int
161
+ device_type: Annotated[Literal["LawnMower", "Tracker"], Alias("deviceType")]
162
+ check_failed_data: Annotated[dict[str, Any], Alias("checkFailedData")]
163
+ group_id_list: Annotated[list[str], Alias("groupIdList")]
164
+ _tenant_id: Annotated[str, Alias("_tenantId")]
165
+ group_id: Annotated[str, Alias("groupId")]
166
+ category_key: Annotated[Literal["LawnMower", "Tracker"], Alias("categoryKey")]
167
+ batch_id: Annotated[str, Alias("batchId")]
168
+ gmt_create: Annotated[int, Alias("gmtCreate")]
169
+ product_key: Annotated[str, Alias("productKey")]
170
+ generate_time: Annotated[int, Alias("generateTime")]
171
+ device_name: Annotated[str, Alias("deviceName")]
172
+ _trace_id: Annotated[str, Alias("_traceId")]
173
+ iot_id: Annotated[str, Alias("iotId")]
174
+ jmsx_delivery_count: Annotated[int, Alias("JMSXDeliveryCount")]
175
+ check_level: Annotated[int, Alias("checkLevel")]
181
176
  qos: int
182
- requestId: str
183
- _categoryKey: str
177
+ request_id: Annotated[str, Alias("requestId")]
178
+ _category_key: Annotated[str, Alias("_categoryKey")]
184
179
  namespace: str
185
- tenantId: str
186
- thingType: Literal["DEVICE"]
187
- items: Items
188
- tenantInstanceId: str
180
+ tenant_id: Annotated[str, Alias("tenantId")]
181
+ thing_type: Annotated[Literal["DEVICE"], Alias("thingType")]
182
+ items: Annotated["Items", Alias("items")]
183
+ tenant_instance_id: Annotated[str, Alias("tenantInstanceId")]
189
184
 
190
185
 
191
186
  @dataclass
@@ -194,3 +189,11 @@ class ThingPropertiesMessage(DataClassORJSONMixin):
194
189
  id: str
195
190
  params: Params
196
191
  version: Literal["1.0"]
192
+
193
+
194
+ @dataclass
195
+ class MammotionPropertiesMessage(DataClassORJSONMixin):
196
+ id: str
197
+ version: str
198
+ sys: dict
199
+ params: DeviceProperties
@@ -1,8 +1,9 @@
1
1
  from dataclasses import dataclass
2
2
  from enum import Enum
3
- from typing import Literal
3
+ from typing import Annotated, Literal
4
4
 
5
5
  from mashumaro.mixins.orjson import DataClassORJSONMixin
6
+ from mashumaro.types import Alias
6
7
 
7
8
 
8
9
  @dataclass
@@ -25,23 +26,23 @@ class Status(DataClassORJSONMixin):
25
26
 
26
27
  @dataclass
27
28
  class Params(DataClassORJSONMixin):
28
- groupIdList: list[GroupIdListItem]
29
- netType: Literal["NET_WIFI", "NET_MNET"]
30
- activeTime: int
29
+ group_id_list: Annotated[list[GroupIdListItem], Alias("groupIdList")]
30
+ net_type: Annotated[Literal["NET_WIFI", "NET_MNET"], Alias("netType")]
31
+ active_time: Annotated[int, Alias("activeTime")]
31
32
  ip: str
32
- aliyunCommodityCode: Literal["iothub_senior"]
33
- categoryKey: Literal["LawnMower", "Tracker"]
34
- nodeType: Literal["DEVICE"]
35
- productKey: str
36
- statusLast: int
37
- deviceName: str
38
- iotId: str
33
+ aliyun_commodity_code: Annotated[Literal["iothub_senior"], Alias("aliyunCommodityCode")]
34
+ category_key: Annotated[Literal["LawnMower", "Tracker"], Alias("categoryKey")]
35
+ node_type: Annotated[Literal["DEVICE"], Alias("nodeType")]
36
+ product_key: Annotated[str, Alias("productKey")]
37
+ status_last: Annotated[int, Alias("statusLast")]
38
+ device_name: Annotated[str, Alias("deviceName")]
39
+ iot_id: Annotated[str, Alias("iotId")]
39
40
  namespace: str
40
- tenantId: str
41
- thingType: Literal["DEVICE"]
42
- tenantInstanceId: str
43
- categoryId: int
44
- status: Status
41
+ tenant_id: Annotated[str, Alias("tenantId")]
42
+ thing_type: Annotated[Literal["DEVICE"], Alias("thingType")]
43
+ tenant_instance_id: Annotated[str, Alias("tenantInstanceId")]
44
+ category_id: Annotated[int, Alias("categoryId")]
45
+ status: Annotated[Status, Alias("status")]
45
46
 
46
47
 
47
48
  @dataclass
@@ -77,16 +77,19 @@ class DataEvent:
77
77
  self.on_data_event = Event()
78
78
 
79
79
  async def data_event(self, data: Any) -> None:
80
+ """Execute the data event callback."""
80
81
  # This function will be executed when data is received.
81
82
  if data:
82
83
  await self.on_data_event(data)
83
84
  else:
84
85
  await self.on_data_event()
85
86
 
86
- def add_subscribers(self, obj_method) -> None:
87
+ def add_subscribers(self, obj_method: Callable) -> None:
88
+ """Add subscribers."""
87
89
  self.on_data_event += obj_method
88
90
 
89
- def remove_subscribers(self, obj_method) -> None:
91
+ def remove_subscribers(self, obj_method: Callable) -> None:
92
+ """Remove subscribers."""
90
93
  try:
91
94
  self.on_data_event -= obj_method
92
95
  except ValueError:
@@ -0,0 +1,3 @@
1
+ from pymammotion.homeassistant.mower_api import HomeAssistantMowerApi
2
+
3
+ __all__ = ["HomeAssistantMowerApi"]