pymammotion 0.5.3__py3-none-any.whl → 0.5.5__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.
- pymammotion/aliyun/cloud_gateway.py +6 -6
- pymammotion/data/mqtt/properties.py +4 -4
- pymammotion/mammotion/devices/mammotion_cloud.py +3 -1
- pymammotion/mqtt/linkkit/linkkit.py +3 -0
- pymammotion/mqtt/mammotion_mqtt.py +3 -3
- {pymammotion-0.5.3.dist-info → pymammotion-0.5.5.dist-info}/METADATA +1 -1
- {pymammotion-0.5.3.dist-info → pymammotion-0.5.5.dist-info}/RECORD +9 -9
- {pymammotion-0.5.3.dist-info → pymammotion-0.5.5.dist-info}/LICENSE +0 -0
- {pymammotion-0.5.3.dist-info → pymammotion-0.5.5.dist-info}/WHEEL +0 -0
|
@@ -5,6 +5,7 @@ import hashlib
|
|
|
5
5
|
import hmac
|
|
6
6
|
import itertools
|
|
7
7
|
import json
|
|
8
|
+
from json.decoder import JSONDecodeError
|
|
8
9
|
from logging import getLogger
|
|
9
10
|
import random
|
|
10
11
|
import string
|
|
@@ -15,7 +16,6 @@ from aiohttp import ClientSession, ConnectionTimeoutError
|
|
|
15
16
|
from alibabacloud_iot_api_gateway.models import CommonParams, Config, IoTApiRequest
|
|
16
17
|
from alibabacloud_tea_util.client import Client as UtilClient
|
|
17
18
|
from alibabacloud_tea_util.models import RuntimeOptions
|
|
18
|
-
from orjson.orjson import JSONDecodeError
|
|
19
19
|
from Tea.exceptions import UnretryableException
|
|
20
20
|
|
|
21
21
|
from pymammotion.aliyun.client import Client
|
|
@@ -153,7 +153,7 @@ class CloudIOTGateway:
|
|
|
153
153
|
return json.loads(response_body_str) if response_body_str is not None else {}
|
|
154
154
|
except JSONDecodeError:
|
|
155
155
|
logger.error("Couldn't decode message %s", response_body_str)
|
|
156
|
-
return {
|
|
156
|
+
return {"code": 22000}
|
|
157
157
|
|
|
158
158
|
def sign(self, data):
|
|
159
159
|
"""Generate signature for the given data."""
|
|
@@ -691,21 +691,21 @@ class CloudIOTGateway:
|
|
|
691
691
|
return self._devices_by_account_response
|
|
692
692
|
|
|
693
693
|
async def send_cloud_command(self, iot_id: str, command: bytes) -> str:
|
|
694
|
-
|
|
695
694
|
"""Sends a cloud command to a specified IoT device.
|
|
696
|
-
|
|
695
|
+
|
|
697
696
|
This function checks if the IoT token is expired and attempts to refresh it if
|
|
698
697
|
possible. It then constructs a request using the provided command and sends it
|
|
699
698
|
to the IoT device via an asynchronous HTTP POST request. The function handles
|
|
700
699
|
various error codes and exceptions based on the response from the cloud
|
|
701
700
|
service.
|
|
702
|
-
|
|
701
|
+
|
|
703
702
|
Args:
|
|
704
703
|
iot_id (str): The unique identifier of the IoT device.
|
|
705
704
|
command (bytes): The command to be sent to the IoT device in binary format.
|
|
706
|
-
|
|
705
|
+
|
|
707
706
|
Returns:
|
|
708
707
|
str: A unique message ID for the sent command.
|
|
708
|
+
|
|
709
709
|
"""
|
|
710
710
|
if command is None:
|
|
711
711
|
raise Exception("Command is missing / None")
|
|
@@ -125,13 +125,13 @@ ItemTypes = Union[
|
|
|
125
125
|
|
|
126
126
|
|
|
127
127
|
@dataclass
|
|
128
|
-
class Item:
|
|
128
|
+
class Item(DataClassDictMixin):
|
|
129
129
|
time: int
|
|
130
130
|
value: int | float | str | dict[str, Any] | ItemTypes # Depending on the type of value
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
@dataclass
|
|
134
|
-
class Items:
|
|
134
|
+
class Items(DataClassDictMixin):
|
|
135
135
|
iotState: Item | None = None
|
|
136
136
|
extMod: Item | None = None
|
|
137
137
|
deviceVersionInfo: Item | None = None
|
|
@@ -163,12 +163,12 @@ class Items:
|
|
|
163
163
|
|
|
164
164
|
@dataclass
|
|
165
165
|
class Params(DataClassORJSONMixin):
|
|
166
|
-
deviceType: Literal["LawnMower"]
|
|
166
|
+
deviceType: Literal["LawnMower", "Tracker"]
|
|
167
167
|
checkFailedData: dict
|
|
168
168
|
groupIdList: list[str]
|
|
169
169
|
_tenantId: str
|
|
170
170
|
groupId: str
|
|
171
|
-
categoryKey: Literal["LawnMower"]
|
|
171
|
+
categoryKey: Literal["LawnMower", "Tracker"]
|
|
172
172
|
batchId: str
|
|
173
173
|
gmtCreate: int
|
|
174
174
|
productKey: str
|
|
@@ -61,7 +61,9 @@ class MammotionCloud:
|
|
|
61
61
|
return self._mqtt_client.is_connected
|
|
62
62
|
|
|
63
63
|
def disconnect(self) -> None:
|
|
64
|
-
|
|
64
|
+
"""Disconnect the MQTT client."""
|
|
65
|
+
if self.is_connected:
|
|
66
|
+
self._mqtt_client.disconnect()
|
|
65
67
|
|
|
66
68
|
def connect_async(self) -> None:
|
|
67
69
|
self._mqtt_client.connect_async()
|
|
@@ -1352,6 +1352,9 @@ UxeCp6
|
|
|
1352
1352
|
|
|
1353
1353
|
def connect_async(self):
|
|
1354
1354
|
self.__link_log.debug("connect_async")
|
|
1355
|
+
if self.__linkkit_state == LinkKit.LinkKitState.CONNECTED:
|
|
1356
|
+
self.__link_log.info("already connected, returning")
|
|
1357
|
+
return
|
|
1355
1358
|
if self.__linkkit_state not in (LinkKit.LinkKitState.INITIALIZED, LinkKit.LinkKitState.DISCONNECTED):
|
|
1356
1359
|
raise LinkKit.StateError("not in INITIALIZED or DISCONNECTED state")
|
|
1357
1360
|
self.__connect_async_req = True
|
|
@@ -175,18 +175,18 @@ class MammotionMQTT:
|
|
|
175
175
|
)
|
|
176
176
|
payload = json.loads(payload)
|
|
177
177
|
iot_id = payload.get("params", {}).get("iotId", "")
|
|
178
|
-
if iot_id != "" and self.on_message:
|
|
178
|
+
if iot_id != "" and self.on_message is not None:
|
|
179
179
|
future = asyncio.run_coroutine_threadsafe(self.on_message(topic, payload, iot_id), self.loop)
|
|
180
180
|
asyncio.wrap_future(future, loop=self.loop)
|
|
181
181
|
|
|
182
|
-
def _thing_on_connect(self,
|
|
182
|
+
def _thing_on_connect(self, userdata, flags, reason_code, properties) -> None:
|
|
183
183
|
"""Is called on thing connect."""
|
|
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)
|
|
187
187
|
asyncio.wrap_future(future, loop=self.loop)
|
|
188
188
|
|
|
189
|
-
logger.debug("on_connect, session_flag:%d, rc:%d",
|
|
189
|
+
logger.debug("on_connect, session_flag:%d, rc:%d", flags, reason_code)
|
|
190
190
|
|
|
191
191
|
# self._linkkit_client.subscribe_topic(f"/sys/{self._product_key}/{self._device_name}/#")
|
|
192
192
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
pymammotion/__init__.py,sha256=H-U94bNLp0LPC6hkRopVEUlUsZSR97n7WfKGPjK1GMg,1638
|
|
2
2
|
pymammotion/aliyun/__init__.py,sha256=T1lkX7TRYiL4nqYanG4l4MImV-SlavSbuooC-W-uUGw,29
|
|
3
3
|
pymammotion/aliyun/client.py,sha256=GCpAnLOVWW_W0c8UvdRpWVzZH5oLto8JZnb82stJi-8,9662
|
|
4
|
-
pymammotion/aliyun/cloud_gateway.py,sha256=
|
|
4
|
+
pymammotion/aliyun/cloud_gateway.py,sha256=tOnw4oh8CtAzVOgZc8yhnIIbM2Cv0rET5EyHD7JR4Po,29692
|
|
5
5
|
pymammotion/aliyun/model/aep_response.py,sha256=EY4uMTJ4F9rvbcXnAOc5YKi7q__9kIVgfDwfyr65Gk0,421
|
|
6
6
|
pymammotion/aliyun/model/connect_response.py,sha256=Yz-fEbDzgGPTo5Of2oAjmFkSv08T7ze80pQU4k-gKIU,824
|
|
7
7
|
pymammotion/aliyun/model/dev_by_account_response.py,sha256=P9yYy4Z2tLkJSqXA_5XGaCUliSSVa5ILl7VoMtL_tCA,977
|
|
@@ -43,7 +43,7 @@ pymammotion/data/model/report_info.py,sha256=3nXBFRfdKWnZj4YfBcrPwhBRpq58ICMQlrE
|
|
|
43
43
|
pymammotion/data/model/work.py,sha256=AfKMItFqnRtAlVHzKCfYY-BQy-WFDYZBzdj-9Yc03bo,655
|
|
44
44
|
pymammotion/data/mqtt/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
45
45
|
pymammotion/data/mqtt/event.py,sha256=C8TGRJs9wNxwg9FFmr9qcsweDnl5v5kcVcwiHxtYzJw,5384
|
|
46
|
-
pymammotion/data/mqtt/properties.py,sha256=
|
|
46
|
+
pymammotion/data/mqtt/properties.py,sha256=laud9rE-JqBHWKZ44Dov2yMkp3Ld8ghpBwlZ4_3g9uQ,4321
|
|
47
47
|
pymammotion/data/mqtt/status.py,sha256=SgdrpE1Uldb01hybO6hYhgU1Sp1eILghC0UhMZMHrdQ,1091
|
|
48
48
|
pymammotion/data/state_manager.py,sha256=Q0WTI-ehXH50bQEroXibzGK5MLRx5OThGZ86NNCPJjc,11508
|
|
49
49
|
pymammotion/event/__init__.py,sha256=mgATR6vPHACNQ-0zH5fi7NdzeTCDV1CZyaWPmtUusi8,115
|
|
@@ -74,13 +74,13 @@ pymammotion/mammotion/devices/__init__.py,sha256=f2qQFPgLGmV85W2hSlMUh5BYuht9o_A
|
|
|
74
74
|
pymammotion/mammotion/devices/base.py,sha256=qDh7P7fnakDKgxTqjNLcQg8eE-6gHJaXAV0ONjhy_IU,12038
|
|
75
75
|
pymammotion/mammotion/devices/mammotion.py,sha256=dvFNLJvYS_Fu3JFkrJE3ljhECzewNJYMIPGuTAeFYHY,15170
|
|
76
76
|
pymammotion/mammotion/devices/mammotion_bluetooth.py,sha256=dSDw8xLUfAU2c9vKX65w87Rm2E78284WjJ72CKniPt4,19349
|
|
77
|
-
pymammotion/mammotion/devices/mammotion_cloud.py,sha256=
|
|
77
|
+
pymammotion/mammotion/devices/mammotion_cloud.py,sha256=Pd4aOIhcjVZznJfa0ANYTdG3QWO47maM2eB_qE8SR4U,14904
|
|
78
78
|
pymammotion/mqtt/__init__.py,sha256=Ocs5e-HLJvTuDpVXyECEsWIvwsUaxzj7lZ9mSYutNDY,105
|
|
79
79
|
pymammotion/mqtt/linkkit/__init__.py,sha256=ENgc3ynd2kd9gMQR3-kgmCu6Ed9Y6XCIzU0zFReUlkk,80
|
|
80
80
|
pymammotion/mqtt/linkkit/h2client.py,sha256=w9Nvi_nY4CLD_fw-pHtYChwQf7e2TiAGeqkY_sF4cf0,19659
|
|
81
|
-
pymammotion/mqtt/linkkit/linkkit.py,sha256=
|
|
81
|
+
pymammotion/mqtt/linkkit/linkkit.py,sha256=SGWny2_LKa8qg8RD0Bgd3a4S_fMqpYxJ7a9eFRvgcN0,132923
|
|
82
82
|
pymammotion/mqtt/mammotion_future.py,sha256=_OWqKOlUGl2yT1xOsXFQYpGd-1zQ63OxqXgy7KRQgYc,710
|
|
83
|
-
pymammotion/mqtt/mammotion_mqtt.py,sha256=
|
|
83
|
+
pymammotion/mqtt/mammotion_mqtt.py,sha256=4jNNV5tx6CCryjLSmAQA6u19bhRSuVkZem32JCpOakE,10198
|
|
84
84
|
pymammotion/proto/__init__.py,sha256=vUF-eieR8e4VfduqaQ3KfeCRhsMD56NTX2Kk6sS38IE,73466
|
|
85
85
|
pymammotion/proto/basestation.proto,sha256=YiSsDmT0DY_ep6DHay13SbhxGMhentYt0BmJrVQrwLQ,1198
|
|
86
86
|
pymammotion/proto/basestation_pb2.py,sha256=suenbpMz9JZCXdGJGdiPaapppRz9Cf4IDzAXUfdIG3w,3083
|
|
@@ -124,7 +124,7 @@ pymammotion/utility/movement.py,sha256=N75oAoAgFydqoaOedYIxGUHmuTCtPzAOtb-d_29tp
|
|
|
124
124
|
pymammotion/utility/mur_mur_hash.py,sha256=xEfOZVbqRawJj66eLgtnZ85OauDR47oIPr29OHelzPI,4468
|
|
125
125
|
pymammotion/utility/periodic.py,sha256=MbeSb9cfhxzYmdT_RiE0dZe3H9IfbQW_zSqhmSX2RUc,3321
|
|
126
126
|
pymammotion/utility/rocker_util.py,sha256=6tX7sS87qoQC_tsxbx3NLL-HgS08wtzXiZkhDiz7uo0,7179
|
|
127
|
-
pymammotion-0.5.
|
|
128
|
-
pymammotion-0.5.
|
|
129
|
-
pymammotion-0.5.
|
|
130
|
-
pymammotion-0.5.
|
|
127
|
+
pymammotion-0.5.5.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
128
|
+
pymammotion-0.5.5.dist-info/METADATA,sha256=OoAgAEjBHXz8XRebg4rgZAUHx4nPIx4mXvUyLXwdHzI,3870
|
|
129
|
+
pymammotion-0.5.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
130
|
+
pymammotion-0.5.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|