pymammotion 0.5.11__py3-none-any.whl → 0.5.12__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.

@@ -87,6 +87,7 @@ class StateManager:
87
87
  await self.on_status_callback(thing_status)
88
88
 
89
89
  async def device_event(self, device_event: ThingEventMessage) -> None:
90
+ """Sets MQTT event and calls callback."""
90
91
  self._device.mqtt_device_event = device_event
91
92
  await self.on_device_event_callback(device_event)
92
93
 
@@ -121,7 +122,7 @@ class StateManager:
121
122
  await self.status_callback.data_event(thing_status)
122
123
 
123
124
  async def on_device_event_callback(self, device_event: ThingEventMessage) -> None:
124
- """Execute the status callback if it is set."""
125
+ """Executes the status callback if it is set."""
125
126
  if self.device_event_callback:
126
127
  await self.device_event_callback.data_event(device_event)
127
128
 
pymammotion/http/http.py CHANGED
@@ -29,6 +29,7 @@ class MammotionHTTP:
29
29
  return await self.login(email, password)
30
30
 
31
31
  async def get_all_error_codes(self) -> dict[str, ErrorInfo]:
32
+ """Retrieves and parses all error codes from the MAMMOTION API."""
32
33
  async with ClientSession(MAMMOTION_API_DOMAIN) as session:
