pymammotion 0.2.23__py3-none-any.whl → 0.2.25__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.
@@ -5,7 +5,7 @@ from dataclasses import dataclass
5
5
 
6
6
  import betterproto
7
7
 
8
- from pymammotion.data.model import HashList
8
+ from pymammotion.data.model import HashList, RapidState
9
9
  from pymammotion.data.model.device_config import DeviceLimits
10
10
  from pymammotion.data.model.location import Location
11
11
  from pymammotion.data.model.report_info import ReportData
@@ -16,14 +16,13 @@ from pymammotion.proto.mctrl_driver import MctlDriver
16
16
  from pymammotion.proto.mctrl_nav import MctlNav
17
17
  from pymammotion.proto.mctrl_ota import MctlOta
18
18
  from pymammotion.proto.mctrl_pept import MctlPept
19
- from pymammotion.proto.mctrl_sys import MctlSys, MowToAppInfoT, ReportInfoData, SystemUpdateBufMsg
19
+ from pymammotion.proto.mctrl_sys import MctlSys, MowToAppInfoT, ReportInfoData, SystemUpdateBufMsg, \
20
+ SystemRapidStateTunnelMsg
21
+ from pymammotion.utility.constant import WorkMode
22
+ from pymammotion.utility.conversions import parse_double
20
23
  from pymammotion.utility.map import CoordinateConverter
21
24
 
22
25
 
23
- def parse_double(val: float, d: float):
24
- return val / math.pow(10.0, d)
25
-
26
-
27
26
  @dataclass
28
27
  class MowingDevice:
29
28
  """Wraps the betterproto dataclasses, so we can bypass the groups for keeping all data."""
@@ -31,6 +30,7 @@ class MowingDevice:
31
30
  device: LubaMsg
32
31
  map: HashList
33
32
  location: Location
33
+ mowing_state: RapidState
34
34
 
35
35
  def __init__(self):
36
36
  self.device = LubaMsg()
@@ -40,6 +40,7 @@ class MowingDevice:
40
40
  self.err_code_list = []
41
41
  self.err_code_list_time = []
42
42
  self.limits = DeviceLimits(30, 70, 0.2, 0.6)
43
+ self.mowing_state = RapidState()
43
44
 
44
45
  @classmethod
45
46
  def from_raw(cls, raw: dict) -> "MowingDevice":
@@ -97,15 +98,22 @@ class MowingDevice:
97
98
  def update_report_data(self, toapp_report_data: ReportInfoData):
98
99
  coordinate_converter = CoordinateConverter(self.location.RTK.latitude, self.location.RTK.longitude)
99
100
  for index, location in enumerate(toapp_report_data.locations):
100
- if index == 0:
101
+ if index == 0 and location.real_pos_y != 0:
101
102
  self.location.position_type = location.pos_type
102
103
  self.location.orientation = location.real_toward / 10000
103
104
  self.location.device = coordinate_converter.enu_to_lla(
104
105
  parse_double(location.real_pos_y, 4.0), parse_double(location.real_pos_x, 4.0)
105
106
  )
107
+ if location.zone_hash:
108
+ self.location.work_zone = location.zone_hash if self.report_data.dev.sys_status == WorkMode.MODE_WORKING else 0
109
+
110
+
106
111
 
107
112
  self.report_data = self.report_data.from_dict(toapp_report_data.to_dict(casing=betterproto.Casing.SNAKE))
108
113
 
114
+ def run_state_update(self, rapid_state: SystemRapidStateTunnelMsg):
115
+ self.mowing_state = RapidState().from_raw(rapid_state.rapid_state_data)
116
+
109
117
  def mow_info(self, toapp_mow_info: MowToAppInfoT):
110
118
  pass
111
119
 
@@ -31,6 +31,7 @@ class Location:
31
31
  dock: Dock
32
32
  position_type: int = 0
33
33
  orientation: int = 0 # 360 degree rotation +-
34
+ work_zone: int = 0
34
35
 
35
36
  def __init__(self):
36
37
  self.device = Point()
@@ -1,6 +1,8 @@
1
1
  from dataclasses import dataclass
2
2
  from enum import Enum
