pymammotion 0.4.9__py3-none-any.whl → 0.4.11b1__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.
@@ -46,6 +46,10 @@ MOVE_HEADERS = (
46
46
  class SetupException(Exception):
47
47
  """Raise when mqtt expires token or token is invalid."""
48
48
 
49
+ def __init__(self, *args: object) -> None:
50
+ super().__init__(args)
51
+ self.iot_id = args[1]
52
+
49
53
 
50
54
  class AuthRefreshException(Exception):
51
55
  """Raise exception when library cannot refresh token."""
@@ -54,6 +58,10 @@ class AuthRefreshException(Exception):
54
58
  class DeviceOfflineException(Exception):
55
59
  """Raise exception when device is offline."""
56
60
 
61
+ def __init__(self, *args: object) -> None:
62
+ super().__init__(args)
63
+ self.iot_id = args[1]
64
+
57
65
 
58
66
  class NoConnectionException(UnretryableException):
59
67
  """Raise exception when device is unreachable."""
@@ -62,6 +70,10 @@ class NoConnectionException(UnretryableException):
62
70
  class GatewayTimeoutException(Exception):
63
71
  """Raise exception when the gateway times out."""
64
72
 
73
+ def __init__(self, *args: object) -> None:
74
+ super().__init__(args)
75
+ self.iot_id = args[1]
76
+
65
77
 
66
78
  class LoginException(Exception):
67
79
  """Raise exception when library cannot log in."""
@@ -696,14 +708,14 @@ class CloudIOTGateway:
696
708
  )
697
709
  if response_body_dict.get("code") == 20056:
698
710
  logger.debug("Gateway timeout.")
699
- raise GatewayTimeoutException(response_body_dict.get("code"))
711
+ raise GatewayTimeoutException(response_body_dict.get("code"), iot_id)
700
712
 
701
713
  if response_body_dict.get("code") == 29003:
702
714
  logger.debug(self._session_by_authcode_response.data.identityId)
703
715
  self.sign_out()
704
- raise SetupException(response_body_dict.get("code"))
716
+ raise SetupException(response_body_dict.get("code"), iot_id)
705
717
  if response_body_dict.get("code") == 6205:
706
- raise DeviceOfflineException(response_body_dict.get("code"))
718
+ raise DeviceOfflineException(response_body_dict.get("code"), iot_id)
707
719
 
708
720
  return message_id
709
721
 
@@ -118,7 +118,7 @@ class HashList(DataClassORJSONMixin):
118
118
  hashlist for all our hashIDs for verification
