pymammotion 0.4.21__py3-none-any.whl → 0.4.23__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.
@@ -86,27 +86,43 @@ class FrameList(DataClassORJSONMixin):
86
86
 
87
87
  @dataclass
88
88
  class Plan(DataClassORJSONMixin):
89
+ pver: int = 0
89
90
  sub_cmd: int = 2
91
+ area: int = 0
92
+ work_time: int = 0
90
93
  version: str = ""
94
+ id: str = ""
91
95
  user_id: str = ""
92
96
  device_id: str = ""
93
97
  plan_id: str = ""
94
98
  task_id: str = ""
95
- start_time: str = "00:00"
99
+ job_id: str = ""
100
+ start_time: str = ""
101
+ end_time: str = ""
102
+ week: int = 0
96
103
  knife_height: int = 0
97
104
  model: int = 0
98
105
  edge_mode: int = 0
106
+ required_time: int = 0
107
+ route_angle: int = 0
99
108
  route_model: int = 0
100
109
  route_spacing: int = 0
101
110
  ultrasonic_barrier: int = 0
102
111
  total_plan_num: int = 0
112
+ plan_index: int = 0
113
+ result: int = 0
103
114
  speed: float = 0.0
104
115
  task_name: str = ""
105
- zone_hashs: list[str] = field(default_factory=list)
116
+ job_name: str = ""
117
+ zone_hashs: list[int] = field(default_factory=list)
106
118
  reserved: str = ""
107
119
  start_date: str = ""
120
+ end_date: str = ""
108
121
  trigger_type: int = 0
109
- remained_seconds: str = "-1"
122
+ day: int = 0
123
+ weeks: list[int] = field(default_factory=list)
124
+ remained_seconds: int = 0
125
+ toward_mode: int = 0
110
126
  toward_included_angle: int = 0
111
127
 
112
128
 
@@ -263,6 +279,9 @@ class HashList(DataClassORJSONMixin):
263
279
 
264
280
  return []
265
281
 
282
+ def update_plan(self, plan: Plan) -> None:
283
+ self.plan[plan.plan_index] = plan
284
+
266
285
  def update(self, hash_data: NavGetCommData | SvgMessage) -> bool:
267
286
  """Update the map data."""
268
287
 
@@ -9,7 +9,7 @@ import betterproto
9
9
 
10
10
  from pymammotion.data.model.device import MowingDevice
11
11
  from pymammotion.data.model.device_info import SideLight
12
- from pymammotion.data.model.hash_list import AreaHashNameList, NavGetCommData, NavGetHashListData, SvgMessage
12
+ from pymammotion.data.model.hash_list import AreaHashNameList, NavGetCommData, NavGetHashListData, Plan, SvgMessage
13
13
  from pymammotion.data.mqtt.properties import ThingPropertiesMessage
14
14
  from pymammotion.data.mqtt.status import ThingStatusMessage