33
34
  async with session.post(
34
35
  "/user-server/v1/code/record/export-data",
@@ -7,12 +7,13 @@ from pymammotion.utility.device_type import DeviceType
7
7
 
8
8
  class AbstractMessage:
9
9
  seqs = AtomicInteger(0)
10
- user_account: int = 1
10
+ user_account: int
11
11
 
12
12
  @abstractmethod
13
13
  def get_device_name(self) -> str:
14
14
  """Get device name."""
15
15
 
16
+ @abstractmethod
16
17
  def get_device_product_key(self) -> str:
17
18
  """Get device name."""
18
19
 
@@ -5,6 +5,7 @@ from pymammotion.mammotion.commands.messages.network import MessageNetwork
5
5
  from pymammotion.mammotion.commands.messages.ota import MessageOta
6
6
  from pymammotion.mammotion.commands.messages.system import MessageSystem
7
7
  from pymammotion.mammotion.commands.messages.video import MessageVideo
8
+ from pymammotion.utility.device_type import DeviceType
8
9
  from pymammotion.utility.movement import get_percent, transform_both_speeds
9
10
 
10
11
 
@@ -22,6 +23,13 @@ class MammotionCommand(
22
23
  """Get device name."""
23
24
  return self._device_name
24
25
 
26
+ def read_write_device(self, rw_id: int, context: int, rw: int):
27
+ if (
28
+ rw_id == 6 or rw_id == 3 or rw_id == 7 or rw_id == 8 or rw_id == 10 or rw_id == 11
29
+ ) and DeviceType.is_luba_pro(self.get_device_name()):
30
+ return self.allpowerfull_rw_adapter_x3(rw_id, context, rw)
31
+ return self.allpowerfull_rw(rw_id, context, rw)
32
+
25
33
  def get_device_product_key(self) -> str:
26
34
  return self._product_key
27
35
 
@@ -50,7 +50,7 @@ class MessageNavigation(AbstractMessage, ABC):
50
50
 
51
51
  def allpowerfull_rw_adapter_x3(self, rw_id: int, context: int, rw: int) -> bytes:
52
52
  build = MctlNav(nav_sys_param_cmd=NavSysParamMsg(id=rw_id, context=context, rw=rw))
53
- logger.debug(f"Send command--9 general read and write command id={id}, context={context}, rw={rw}")
53
+ logger.debug(f"Send command--x3 general read and write command id={rw_id}, context={context}, rw={rw}")
54
54
  return self.send_order_msg_nav(build)
55
55
 
56
56
  def along_border(self) -> bytes:
@@ -1,9 +1,12 @@
1
1
  # === sendOrderMsg_Ota ===
2
2
  from abc import ABC
3
+ import logging
3
4
 
4
5
  from pymammotion.mammotion.commands.abstract_message import AbstractMessage
5
6
  from pymammotion.proto import GetInfoReq, InfoType, LubaMsg, MctlOta, MsgAttr, MsgCmdType, MsgDevice
6
7
 
8
+ _LOGGER = logging.getLogger(__name__)
9
+
7
10
 
8
11
  class MessageOta(AbstractMessage, ABC):
9
12
  """Message OTA class."""
@@ -25,11 +28,11 @@ class MessageOta(AbstractMessage, ABC):
25
28
  def get_device_ota_info(self, log_type: int):
26
29
  todev_get_info_req = MctlOta(todev_get_info_req=GetInfoReq(type=InfoType.IT_OTA))
27
30
 
28
- print("===Send command to get upgrade details===logType:" + str(log_type))
31
+ _LOGGER.debug("===Send command to get upgrade details===logType:" + str(log_type))
29
32
  return self.send_order_msg_ota(todev_get_info_req)
30
33
 
31
34
  def get_device_info_new(self) -> bytes:
32
35
  """New device call for OTA upgrade information."""
33
36
  todev_get_info_req = MctlOta(todev_get_info_req=GetInfoReq(type=InfoType.IT_BASE))
34
- print("Send to get OTA upgrade information", "Get device information")
37
+ _LOGGER.debug("Send to get OTA upgrade information", "Get device information")
35
38
  return self.send_order_msg_ota(todev_get_info_req)
@@ -5,7 +5,6 @@ import time
5
5
 
6
6
  from pymammotion import logger
7
7
  from pymammotion.mammotion.commands.abstract_message import AbstractMessage
8
- from pymammotion.mammotion.commands.messages.navigation import MessageNavigation
9
8
  from pymammotion.proto import (
10
9
  DeviceProductTypeInfoT,
11
10
  LoraCfgReq,
@@ -23,12 +22,9 @@ from pymammotion.proto import (
23
22
  SysSetDateTime,
24
23
  TimeCtrlLight,
25
24
  )
26
- from pymammotion.utility.device_type import DeviceType
27
25
 
28
26
 
29
27
  class MessageSystem(AbstractMessage, ABC):
30
- messageNavigation: MessageNavigation = MessageNavigation()
31
-
32
28
  def send_order_msg_sys(self, sys) -> bytes:
33
29
  luba_msg = LubaMsg(
34
30
  msgtype=MsgCmdType.EMBED_SYS,
@@ -119,10 +115,6 @@ class MessageSystem(AbstractMessage, ABC):
119
115
  return self.send_order_msg_sys(MctlSys(todev_lora_cfg_req=LoraCfgReq(op=op, cfg=cgf)))
120
116
 
121
117
  def allpowerfull_rw(self, rw_id: int, context: int, rw: int) -> bytes:
122
- if (
123
- rw_id == 6 or rw_id == 3 or rw_id == 7 or rw_id == 8 or rw_id == 10 or rw_id == 11
124
- ) and DeviceType.is_luba_pro(self.get_device_name()):
125
- return self.messageNavigation.allpowerfull_rw_adapter_x3(rw_id, context, rw)
126
118
  build = MctlSys(bidire_comm_cmd=SysCommCmd(id=rw_id, context=context, rw=rw))
127
119
  logger.debug(f"Send command - 9 general read and write command id={rw_id}, context={context}, rw={rw}")
128
120
  return self.send_order_msg_sys(build)
@@ -140,8 +140,10 @@ class MammotionDeviceManager:
140
140
  exists.replace_ble(mammotion_device.ble())
141
141
 
142
142
  def get_device(self, mammotion_device_name: str) -> MammotionMixedDeviceManager:
143
- """Get a device."""
144
- return self.devices.get(mammotion_device_name)
143
+ if device := self.devices[mammotion_device_name]:
144
+ return device
145
+ else:
146
+ raise KeyError
145
147
 
146
148
  async def remove_device(self, name: str) -> None:
147
149
  """Remove a device."""
@@ -52,6 +52,7 @@ class MammotionCloud:
52
52
  self._mqtt_client.on_ready = self.on_ready
53
53
 
54
54
  async def on_ready(self) -> None:
55
+ """Starts processing the queue and emits the ready event."""
55
56
  loop = asyncio.get_event_loop()
56
57
  loop.create_task(self.process_queue())
57
58
  await self.on_ready_event.data_event(None)
@@ -116,7 +117,16 @@ class MammotionCloud:
116
117
  await self._parse_mqtt_response(topic, payload)
117
118
 
118
119
  async def _parse_mqtt_response(self, topic: str, payload: dict) -> None:
119
- """Parse the MQTT response."""
120
+ """Parse and handle MQTT responses based on the topic.
121
+
122
+ This function processes different types of MQTT messages received from various
123
+ topics. It logs debug information and calls appropriate callback methods for
124
+ each event type.
125
+
126
+ Args:
127
+ topic (str): The MQTT topic from which the message was received.
128
+ payload (dict): The payload data of the MQTT message.
129
+ """
120
130
  if topic.endswith("/app/down/thing/events"):
121
131
  _LOGGER.debug("Thing event received")
122
132
  event = ThingEventMessage.from_dicts(payload)
@@ -323,11 +333,23 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
323
333
  await self.state_manager.status(status)
324
334
 
325
335
  async def _parse_device_event_for_device(self, status: ThingStatusMessage) -> None:
336
+ """Process device event if it matches the device's IoT ID."""
326
337
  if status.params.iotId != self.iot_id:
327
338
  return
328
339
  await self.state_manager.device_event(status)
329
340
 
330
341
  async def _parse_message_for_device(self, event: ThingEventMessage) -> None:
342
+ """Parses a message received from a device and updates internal state.
343
+
344
+ This function processes an incoming `ThingEventMessage`, checks if the message
345
+ is intended for this device, decodes the binary data, and updates raw data. It
346
+ then attempts to parse the binary data into a `LubaMsg`. If parsing fails, it
347
+ logs the exception. The function also handles setting the device product key if
348
+ not already set and processes specific sub-messages based on their types.
349
+
350
+ Args:
351
+ event (ThingEventMessage): The event message received from the device.
352
+ """
331
353
  params = event.params
332
354
  new_msg = LubaMsg()
333
355
  if event.params.iotId != self.iot_id:
@@ -180,7 +180,7 @@ class MammotionMQTT:
180
180
  asyncio.wrap_future(future, loop=self.loop)
181
181
 
182
182
  def _thing_on_connect(self, session_flag, rc, user_data) -> None:
183
- """Is called on thing connect."""
183
+ """Handle connection event and execute callback if set."""
184
184
  self.is_connected = True
185
185
  if self.on_connected is not None:
186
186
  future = asyncio.run_coroutine_threadsafe(self.on_connected(), self.loop)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pymammotion
3
- Version: 0.5.11
3
+ Version: 0.5.12
4
4
  Summary:
5
5
  License: GPL-3.0
6
6
  Author: Michael Arthur
@@ -46,42 +46,42 @@ pymammotion/data/mqtt/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdr
46
46
  pymammotion/data/mqtt/event.py,sha256=pj65y93ACcTzUIJkHZC6s_pRFBYaNMSU1wyYRhiGvw4,5571
47
47
  pymammotion/data/mqtt/properties.py,sha256=laud9rE-JqBHWKZ44Dov2yMkp3Ld8ghpBwlZ4_3g9uQ,4321
48
48
  pymammotion/data/mqtt/status.py,sha256=SgdrpE1Uldb01hybO6hYhgU1Sp1eILghC0UhMZMHrdQ,1091
49
- pymammotion/data/state_manager.py,sha256=K3o__YsjBS5C5tEujANnxI-lgQpbXhPMUIy3sgVc3QI,12056
49
+ pymammotion/data/state_manager.py,sha256=AyrXwcU7SxliQ1r8b_QqFMkMoS6l0VE-XfxLq7NZ5go,12107
50
50
  pymammotion/event/__init__.py,sha256=mgATR6vPHACNQ-0zH5fi7NdzeTCDV1CZyaWPmtUusi8,115
51
51
  pymammotion/event/event.py,sha256=Z8WYxv_-5khEqKjL1w4c_Et24G1Kdm8QFuIBylD3h3U,3021
52
52
  pymammotion/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
53
  pymammotion/http/_init_.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
54
  pymammotion/http/encryption.py,sha256=lzXu3WwBdQlzjXxWnlJuRgkCrKdPbxx5drhMitVKIEk,8287
55
- pymammotion/http/http.py,sha256=7tIk7KzM6Wq4bWApcdAgsvQ139HEMvqfIX2STRVJTyM,12331
55
+ pymammotion/http/http.py,sha256=-JT97FN8j5CfGPI5gPjFpOivBsKeP-IlzH0dIAioTvI,12406
56
56
  pymammotion/http/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
57
  pymammotion/http/model/camera_stream.py,sha256=ilxQNny_w9Frwt-m8kbHinvyjDv4Bx8C2swfZ2lTEDE,600
58
58
  pymammotion/http/model/http.py,sha256=VDBmi9nyY5Y2ns_HYvKIyzbkKRxhZ5elpq0lWXWzbGw,4123
59
59
  pymammotion/http/model/response_factory.py,sha256=f5_ZR0-4sLOU-q28BVy5sQOReSoND2A8UvpOOwnwrzA,1936
60
60
  pymammotion/mammotion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
61
61
  pymammotion/mammotion/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
- pymammotion/mammotion/commands/abstract_message.py,sha256=P5FcjGkfoQ1O4Q9JKdq306TisQnJ40xDXufR-juNn8k,792
63
- pymammotion/mammotion/commands/mammotion_command.py,sha256=3OFXQjF7HFwPd_j6utHVI2Kfwh7t6_6ff_9MKAWGTlk,2570
62
+ pymammotion/mammotion/commands/abstract_message.py,sha256=M4qL-Yw5g3fTgS9jB9LUSgJSAqpUf7MME-2mfv471Sk,808
63
+ pymammotion/mammotion/commands/mammotion_command.py,sha256=AMOx6nEbPa0HijbENomPLLuJummS1q-23BzgetBAuOI,2991
64
64
  pymammotion/mammotion/commands/messages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
65
  pymammotion/mammotion/commands/messages/driver.py,sha256=LAYGvAcDDXwwliQ1OfRwNBk1VpIdpURo1TlA64zpLA4,3701
66
66
  pymammotion/mammotion/commands/messages/media.py,sha256=X4LQG9SFNZXyqeaedjuEM10Jx9Bc6SN7kQFpKxrSFrQ,2934
67
- pymammotion/mammotion/commands/messages/navigation.py,sha256=aEEpvDW5QukJ0QiWMhPjjz0eTTF1ndQuvv8a6hJlUg0,23257
67
+ pymammotion/mammotion/commands/messages/navigation.py,sha256=yI-B5HHGuZJXn9iYrxhYZ5BArde6wB_j9bUc5IcSIJE,23261
68
68
  pymammotion/mammotion/commands/messages/network.py,sha256=OrmW4-BP_o3piBjwXZ12WY0HqbXHQqeDXC0YaDPeBM8,7409
69
- pymammotion/mammotion/commands/messages/ota.py,sha256=ZHLQRE5ETvLEIu2Vbj3m2XidIWT8uorYSHxkZd3pkRc,1376
70
- pymammotion/mammotion/commands/messages/system.py,sha256=P_J6ikTXGuVEsekOKGEV6o-wfrFDf8ChF4Tzxz6uDtY,14275
69
+ pymammotion/mammotion/commands/messages/ota.py,sha256=Nk3Tlp6n7hkbkuy355BlqbozHIHzsYnrH2cDO8QGaLk,1446
70
+ pymammotion/mammotion/commands/messages/system.py,sha256=620kzRgX_ee9ATRgxQ1fwog4hN_-ijGNxGUH-wwlIIU,13816
71
71
  pymammotion/mammotion/commands/messages/video.py,sha256=WExYvIcfVnStM5viP1VW05Fl_SmZipxGTAvZFZh3ryQ,1302
72
72
  pymammotion/mammotion/control/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
73
  pymammotion/mammotion/control/joystick.py,sha256=QfBVxM_gxpWsZAGO90whtgxCI2tIZ3TTad9wHIPsU9s,5640
74
74
  pymammotion/mammotion/devices/__init__.py,sha256=f2qQFPgLGmV85W2hSlMUh5BYuht9o_Ar_JEAAMD4fsE,102
75
75
  pymammotion/mammotion/devices/base.py,sha256=qDh7P7fnakDKgxTqjNLcQg8eE-6gHJaXAV0ONjhy_IU,12038
76
- pymammotion/mammotion/devices/mammotion.py,sha256=1SDIT4BazBoqqrsXmnNy5YjiP0vltVZ7IonZ7SlYQ8Q,15559
76
+ pymammotion/mammotion/devices/mammotion.py,sha256=BJtlukiRqi5GLO4cQ5QgMxQRKtMO0bBmpHWM_27hyYI,15601
77
77
  pymammotion/mammotion/devices/mammotion_bluetooth.py,sha256=mbZlbm3lAx5uLtHOR7rZ_hp4l9XPb2DnSzz4v8tdmKg,19352
78
- pymammotion/mammotion/devices/mammotion_cloud.py,sha256=aJ_SS2KgQsdD_qpSaHmGfhOyENPwatA6ae2Me41F8UI,15344
78
+ pymammotion/mammotion/devices/mammotion_cloud.py,sha256=USYgv3ENplzy0dWu0JttBy9Ldl06yUkuhxI2dW0GfTQ,16527
79
79
  pymammotion/mqtt/__init__.py,sha256=Ocs5e-HLJvTuDpVXyECEsWIvwsUaxzj7lZ9mSYutNDY,105
80
80
  pymammotion/mqtt/linkkit/__init__.py,sha256=ENgc3ynd2kd9gMQR3-kgmCu6Ed9Y6XCIzU0zFReUlkk,80
81
81
  pymammotion/mqtt/linkkit/h2client.py,sha256=w9Nvi_nY4CLD_fw-pHtYChwQf7e2TiAGeqkY_sF4cf0,19659
82
82
  pymammotion/mqtt/linkkit/linkkit.py,sha256=SGWny2_LKa8qg8RD0Bgd3a4S_fMqpYxJ7a9eFRvgcN0,132923
83
83
  pymammotion/mqtt/mammotion_future.py,sha256=_OWqKOlUGl2yT1xOsXFQYpGd-1zQ63OxqXgy7KRQgYc,710
84
- pymammotion/mqtt/mammotion_mqtt.py,sha256=p2efgd35ePi9bZxsGp2gtcS83BHiw7A1NR-utZx8Ijg,10183
84
+ pymammotion/mqtt/mammotion_mqtt.py,sha256=OtLyTxow8xJc1RK1tv3ZCUBleTLZ3QABKmVYIcynoxU,10208
85
85
  pymammotion/proto/__init__.py,sha256=dUl6HZ0NMRQUVOWe5Kf3fOJFVC5YJ98I9xEfd1R9Wdg,73487
86
86
  pymammotion/proto/basestation.proto,sha256=YiSsDmT0DY_ep6DHay13SbhxGMhentYt0BmJrVQrwLQ,1198
87
87
  pymammotion/proto/basestation_pb2.py,sha256=suenbpMz9JZCXdGJGdiPaapppRz9Cf4IDzAXUfdIG3w,3083
@@ -125,7 +125,7 @@ pymammotion/utility/movement.py,sha256=N75oAoAgFydqoaOedYIxGUHmuTCtPzAOtb-d_29tp
125
125
  pymammotion/utility/mur_mur_hash.py,sha256=xEfOZVbqRawJj66eLgtnZ85OauDR47oIPr29OHelzPI,4468
126
126
  pymammotion/utility/periodic.py,sha256=MbeSb9cfhxzYmdT_RiE0dZe3H9IfbQW_zSqhmSX2RUc,3321
127
127
  pymammotion/utility/rocker_util.py,sha256=6tX7sS87qoQC_tsxbx3NLL-HgS08wtzXiZkhDiz7uo0,7179
128
- pymammotion-0.5.11.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
129
- pymammotion-0.5.11.dist-info/METADATA,sha256=3Ui7RMa8Y5Ylkkar68fFQ5CNdDj29diGqPAs9QUrquU,3871
130
- pymammotion-0.5.11.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
131
- pymammotion-0.5.11.dist-info/RECORD,,
128
+ pymammotion-0.5.12.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
129
+ pymammotion-0.5.12.dist-info/METADATA,sha256=s4Bqz8X821VmOlMZ3XdeyHRwuZwg4qVsqy5zD2McPLo,3871
130
+ pymammotion-0.5.12.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
131
+ pymammotion-0.5.12.dist-info/RECORD,,