119
119
  """
120
120
 
121
- root_hash_list: RootHashList = field(default_factory=RootHashList)
121
+ root_hash_lists: list[RootHashList] = field(default_factory=list)
122
122
  area: dict = field(default_factory=dict) # type 0
123
123
  path: dict = field(default_factory=dict) # type 2
124
124
  obstacle: dict = field(default_factory=dict) # type 1
@@ -135,37 +135,51 @@ class HashList(DataClassORJSONMixin):
135
135
 
136
136
  @property
137
137
  def hashlist(self) -> list[int]:
138
- if len(self.root_hash_list.data) == 0:
138
+ if not self.root_hash_lists:
139
139
  return []
140
- return [i for obj in self.root_hash_list.data for i in obj.data_couple]
140
+ # Combine data_couple from all RootHashLists
141
+ return [i for root_list in self.root_hash_lists for obj in root_list.data for i in obj.data_couple]
141
142
 
142
143
  @property
143
144
  def missing_hashlist(self) -> list[int]:
144
145
  """Return missing hashlist."""
146
+ all_hash_ids = set(self.area.keys()).union(
147
+ self.path.keys(), self.obstacle.keys(), self.dump.keys(), self.svg.keys()
148
+ )
145
149
  return [
146
150
  i
147
- for obj in self.root_hash_list.data
151
+ for root_list in self.root_hash_lists
152
+ for obj in root_list.data
148
153
  for i in obj.data_couple
149
- if f"{i}"
150
- not in set(self.area.keys()).union(
151
- self.path.keys(), self.obstacle.keys(), self.dump.keys(), self.svg.keys()
152
- )
154
+ if f"{i}" not in all_hash_ids
153
155
  ]
154
156
 
155
157
  def update_root_hash_list(self, hash_list: NavGetHashListData) -> None:
156
- self.root_hash_list.total_frame = hash_list.total_frame
158
+ target_root_list = next((rhl for rhl in self.root_hash_lists if rhl.total_frame == hash_list.total_frame), None)
157
159
 
158
- for index, obj in enumerate(self.root_hash_list.data):
160
+ if target_root_list is None:
161
+ # Create new RootHashList if none exists for this total_frame
162
+ new_root_list = RootHashList(total_frame=hash_list.total_frame, data=[hash_list])
163
+ self.root_hash_lists.append(new_root_list)
164
+ return
165
+
166
+ for index, obj in enumerate(target_root_list.data):
159
167
  if obj.current_frame == hash_list.current_frame:
160
168
  # Replace the item if current_frame matches
161
- self.root_hash_list.data[index] = hash_list
169
+ target_root_list.data[index] = hash_list
162
170
  return
163
171
 
164
172
  # If no match was found, append the new item
165
- self.root_hash_list.data.append(hash_list)
173
+ target_root_list.data.append(hash_list)
166
174
 
167
175
  def missing_hash_frame(self) -> list[int]:
168
- return self._find_missing_frames(self.root_hash_list)
176
+ """Returns a combined list of all missing frames across all RootHashLists."""
177
+ missing_frames = []
178
+ for root_list in self.root_hash_lists:
179
+ missing = self._find_missing_frames(root_list)
180
+ if missing:
181
+ missing_frames.extend(missing)
182
+ return missing_frames
169
183
 
170
184
  def missing_frame(self, hash_data: NavGetCommDataAck | SvgMessageAckT) -> list[int]:
171
185
  if hash_data.type == PathType.AREA:
@@ -219,6 +219,7 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
219
219
  """Stop all tasks and disconnect."""
220
220
  if self._ble_sync_task:
221
221
  self._ble_sync_task.cancel()
222
+ # self._mqtt._mqtt_client.unsubscribe()
222
223
  self.stopped = True
223
224
 
224
225
  async def start(self) -> None:
@@ -227,7 +228,10 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
227
228
  await self.run_periodic_sync_task()
228
229
  self.stopped = False
229
230
  if not self.mqtt.is_connected():
230
- self.mqtt.connect_async()
231
+ loop = asyncio.get_running_loop()
232
+ await loop.run_in_executor(None, self.mqtt.connect_async)
233
+ # else:
234
+ # self.mqtt._mqtt_client.thing_on_thing_enable(None)
231
235
 
232
236
  async def _ble_sync(self) -> None:
233
237
  command_bytes = self._commands.send_todev_ble_sync(3)
@@ -142,6 +142,31 @@ class MammotionMQTT:
142
142
  # command = MammotionCommand(device_name="Luba")
143
143
  # self._cloud_client.send_cloud_command(command.get_report_cfg())
144
144
 
145
+ def unsubscribe(self) -> None:
146
+ self._linkkit_client.unsubscribe_topic(
147
+ f"/sys/{self._product_key}/{self._device_name}/app/down/account/bind_reply"
148
+ )
149
+ self._linkkit_client.unsubscribe_topic(
150
+ f"/sys/{self._product_key}/{self._device_name}/app/down/thing/event/property/post_reply"
151
+ )
152
+ self._linkkit_client.unsubscribe_topic(
153
+ f"/sys/{self._product_key}/{self._device_name}/app/down/thing/wifi/status/notify"
154
+ )
155
+ self._linkkit_client.unsubscribe_topic(
156
+ f"/sys/{self._product_key}/{self._device_name}/app/down/thing/wifi/connect/event/notify"
157
+ )
158
+ self._linkkit_client.unsubscribe_topic(
159
+ f"/sys/{self._product_key}/{self._device_name}/app/down/_thing/event/notify"
160
+ )
161
+ self._linkkit_client.unsubscribe_topic(f"/sys/{self._product_key}/{self._device_name}/app/down/thing/events")
162
+ self._linkkit_client.unsubscribe_topic(f"/sys/{self._product_key}/{self._device_name}/app/down/thing/status")
163
+ self._linkkit_client.unsubscribe_topic(
164
+ f"/sys/{self._product_key}/{self._device_name}/app/down/thing/properties"
165
+ )
166
+ self._linkkit_client.unsubscribe_topic(
167
+ f"/sys/{self._product_key}/{self._device_name}/app/down/thing/model/down_raw"
168
+ )
169
+
145
170
  def _thing_on_topic_message(self, topic, payload, qos, user_data) -> None:
146
171
  """Is called when thing topic comes in."""
147
172
  logger.debug(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pymammotion
3
- Version: 0.4.9
3
+ Version: 0.4.11b1
4
4
  Summary:
5
5
  License: GPL-3.0
6
6
  Author: Michael Arthur
@@ -1,6 +1,6 @@
1
1
  pymammotion/__init__.py,sha256=u1OHuD8Uj0qCOH4I7Lt5d7T-TPt1R0pY-bv8S6UfVxM,1587
2
2
  pymammotion/aliyun/__init__.py,sha256=T1lkX7TRYiL4nqYanG4l4MImV-SlavSbuooC-W-uUGw,29
3
- pymammotion/aliyun/cloud_gateway.py,sha256=2IE72NSM93rtHIAmdTnIdXU_Ak2txXNiaayVSkND6WQ,26254
3
+ pymammotion/aliyun/cloud_gateway.py,sha256=mafX63IuRhbSLNv5WjwhbDY4HJGHRCYAMJseVOQebJE,26605
4
4
  pymammotion/aliyun/model/aep_response.py,sha256=EY4uMTJ4F9rvbcXnAOc5YKi7q__9kIVgfDwfyr65Gk0,421
5
5
  pymammotion/aliyun/model/connect_response.py,sha256=Yz-fEbDzgGPTo5Of2oAjmFkSv08T7ze80pQU4k-gKIU,824
6
6
  pymammotion/aliyun/model/dev_by_account_response.py,sha256=P9yYy4Z2tLkJSqXA_5XGaCUliSSVa5ILl7VoMtL_tCA,977
@@ -31,7 +31,7 @@ pymammotion/data/model/enums.py,sha256=EpKmO8yVUZyEnTY4yH0DMMVKYNQM42zpW1maUu0i3
31
31
  pymammotion/data/model/excute_boarder_params.py,sha256=9CpUqrygcle1C_1hDW-riLmm4map4ZbE842NXjcomEI,1394
32
32
  pymammotion/data/model/execute_boarder.py,sha256=9rd_h4fbcsXxgnLOd2rO2hWyD1abnTGc47QTEpp8DD0,1103
33
33
  pymammotion/data/model/generate_route_information.py,sha256=pgjqURwmEIzjCMbl4Z5JDDkfxyUAdry1KhPfyir3-mU,777
34
- pymammotion/data/model/hash_list.py,sha256=1mwL715Q-OizowBDDPk1n_mYDZgb7kz24cIfzKu0QUM,7892
34
+ pymammotion/data/model/hash_list.py,sha256=EKX-P8I2dp234GsMzZgi6afxX2xwgcYfk7kl8ezvf_g,8605
35
35
  pymammotion/data/model/location.py,sha256=PwmITejfI4pm7PI4rzqSuuHetwle6IJr_CV95435s2M,871
36
36
  pymammotion/data/model/mowing_modes.py,sha256=bBbRhDe-imZsXDR0TN0emQv6BiIkAlXJFb5isPEjgDk,1078
37
37
  pymammotion/data/model/plan.py,sha256=wGlcJT-w0EdbWK9jI838TCOm_MABFg7WoR664VB8RWg,2880
@@ -68,13 +68,13 @@ pymammotion/mammotion/devices/__init__.py,sha256=f2qQFPgLGmV85W2hSlMUh5BYuht9o_A
68
68
  pymammotion/mammotion/devices/base.py,sha256=Klkmvo56VgAX_zqen__lhbRb41k2U9HEHzA7t9FoZjc,10333
69
69
  pymammotion/mammotion/devices/mammotion.py,sha256=Zz2tUIdGA-jFSHLM3aO8tBMvVl7sBIBiqC9Kg7f-lm8,13190
70
70
  pymammotion/mammotion/devices/mammotion_bluetooth.py,sha256=oNDwtDKsdsG62frehBCg6xmwF3CD3VJ32iUwQcAjzKo,19576
71
- pymammotion/mammotion/devices/mammotion_cloud.py,sha256=Pgd_jEX2-Y4g5zRI_HW3vr_hW0g_8U73aQkgN3FVG5o,14001
71
+ pymammotion/mammotion/devices/mammotion_cloud.py,sha256=ckTsfCjyCF_asXmACb7UgkPGUSdz9PqxlFdX1YPF7js,14208
72
72
  pymammotion/mqtt/__init__.py,sha256=Ocs5e-HLJvTuDpVXyECEsWIvwsUaxzj7lZ9mSYutNDY,105
73
73
  pymammotion/mqtt/linkkit/__init__.py,sha256=ENgc3ynd2kd9gMQR3-kgmCu6Ed9Y6XCIzU0zFReUlkk,80
74
74
  pymammotion/mqtt/linkkit/h2client.py,sha256=w9Nvi_nY4CLD_fw-pHtYChwQf7e2TiAGeqkY_sF4cf0,19659
75
75
  pymammotion/mqtt/linkkit/linkkit.py,sha256=NzFpdtfxNHQ6xNu-POyp45fTK7AWUAWV7RavFevX4m4,132772
76
76
  pymammotion/mqtt/mammotion_future.py,sha256=_OWqKOlUGl2yT1xOsXFQYpGd-1zQ63OxqXgy7KRQgYc,710
77
- pymammotion/mqtt/mammotion_mqtt.py,sha256=dQuGz-dQnOYI7vz_v5Kn9nHcizs-S0E2lZzJlZVkG5Y,8867
77
+ pymammotion/mqtt/mammotion_mqtt.py,sha256=urqhTIXabJ8QGAkArPZZQAm7CJQiA00912mviotTSds,10194
78
78
  pymammotion/proto/__init__.py,sha256=BLOSkNGEVbDJGtg9wYi0ziO3_tl3CIBRU3Sf9pmjuKU,72202
79
79
  pymammotion/proto/basestation.proto,sha256=_x5gAz3FkZXS1jtq4GgZgaDCuRU-UV-7HTFdsfQ3zbo,1034
80
80
  pymammotion/proto/basestation_pb2.py,sha256=PTVlHcDLQeRV6qv7ZPjGke9MF68mpqoUeJA0Sw_AoT0,2776
@@ -117,7 +117,7 @@ pymammotion/utility/map.py,sha256=GYscVMg2cX3IPlNpCBNHDW0S55yS1WGRf1iHnNZ7TfQ,22
117
117
  pymammotion/utility/movement.py,sha256=N75oAoAgFydqoaOedYIxGUHmuTCtPzAOtb-d_29tpfI,615
118
118
  pymammotion/utility/periodic.py,sha256=MbeSb9cfhxzYmdT_RiE0dZe3H9IfbQW_zSqhmSX2RUc,3321
119
119
  pymammotion/utility/rocker_util.py,sha256=6tX7sS87qoQC_tsxbx3NLL-HgS08wtzXiZkhDiz7uo0,7179
120
- pymammotion-0.4.9.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
121
- pymammotion-0.4.9.dist-info/METADATA,sha256=XNyGzp7QPZdl5_8dAyCTXeu4KpdeBkyA_dCEK_fXQJM,3884
122
- pymammotion-0.4.9.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
123
- pymammotion-0.4.9.dist-info/RECORD,,
120
+ pymammotion-0.4.11b1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
121
+ pymammotion-0.4.11b1.dist-info/METADATA,sha256=DofePhYsQPvJiHt2WhaVGMYn1ZiRD2voldlNeG5gxPY,3887
122
+ pymammotion-0.4.11b1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
123
+ pymammotion-0.4.11b1.dist-info/RECORD,,