15
15
  from pymammotion.proto import (
@@ -21,6 +21,7 @@ from pymammotion.proto import (
21
21
  LubaMsg,
22
22
  NavGetCommDataAck,
23
23
  NavGetHashListAck,
24
+ NavPlanJobSet,
24
25
  SvgMessageAckT,
25
26
  TimeCtrlLight,
26
27
  WifiIotStatusReport,
@@ -36,6 +37,7 @@ class StateManager:
36
37
  last_updated_at: datetime = datetime.now()
37
38
  cloud_gethash_ack_callback: Callable[[NavGetHashListAck], Awaitable[None]] | None = None
38
39
  cloud_get_commondata_ack_callback: Callable[[NavGetCommDataAck | SvgMessageAckT], Awaitable[None]] | None = None
40
+ cloud_get_plan_callback: Callable[[NavPlanJobSet], Awaitable[None]] | None = None
39
41
  cloud_on_notification_callback: Callable[[tuple[str, Any | None]], Awaitable[None]] | None = None
40
42
 
41
43
  # possibly don't need anymore
@@ -43,6 +45,7 @@ class StateManager:
43
45
 
44
46
  ble_gethash_ack_callback: Callable[[NavGetHashListAck], Awaitable[None]] | None = None
45
47
  ble_get_commondata_ack_callback: Callable[[NavGetCommDataAck | SvgMessageAckT], Awaitable[None]] | None = None
48
+ ble_get_plan_callback: Callable[[NavPlanJobSet], Awaitable[None]] | None = None
46
49
  ble_on_notification_callback: Callable[[tuple[str, Any | None]], Awaitable[None]] | None = None
47
50
 
48
51
  # possibly don't need anymore
@@ -97,6 +100,12 @@ class StateManager:
97
100
  elif self.ble_get_commondata_ack_callback:
98
101
  await self.ble_get_commondata_ack_callback(comm_data)
99
102
 
103
+ async def get_plan_callback(self, planjob: NavPlanJobSet) -> None:
104
+ if self.cloud_get_plan_callback:
105
+ await self.get_plan_callback(planjob)
106
+ elif self.ble_get_plan_callback:
107
+ await self.ble_get_plan_callback(planjob)
108
+
100
109
  async def notification(self, message: LubaMsg) -> None:
101
110
  """Handle protobuf notifications."""
102
111
  res = betterproto.which_one_of(message, "LubaSubMsg")
@@ -138,6 +147,11 @@ class StateManager:
138
147
  )
139
148
  if updated:
140
149
  await self.get_commondata_ack_callback(common_data)
150
+ case "todev_planjob_set":
151
+ planjob: NavPlanJobSet = nav_msg[1]
152
+ self._device.map.update_plan(Plan.from_dict(planjob.to_dict(casing=betterproto.Casing.SNAKE)))
153
+ await self.get_plan_callback(planjob)
154
+
141
155
  case "toapp_svg_msg":
142
156
  common_svg_data: SvgMessageAckT = nav_msg[1]
143
157
  updated = self._device.map.update(
@@ -10,7 +10,7 @@ from pymammotion.data.model import RegionData
10
10
  from pymammotion.data.model.device import MowingDevice
11
11
  from pymammotion.data.model.raw_data import RawMowerData
12
12
  from pymammotion.data.state_manager import StateManager
13
- from pymammotion.proto import LubaMsg, NavGetCommDataAck, NavGetHashListAck, SvgMessageAckT
13
+ from pymammotion.proto import LubaMsg, NavGetCommDataAck, NavGetHashListAck, NavPlanJobSet, SvgMessageAckT
14
14
  from pymammotion.utility.device_type import DeviceType
15
15
 
16
16
  _LOGGER = logging.getLogger(__name__)
@@ -89,6 +89,14 @@ class MammotionBaseDevice:
89
89
  region_data.current_frame = current_frame
90
90
  await self.queue_command("get_regional_data", regional_data=region_data)
91
91
 
92
+ async def plan_callback(self, plan: NavPlanJobSet) -> None:
93
+ if plan.plan_index != 0 and plan.total_plan_num - 1 != plan.plan_index:
94
+ index = plan.plan_index
95
+ while index in self.mower.map.plan and index < plan.total_plan_num:
96
+ index += 1
97
+ if index < plan.total_plan_num:
98
+ await self.queue_command("read_plan", plan_index=index)
99
+
92
100
  def _update_raw_data(self, data: bytes) -> None:
93
101
  """Update raw and model data from notifications."""
94
102
  tmp_msg = LubaMsg().parse(data)
@@ -216,7 +224,8 @@ class MammotionBaseDevice:
216
224
  if self._cloud_device and len(self.mower.map.area_name) == 0 and not DeviceType.is_luba1(self.mower.name):
217
225
  await self.queue_command("get_area_name_list", device_id=self._cloud_device.iotId)
218
226
 
219
- await self.queue_command("read_plan", sub_cmd=2, plan_index=0)
227
+ if len(self.mower.map.plan) == 0 or self.mower.map.plan[0].total_plan_num != len(self.mower.map.plan):
228
+ await self.queue_command("read_plan", sub_cmd=2, plan_index=0)
220
229
 
221
230
  for hash, frame in list(self.mower.map.area.items()):
222
231
  missing_frames = self.mower.map.find_missing_frames(frame)
@@ -91,6 +91,7 @@ class MammotionBaseBLEDevice(MammotionBaseDevice):
91
91
  self.set_queue_callback(self.queue_command)
92
92
  self._state_manager.ble_gethash_ack_callback = self.datahash_response
93
93
  self._state_manager.ble_get_commondata_ack_callback = self.commdata_response
94
+ self._state_manager.ble_get_plan_callback = self.plan_callback
94
95
  loop = asyncio.get_event_loop()
95
96
  loop.create_task(self.process_queue())
96
97
 
@@ -167,6 +167,7 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
167
167
  self._mqtt.on_connected_event.add_subscribers(self.on_connect)
168
168
  self._state_manager.cloud_gethash_ack_callback = self.datahash_response
169
169
  self._state_manager.cloud_get_commondata_ack_callback = self.commdata_response
170
+ self._state_manager.cloud_get_plan_callback = self.plan_callback
170
171
  self.set_queue_callback(self.queue_command)
171
172
 
172
173
  if self._mqtt.is_ready:
@@ -227,6 +228,9 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
227
228
  # self.mqtt._mqtt_client.thing_on_thing_enable(None)
228
229
 
229
230
  async def _ble_sync(self) -> None:
231
+ if self.stopped or self._mqtt.is_connected is False:
232
+ return
233
+
230
234
  command_bytes = self._commands.send_todev_ble_sync(3)
231
235
  try:
232
236
  await self._mqtt.send_command(self.iot_id, command_bytes)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pymammotion
3
- Version: 0.4.21
3
+ Version: 0.4.23
4
4
  Summary:
5
5
  License: GPL-3.0
6
6
  Author: Michael Arthur
@@ -33,7 +33,7 @@ pymammotion/data/model/enums.py,sha256=EpKmO8yVUZyEnTY4yH0DMMVKYNQM42zpW1maUu0i3
33
33
  pymammotion/data/model/excute_boarder_params.py,sha256=9CpUqrygcle1C_1hDW-riLmm4map4ZbE842NXjcomEI,1394
34
34
  pymammotion/data/model/execute_boarder.py,sha256=9rd_h4fbcsXxgnLOd2rO2hWyD1abnTGc47QTEpp8DD0,1103
35
35
  pymammotion/data/model/generate_route_information.py,sha256=pgjqURwmEIzjCMbl4Z5JDDkfxyUAdry1KhPfyir3-mU,777
36
- pymammotion/data/model/hash_list.py,sha256=8HqUIz2_lVen-2iZwsWNz54odfErRS6mUCrKK861_wA,11628
36
+ pymammotion/data/model/hash_list.py,sha256=kB2p6OWIouEL2gD67JFxQSWkzUrG33-Kcg84E84ZZKg,12083
37
37
  pymammotion/data/model/location.py,sha256=PwmITejfI4pm7PI4rzqSuuHetwle6IJr_CV95435s2M,871
38
38
  pymammotion/data/model/mowing_modes.py,sha256=bBbRhDe-imZsXDR0TN0emQv6BiIkAlXJFb5isPEjgDk,1078
39
39
  pymammotion/data/model/plan.py,sha256=wGlcJT-w0EdbWK9jI838TCOm_MABFg7WoR664VB8RWg,2880
@@ -45,7 +45,7 @@ pymammotion/data/mqtt/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdr
45
45
  pymammotion/data/mqtt/event.py,sha256=r14gzZVxmlGVAwFdZQ1CUsMZFHHwRKnbt2VHnjugP28,5123
46
46
  pymammotion/data/mqtt/properties.py,sha256=pX5JRVmmpVO04CSPm5xAGcSWA_OeLd0JnBagLsfiSEc,3755
47
47
  pymammotion/data/mqtt/status.py,sha256=SgdrpE1Uldb01hybO6hYhgU1Sp1eILghC0UhMZMHrdQ,1091
48
- pymammotion/data/state_manager.py,sha256=H3xHcLorw4xBtDAhyigl5rd1SYkLaSTBB9qQ6XQV9SM,8646
48
+ pymammotion/data/state_manager.py,sha256=MiRnTzwHZ9lOZE_K-IjNPrtTu_MX75neUTTIQT2VBv4,9355
49
49
  pymammotion/event/__init__.py,sha256=mgATR6vPHACNQ-0zH5fi7NdzeTCDV1CZyaWPmtUusi8,115
50
50
  pymammotion/event/event.py,sha256=bj2RirSIRyBs0QvkcrOtwZWUX_8F3m1sySuHVyKmZLs,2143
51
51
  pymammotion/http/_init_.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -67,10 +67,10 @@ pymammotion/mammotion/commands/messages/video.py,sha256=YQGIxKx2prA0X01ovNmMkX6Y
67
67
  pymammotion/mammotion/control/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
68
68
  pymammotion/mammotion/control/joystick.py,sha256=QfBVxM_gxpWsZAGO90whtgxCI2tIZ3TTad9wHIPsU9s,5640
69
69
  pymammotion/mammotion/devices/__init__.py,sha256=f2qQFPgLGmV85W2hSlMUh5BYuht9o_Ar_JEAAMD4fsE,102
70
- pymammotion/mammotion/devices/base.py,sha256=w7ZucgZkOBdpPajrJs-W4oZpoDRpTDYgCCdVlwOP-uo,11901
70
+ pymammotion/mammotion/devices/base.py,sha256=FeESaqNcHqQ_4Ew8Hq2BCQQZQeS9M8lOvw8zBJLka2k,12435
71
71
  pymammotion/mammotion/devices/mammotion.py,sha256=ffzwsQqO9zDwMElWYMsxi-J5_rGaOOOHdAm5D3DXprc,13671
72
- pymammotion/mammotion/devices/mammotion_bluetooth.py,sha256=B1tpnC8vrbXGKhFq-l5LR86EcCvd6iHuW5kOkhpjwgY,19541
73
- pymammotion/mammotion/devices/mammotion_cloud.py,sha256=vh35qIT5hC6h6TwwejGa_GusU_oD7_dsX9b8b526irI,13720
72
+ pymammotion/mammotion/devices/mammotion_bluetooth.py,sha256=nIuOW22Une1Zk1tN691jGUv_eqQJA8K2LuC9ohPUHAk,19612
73
+ pymammotion/mammotion/devices/mammotion_cloud.py,sha256=GSa9FPG2Ob7eP7L_WqV5Wk9LzL6dKbhFJsBTyLJBguI,13874
74
74
  pymammotion/mqtt/__init__.py,sha256=Ocs5e-HLJvTuDpVXyECEsWIvwsUaxzj7lZ9mSYutNDY,105
75
75
  pymammotion/mqtt/linkkit/__init__.py,sha256=ENgc3ynd2kd9gMQR3-kgmCu6Ed9Y6XCIzU0zFReUlkk,80
76
76
  pymammotion/mqtt/linkkit/h2client.py,sha256=w9Nvi_nY4CLD_fw-pHtYChwQf7e2TiAGeqkY_sF4cf0,19659
@@ -119,7 +119,7 @@ pymammotion/utility/map.py,sha256=GYscVMg2cX3IPlNpCBNHDW0S55yS1WGRf1iHnNZ7TfQ,22
119
119
  pymammotion/utility/movement.py,sha256=N75oAoAgFydqoaOedYIxGUHmuTCtPzAOtb-d_29tpfI,615
120
120
  pymammotion/utility/periodic.py,sha256=MbeSb9cfhxzYmdT_RiE0dZe3H9IfbQW_zSqhmSX2RUc,3321
121
121
  pymammotion/utility/rocker_util.py,sha256=6tX7sS87qoQC_tsxbx3NLL-HgS08wtzXiZkhDiz7uo0,7179
122
- pymammotion-0.4.21.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
123
- pymammotion-0.4.21.dist-info/METADATA,sha256=yevyvFzOc9oRwbm9Qm4-KAndb4D4VQGHwuB42tlH1gY,3834
124
- pymammotion-0.4.21.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
125
- pymammotion-0.4.21.dist-info/RECORD,,
122
+ pymammotion-0.4.23.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
123
+ pymammotion-0.4.23.dist-info/METADATA,sha256=bzbUeA0qbWXlykj69bKDHYVSCNM4COzTMVNIExegO_M,3834
124
+ pymammotion-0.4.23.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
125
+ pymammotion-0.4.23.dist-info/RECORD,,