pymammotion 0.2.15__py3-none-any.whl → 0.2.17__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 +10 -3
- pymammotion/data/state_manager.py +4 -0
- pymammotion/mammotion/devices/mammotion.py +5 -2
- {pymammotion-0.2.15.dist-info → pymammotion-0.2.17.dist-info}/METADATA +1 -1
- {pymammotion-0.2.15.dist-info → pymammotion-0.2.17.dist-info}/RECORD +7 -7
- {pymammotion-0.2.15.dist-info → pymammotion-0.2.17.dist-info}/LICENSE +0 -0
- {pymammotion-0.2.15.dist-info → pymammotion-0.2.17.dist-info}/WHEEL +0 -0
|
@@ -55,6 +55,8 @@ class AuthRefreshException(Exception):
|
|
|
55
55
|
class DeviceOfflineException(Exception):
|
|
56
56
|
"""Raise exception when device is offline."""
|
|
57
57
|
|
|
58
|
+
class LoginException(Exception):
|
|
59
|
+
"""Raise exception when library cannot log in."""
|
|
58
60
|
|
|
59
61
|
class CloudIOTGateway:
|
|
60
62
|
"""Class for interacting with Aliyun Cloud IoT Gateway."""
|
|
@@ -303,8 +305,11 @@ class CloudIOTGateway:
|
|
|
303
305
|
params={"request": json.dumps(_bodyParam, separators=(",", ":"))},
|
|
304
306
|
) as resp:
|
|
305
307
|
data = await resp.json()
|
|
306
|
-
self._connect_response = ConnectResponse.from_dict(data)
|
|
307
308
|
logger.debug(data)
|
|
309
|
+
if resp.status == 200:
|
|
310
|
+
self._connect_response = ConnectResponse.from_dict(data)
|
|
311
|
+
return self._connect_response
|
|
312
|
+
raise LoginException(data)
|
|
308
313
|
|
|
309
314
|
async def login_by_oauth(self, country_code: str, auth_code: str):
|
|
310
315
|
"""Login by OAuth."""
|
|
@@ -372,8 +377,10 @@ class CloudIOTGateway:
|
|
|
372
377
|
) as resp:
|
|
373
378
|
data = await resp.json()
|
|
374
379
|
logger.debug(data)
|
|
375
|
-
|
|
376
|
-
|
|
380
|
+
if resp.status == 200:
|
|
381
|
+
self._login_by_oauth_response = LoginByOAuthResponse.from_dict(data)
|
|
382
|
+
return self._login_by_oauth_response
|
|
383
|
+
raise LoginException(data)
|
|
377
384
|
|
|
378
385
|
def session_by_auth_code(self):
|
|
379
386
|
"""Create a session by auth code."""
|
|
@@ -17,6 +17,7 @@ class StateManager:
|
|
|
17
17
|
self._device = device
|
|
18
18
|
self.gethash_ack_callback: Optional[Callable[[NavGetHashListAck],Awaitable[None]]] = None
|
|
19
19
|
self.get_commondata_ack_callback: Optional[Callable[[NavGetCommDataAck],Awaitable[None]]] = None
|
|
20
|
+
self.on_notification_callback: Optional[Callable[[],Awaitable[None]]] = None
|
|
20
21
|
|
|
21
22
|
def get_device(self) -> MowingDevice:
|
|
22
23
|
"""Get device."""
|
|
@@ -44,6 +45,9 @@ class StateManager:
|
|
|
44
45
|
case "ota":
|
|
45
46
|
self._update_ota_data(message)
|
|
46
47
|
|
|
48
|
+
if self.on_notification_callback:
|
|
49
|
+
await self.on_notification_callback()
|
|
50
|
+
|
|
47
51
|
async def _update_nav_data(self, message):
|
|
48
52
|
"""Update nav data."""
|
|
49
53
|
nav_msg = betterproto.which_one_of(message.nav, "SubNavMsg")
|
|
@@ -346,6 +346,9 @@ class MammotionBaseDevice:
|
|
|
346
346
|
self._notify_future: asyncio.Future[bytes] | None = None
|
|
347
347
|
self._cloud_device = cloud_device
|
|
348
348
|
|
|
349
|
+
def set_notifiction_callback(self, func: Callable[[],Awaitable[None]]):
|
|
350
|
+
self._state_manager.on_notification_callback = func
|
|
351
|
+
|
|
349
352
|
async def datahash_response(self, hash_ack: NavGetHashListAck):
|
|
350
353
|
"""Handle datahash responses."""
|
|
351
354
|
result_hash = 0
|
|
@@ -1150,7 +1153,7 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
|
|
|
1150
1153
|
if isinstance(params, str):
|
|
1151
1154
|
_LOGGER.debug("config event %s", str)
|
|
1152
1155
|
return
|
|
1153
|
-
if params.identifier == "device_protobuf_msg_event" and
|
|
1156
|
+
if params.identifier == "device_protobuf_msg_event" and event.method == "thing.events":
|
|
1154
1157
|
_LOGGER.debug("Protobuf event")
|
|
1155
1158
|
binary_data = base64.b64decode(params.value.get("content", ""))
|
|
1156
1159
|
self._update_raw_data(cast(bytes, binary_data))
|
|
@@ -1171,7 +1174,7 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
|
|
|
1171
1174
|
if not fut.fut.cancelled():
|
|
1172
1175
|
fut.resolve(cast(bytes, binary_data))
|
|
1173
1176
|
await self._state_manager.notification(new_msg)
|
|
1174
|
-
if
|
|
1177
|
+
if event.method == "thing.properties":
|
|
1175
1178
|
_LOGGER.debug(event)
|
|
1176
1179
|
|
|
1177
1180
|
async def _handle_mqtt_message(self, topic: str, payload: dict) -> None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
pymammotion/__init__.py,sha256=kmnjdt3AEMejIz5JK7h1tTJj5ZriAgKwZBa3ScA4-Ao,1516
|
|
2
2
|
pymammotion/aliyun/__init__.py,sha256=T1lkX7TRYiL4nqYanG4l4MImV-SlavSbuooC-W-uUGw,29
|
|
3
|
-
pymammotion/aliyun/cloud_gateway.py,sha256=
|
|
3
|
+
pymammotion/aliyun/cloud_gateway.py,sha256=RzlfDGzhaIZcu6o8gzGbSJGiQ3al73jTp3dNb6mqZrk,22221
|
|
4
4
|
pymammotion/aliyun/cloud_service.py,sha256=YWcKuKK6iRWy5mTnBYgHxcCusiRGGzQt3spSf7dGDss,2183
|
|
5
5
|
pymammotion/aliyun/dataclass/aep_response.py,sha256=8f6GIP58ve8gd6AL3HBoXxsy0n2q4ygWvjELGnoOnVc,452
|
|
6
6
|
pymammotion/aliyun/dataclass/connect_response.py,sha256=Yz-fEbDzgGPTo5Of2oAjmFkSv08T7ze80pQU4k-gKIU,824
|
|
@@ -38,7 +38,7 @@ pymammotion/data/mqtt/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdr
|
|
|
38
38
|
pymammotion/data/mqtt/event.py,sha256=j2bo__p7ROPPeiBH-74YyOAOMV7tlYYfl30nnZ81XgQ,3567
|
|
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=
|
|
41
|
+
pymammotion/data/state_manager.py,sha256=jkedK5qAVDTGqIzlPNCmPpE-Pc1V4e-ZHW6Ds1ihJ50,3004
|
|
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=EWV20MMzQuhbLlNlXbsyZKSEpeM7x1CQL7saU4Pn0-g,6165
|
|
60
60
|
pymammotion/mammotion/devices/__init__.py,sha256=T72jt0ejtMjo1rPmn_FeMF3pmp0LLeRRpc9WcDKEYYY,126
|
|
61
|
-
pymammotion/mammotion/devices/mammotion.py,sha256=
|
|
61
|
+
pymammotion/mammotion/devices/mammotion.py,sha256=6icsKV066SX-4QPVD1IF3LXhJf_fGv8CtDDuDyOF29U,47997
|
|
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=7V0JW2N9dshUJAGlg6d6Y5LKWYoXvlQd0o-9l6idPNg,8071
|
|
@@ -111,7 +111,7 @@ pymammotion/utility/device_type.py,sha256=KYawu2glZMVlPmxRbA4kVFujXz3miHp3rJiOWR
|
|
|
111
111
|
pymammotion/utility/map.py,sha256=aoi-Luzuph02hKynTofMoq3mnPstanx75MDAVv49CuY,2211
|
|
112
112
|
pymammotion/utility/periodic.py,sha256=9wJMfwXPlx6Mbp3Fws7LLTI34ZDKphH1bva_Ggyk32g,3281
|
|
113
113
|
pymammotion/utility/rocker_util.py,sha256=syPL0QN4zMzHiTIkUKS7RXBBptjdbkfNlPddwUD5V3A,7171
|
|
114
|
-
pymammotion-0.2.
|
|
115
|
-
pymammotion-0.2.
|
|
116
|
-
pymammotion-0.2.
|
|
117
|
-
pymammotion-0.2.
|
|
114
|
+
pymammotion-0.2.17.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
115
|
+
pymammotion-0.2.17.dist-info/METADATA,sha256=Pu-S4POuRuUcvi7fOiAROoc8QwzxZmIVwoV-g8EO16M,3969
|
|
116
|
+
pymammotion-0.2.17.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
117
|
+
pymammotion-0.2.17.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|