3
3
 
4
+ from pymammotion.utility.conversions import parse_double
5
+
4
6
 
5
7
  class RTKStatus(Enum):
6
8
  NONE = 0
@@ -10,18 +12,18 @@ class RTKStatus(Enum):
10
12
 
11
13
  @dataclass
12
14
  class RapidState:
13
- pos_x: float
14
- pos_y: float
15
- rtk_status: RTKStatus
16
- toward: float
17
- satellites_total: int
18
- satellites_l2: int
19
- rtk_age: float
20
- lat_std: float
21
- lon_std: float
22
- pos_type: int
23
- zone_hash: int
24
- pos_level: int
15
+ pos_x: float = 0
16
+ pos_y: float = 0
17
+ rtk_status: RTKStatus = RTKStatus.NONE
18
+ toward: float = 0
19
+ satellites_total: int = 0
20
+ satellites_l2: int = 0
21
+ rtk_age: float = 0
22
+ lat_std: float = 0
23
+ lon_std: float = 0
24
+ pos_type: int = 0
25
+ zone_hash: int = 0
26
+ pos_level: int = 0
25
27
 
26
28
  @classmethod
27
29
  def from_raw(cls, raw: list[int]) -> "RapidState":
@@ -29,13 +31,13 @@ class RapidState:
29
31
  rtk_status=RTKStatus.FINE if raw[0] == 4 else RTKStatus.BAD if raw[0] in (1, 5) else RTKStatus.NONE,
30
32
  pos_level=raw[1],
31
33
  satellites_total=raw[2],
32
- rtk_age=raw[3] / 10000,
33
- lat_std=raw[4] / 10000,
34
- lon_std=raw[5] / 10000,
34
+ rtk_age=parse_double(raw[3], 4.0),
35
+ lat_std=parse_double(raw[4], 4.0),
36
+ lon_std=parse_double(raw[5], 4.0),
35
37
  satellites_l2=raw[6],
36
- pos_x=raw[7] / 10000,
37
- pos_y=raw[8] / 10000,
38
- toward=raw[9] / 10000,
38
+ pos_x=parse_double(raw[7], 4.0),
39
+ pos_y=parse_double(raw[8], 4.0),
40
+ toward=parse_double(raw[9], 4.0),
39
41
  pos_type=raw[10],
40
42
  zone_hash=raw[11],
41
43
  )
@@ -51,6 +51,16 @@ class DeviceConfigurationRequestValue(DataClassORJSONMixin):
51
51
  bizId: str
52
52
  params: str
53
53
 
54
+ @dataclass
55
+ class DeviceNotificationEventCode(DataClassORJSONMixin):
56
+ localTime: int
57
+ code: str
58
+
59
+ @dataclass
60
+ class DeviceNotificationEventValue(DataClassORJSONMixin):
61
+ data: DeviceNotificationEventCode
62
+
63
+
54
64
 
55
65
  @dataclass
56
66
  class GeneralParams(DataClassORJSONMixin):
@@ -90,6 +100,16 @@ class DeviceProtobufMsgEventParams(GeneralParams):
90
100
  type: Literal["info"]
91
101
  value: DeviceProtobufMsgEventValue
92
102
 
103
+ @dataclass
104
+ class DeviceNotificationEventParams(GeneralParams):
105
+ """Device notification event.
106
+
107
+ {'data': '{"localTime":1725159492000,"code":"1002"}'},
108
+ """
109
+
110
+ identifier: Literal["device_notification_event"]
111
+ type: Literal["info"]
112
+ value: DeviceNotificationEventValue
93
113
 
94
114
  @dataclass
95
115
  class DeviceWarningEventParams(GeneralParams):
@@ -129,6 +149,8 @@ class ThingEventMessage(DataClassORJSONMixin):
129
149
  params_obj = DeviceWarningEventParams(**params_dict)
130
150
  elif identifier == "device_config_req_event":
131
151
  params_obj = payload.get("params", '')
152
+ elif identifier == "device_notification_event":
153
+ params_obj = DeviceNotificationEventParams(**params_dict)
132
154
  else:
133
155
  raise ValueError(f"Unknown identifier: {identifier} {params_dict}")
134
156
 
@@ -72,6 +72,8 @@ class StateManager:
72
72
  self._device.update_report_data(sys_msg[1])
73
73
  case "mow_to_app_info":
74
74
  self._device.mow_info(sys_msg[1])
75
+ case "system_tard_state_tunnel":
76
+ self._device.run_state_update(sys_msg[1])
75
77
 
76
78
  def _update_driver_data(self, message):
77
79
  pass
@@ -299,7 +299,7 @@ class Mammotion(object):
299
299
  return await device.cloud().command(key, **kwargs)
300
300
  # TODO work with both with EITHER
301
301
 
302
- async def start_sync(self,name:str, retry: int):
302
+ async def start_sync(self, name:str, retry: int):
303
303
  device = self.get_device_by_name(name)
304
304
  if device:
305
305
  if self._preference is ConnectionPreference.BLUETOOTH:
@@ -537,7 +537,7 @@ class MammotionBaseDevice:
537
537
  async def move_back(self, linear: float):
538
538
  """Move back. values 0.0 1.0."""
539
539
  linear_percent = get_percent(abs(linear * 100))
540
- (linear_speed, angular_speed) = transform_both_speeds(90.0, 0.0, linear_percent, 0.0)
540
+ (linear_speed, angular_speed) = transform_both_speeds(270.0, 0.0, linear_percent, 0.0)
541
541
  await self.queue_command("send_movement", linear_speed=linear_speed, angular_speed=angular_speed)
542
542
 
543
543
  async def move_left(self, angulur: float):
@@ -1015,11 +1015,12 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
1015
1015
  """Callback for when MQTT is subscribed to events."""
1016
1016
  loop = asyncio.get_event_loop()
1017
1017
 
1018
- if self.on_ready_callback:
1019
- self.loop.create_task(self.on_ready_callback)
1018
+
1020
1019
  await self._ble_sync()
1021
1020
  await self.run_periodic_sync_task()
1022
1021
  loop.create_task(self._process_queue())
1022
+ if self.on_ready_callback:
1023
+ await self.on_ready_callback()
1023
1024
 
1024
1025
  async def on_connected(self):
1025
1026
  """Callback for when MQTT connects."""
@@ -1219,3 +1220,6 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
1219
1220
  def _disconnect(self):
1220
1221
  """Disconnect the MQTT client."""
1221
1222
  self._mqtt_client.disconnect()
1223
+
1224
+
1225
+
@@ -123,7 +123,7 @@ class SystemUpdateBuf:
123
123
  ZONE_STATE_LEN_INDEX = 1
124
124
 
125
125
 
126
- class SystemRapidStateTunnel:
126
+ class SystemRapidStateTunnelIndex(IntEnum):
127
127
  DIS_CAR_RTK_STARS_INDEX = 15
128
128
  DIS_RTK_STATUS_INDEX = 13
129
129
  L1_SATS_INDEX = 2
@@ -0,0 +1,5 @@
1
+ import math
2
+
3
+
4
+ def parse_double(val: float, d: float):
5
+ return val / math.pow(10.0, d)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymammotion
3
- Version: 0.2.23
3
+ Version: 0.2.25
4
4
  Summary:
5
5
  License: GNU-3.0
6
6
  Author: Michael Arthur
@@ -21,24 +21,24 @@ pymammotion/const.py,sha256=EEmZ1v4MqN2nPiNpS_mJQqaCkSNEa1EXUmtwZBUhXIg,329
21
21
  pymammotion/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  pymammotion/data/model/__init__.py,sha256=d8FlIgCcWqoH3jJSpnm-IY-25RM-l2nbRwLtWjSHo74,222
23
23
  pymammotion/data/model/account.py,sha256=stWLDtWPw1vOPp3xNdX-jWziMmdCvww4IYl00UUGKuI,139
24
- pymammotion/data/model/device.py,sha256=XHw4q32TL6R60GmLkQiiJmlOv5Y3iHLNytR5ArtsySg,10403
24
+ pymammotion/data/model/device.py,sha256=wDmmuCkWvuyoFhZxULCGeigMErmN5GX08NqYJrZbVhQ,10903
25
25
  pymammotion/data/model/device_config.py,sha256=E3rhLvUH4BuWEpBfylBYBEwn4G8u7c0QbKxWRElw3Sg,177
26
26
  pymammotion/data/model/enums.py,sha256=tD_vYsxstOV_lUkYF9uWkrjVOgAJPNnGevy_xmiu3WE,1558
27
27
  pymammotion/data/model/excute_boarder_params.py,sha256=kadSth4y-VXlXIZ6R-Ng-kDvBbM-3YRr8bmR86qR0U0,1355
28
28
  pymammotion/data/model/execute_boarder.py,sha256=oDb2h5tFtOQIa8OCNYaDugqCgCZBLjQRzQTNVcJVAGQ,1072
29
29
  pymammotion/data/model/generate_route_information.py,sha256=5w1MM1-gXGXb_AoEap_I5xTxAFbNSzXuqQFEkw4NmDs,4301
30
30
  pymammotion/data/model/hash_list.py,sha256=wHdM46r42_EF2OnXqBHNAyf-muDOibEB7NWVjc0gXYA,2683
31
- pymammotion/data/model/location.py,sha256=qO3G0U_eWP9alswbZXTpmYImIcXJeteBVHX1cGZGbHg,729
31
+ pymammotion/data/model/location.py,sha256=mafcOPFcb6niTiiZdDWIh_TbnS76jA3Cqd5paKbnhgc,752
32
32
  pymammotion/data/model/mowing_modes.py,sha256=2GAF-xaHpv6CSGobYoNtfSi2if8_jW0nonCqN50SNx0,665
33
33
  pymammotion/data/model/plan.py,sha256=7JvqAo0a9Yg1Vtifd4J3Dx3StEppxrMOfmq2-877kYg,2891
34
- pymammotion/data/model/rapid_state.py,sha256=_e9M-65AbkvIqXyMYzLKBxbNvpso42qD8R-JSt66THY,986
34
+ pymammotion/data/model/rapid_state.py,sha256=BdJFD_DlhrVneg-PqEruqCoMty-CR7q_9Qna-hk1yd8,1171
35
35
  pymammotion/data/model/region_data.py,sha256=75xOTM1qeRbSROp53eIczw3yCmYM9DgMjMh8qE9xkKo,2880
36
36
  pymammotion/data/model/report_info.py,sha256=1Rj_yRZ9apWX296QHae5prdObDbs32bsQf9rzMz2KEQ,4458
37
37
  pymammotion/data/mqtt/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
38
- pymammotion/data/mqtt/event.py,sha256=QkuFQtSUfg8eHisJ-llu-b6cpAlTePaP0JbqL6xZcvk,3900
38
+ pymammotion/data/mqtt/event.py,sha256=0bxP7mt3unvoaPIJn5VDUXMuwTcakgw6bfuv64aaYAk,4522
39
39
  pymammotion/data/mqtt/properties.py,sha256=HkBPghr26L9_b4QaOi1DtPgb0UoPIOGSe9wb3kgnM6Y,2815
40
40
  pymammotion/data/mqtt/status.py,sha256=zqnlo-MzejEQZszl0i0Wucoc3E76x6UtI9JLxoBnu54,1067
41
- pymammotion/data/state_manager.py,sha256=Il9jJKXE_ga_wfnRS0bhSkQytcRXOzxb_wZAmL0VnQQ,2992
41
+ pymammotion/data/state_manager.py,sha256=T6slACOpbnhWVKmJD_XrBY9vrcCFc6q2l6jEf-g89NQ,3095
42
42
  pymammotion/event/__init__.py,sha256=mgATR6vPHACNQ-0zH5fi7NdzeTCDV1CZyaWPmtUusi8,115
43
43
  pymammotion/event/event.py,sha256=Fy5-I1p92AO_D67VW4eHQqA4pOt7MZsrP--tVfIVUz8,1820
44
44
  pymammotion/http/_init_.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -58,7 +58,7 @@ pymammotion/mammotion/commands/messages/video.py,sha256=_8lJsU4sLm2CGnc7RDkueA0A
58
58
  pymammotion/mammotion/control/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
59
  pymammotion/mammotion/control/joystick.py,sha256=mresPubTlWCuLQBOFD9KTyYJz5BjZgqt52BaRodemhM,5557
60
60
  pymammotion/mammotion/devices/__init__.py,sha256=T72jt0ejtMjo1rPmn_FeMF3pmp0LLeRRpc9WcDKEYYY,126
61
- pymammotion/mammotion/devices/mammotion.py,sha256=4cqUHjxjUbfZNeYIwtm1HmS6X7x4gDMUxi5I4uEZjag,49403
61
+ pymammotion/mammotion/devices/mammotion.py,sha256=PQPiPxfPGi9wNne2Rcxy7Tcf1kRdkvAvqZqM5nEu5qM,49394
62
62
  pymammotion/mqtt/__init__.py,sha256=Ocs5e-HLJvTuDpVXyECEsWIvwsUaxzj7lZ9mSYutNDY,105
63
63
  pymammotion/mqtt/mammotion_future.py,sha256=WKnHqeHiS2Ut-SaDBNOxqh1jDLeTiyLTsJ7PNUexrjk,687
64
64
  pymammotion/mqtt/mammotion_mqtt.py,sha256=X012f5RvmZI52FlgchLSWbngvPnkv9M_gTYvJHakYaM,8127
@@ -105,14 +105,15 @@ pymammotion/proto/mctrl_sys_pb2.py,sha256=DYemb514mlC7c27t-k1YqqBif0xxhLmnIWk8rX
105
105
  pymammotion/proto/mctrl_sys_pb2.pyi,sha256=Dj_1UM86kZ5MfcVyNC76Z0gKrfl5YFsVWP2b-bKoZvk,38912
106
106
  pymammotion/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
107
107
  pymammotion/utility/constant/__init__.py,sha256=tZz7szqIhrzNjfcLU3ysfINfg5VEBUAisd9AhP4mvT0,38
108
- pymammotion/utility/constant/device_constant.py,sha256=aM69DJJy-h-btLP9RJezld1zm1rGz4gZRdRSpArVtmc,7109
108
+ pymammotion/utility/constant/device_constant.py,sha256=rAEK60F52VyJL31uLnq0Y60D-0VK5gVm59yi9kBfndM,7123
109
+ pymammotion/utility/conversions.py,sha256=ioVTEGTmq2-H9GSQbHlm2D9mNAhOTbabuiTaKPElyXQ,88
109
110
  pymammotion/utility/datatype_converter.py,sha256=v6zym2Zu0upxQjR-xDqXwi3516zpntSlg7LP8tQF5K8,4216
110
111
  pymammotion/utility/device_type.py,sha256=KYawu2glZMVlPmxRbA4kVFujXz3miHp3rJiOWRVj-GI,8285
111
112
  pymammotion/utility/map.py,sha256=aoi-Luzuph02hKynTofMoq3mnPstanx75MDAVv49CuY,2211
112
113
  pymammotion/utility/movement.py,sha256=JISPBWCOe4MqHbhmkewhV5aWykr1p6f01DzJfvOF-J8,613
113
114
  pymammotion/utility/periodic.py,sha256=9wJMfwXPlx6Mbp3Fws7LLTI34ZDKphH1bva_Ggyk32g,3281
114
115
  pymammotion/utility/rocker_util.py,sha256=syPL0QN4zMzHiTIkUKS7RXBBptjdbkfNlPddwUD5V3A,7171
115
- pymammotion-0.2.23.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
116
- pymammotion-0.2.23.dist-info/METADATA,sha256=gKOZy5S7Pu2ee9TUEE8mISFQUQSljhSixqC5LSSyQdQ,3969
117
- pymammotion-0.2.23.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
118
- pymammotion-0.2.23.dist-info/RECORD,,
116
+ pymammotion-0.2.25.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
117
+ pymammotion-0.2.25.dist-info/METADATA,sha256=liR32EcxsTwl9FcHXPD2W2Xnt7IefPMm5GxOHUTPRMc,3969
118
+ pymammotion-0.2.25.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
119
+ pymammotion-0.2.25.dist-info/RECORD,,