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

@@ -52,6 +52,9 @@ class SetupException(Exception):
52
52
  class AuthRefreshException(Exception):
53
53
  """Raise exception when library cannot refresh token."""
54
54
 
55
+ class DeviceOfflineException(Exception):
56
+ """Raise exception when device is offline."""
57
+
55
58
 
56
59
  class CloudIOTGateway:
57
60
  """Class for interacting with Aliyun Cloud IoT Gateway."""
@@ -416,10 +419,15 @@ class CloudIOTGateway:
416
419
  # Load the JSON string into a dictionary
417
420
  response_body_dict = json.loads(response_body_str)
418
421
 
419
- if int(response_body_dict.get("code")) != 200:
420
- raise Exception("Error in creating session: " + response_body_dict["msg"])
422
+ session_by_auth = SessionByAuthCodeResponse.from_dict(response_body_dict)
421
423
 
422
- self._session_by_authcode_response = SessionByAuthCodeResponse.from_dict(response_body_dict)
424
+ if int(session_by_auth.code) != 200:
425
+ raise Exception("Error in creating session: " + response_body_str)
426
+
427
+ if session_by_auth.data.identityId is None:
428
+ raise Exception("Error in creating session: " + response_body_str)
429
+
430
+ self._session_by_authcode_response = session_by_auth
423
431
  self._iot_token_issued_at = int(time.time())
424
432
 
425
433
  return response.body
@@ -472,17 +480,13 @@ class CloudIOTGateway:
472
480
  if int(response_body_dict.get("code")) != 200:
473
481
  raise Exception("Error check or refresh token: " + response_body_dict.get('msg', ''))
474
482
 
475
- identityId = response_body_dict.get('data', {}).get('identityId', None)
476
- refreshTokenExpire = response_body_dict.get('data', {}).get('refreshTokenExpire', None)
477
- iotToken = response_body_dict.get('data', {}).get('iotToken', None)
478
- iotTokenExpire = response_body_dict.get('data', {}).get('iotTokenExpire', None)
479
- refreshToken = response_body_dict.get('data', {}).get('refreshToken', None)
480
-
483
+ session = SessionByAuthCodeResponse.from_dict(response_body_dict)
484
+ session_data = session.data
481
485
 
482
- if (identityId is None or refreshTokenExpire is None or iotToken is None or iotTokenExpire is None or refreshToken is None):
486
+ if session_data.identityId is None or session_data.refreshTokenExpire is None or session_data.iotToken is None or session_data.iotTokenExpire is None or session_data.refreshToken is None:
483
487
  raise Exception("Error check or refresh token: Parameters not correct")
484
488
 
485
- self._session_by_authcode_response = SessionByAuthCodeResponse.from_dict(response_body_dict)
489
+ self._session_by_authcode_response = session
486
490
  self._iot_token_issued_at = int(time.time())
487
491
 
488
492
 
@@ -591,6 +595,7 @@ class CloudIOTGateway:
591
595
  if response_body_dict.get("code") == 29003:
592
596
  raise SetupException(response_body_dict.get("code"))
593
597
  if response_body_dict.get("code") == 6205:
598
+ raise DeviceOfflineException(response_body_dict.get("code"))
594
599
  """Device is offline."""
595
600
 
596
601
  return message_id
@@ -9,7 +9,6 @@ from mashumaro.mixins.orjson import DataClassORJSONMixin
9
9
  class Device(DataClassORJSONMixin):
10
10
  gmtModified: int
11
11
  netType: str
12
- nickName: str
13
12
  categoryKey: str
14
13
  productKey: str
15
14
  nodeType: str
@@ -24,10 +23,13 @@ class Device(DataClassORJSONMixin):
24
23
  identityId: str
25
24
  thingType: str
26
25
  status: int
26
+ nickName: Optional[str] = None
27
+ description: Optional[str] = None
27
28
  productImage: Optional[str] = None
28
29
  categoryImage: Optional[str] = None
29
30
  productModel: Optional[str] = None
30
31
 
32
+
31
33
  class Config(BaseConfig):
32
34
  omit_default = True
33
35
 
@@ -29,7 +29,7 @@ from bleak_retry_connector import (
29
29
  establish_connection,
30
30
  )
31
31
 
32
- from pymammotion.aliyun.cloud_gateway import CloudIOTGateway
32
+ from pymammotion.aliyun.cloud_gateway import CloudIOTGateway, DeviceOfflineException, SetupException
33
33
  from pymammotion.aliyun.dataclass.dev_by_account_response import Device
34
34
  from pymammotion.bluetooth import BleMessage
35
35
  from pymammotion.const import MAMMOTION_DOMAIN
@@ -1070,9 +1070,23 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
1070
1070
  """Send command to device and read response."""
1071
1071
  try:
1072
1072
  return await self._execute_command_locked(key, command)
1073
+ except DeviceOfflineException as ex:
1074
+ _LOGGER.debug(
1075
+ "%s: device offline in _send_command_locked: %s",
1076
+ self.device.nickName,
1077
+ ex,
1078
+ )
1079
+ except SetupException as ex:
1080
+ session = self._mqtt_client.get_cloud_client().get_session_by_authcode_response()
1081
+ _LOGGER.debug(
1082
+ "%s: session identityId mssing in _send_command_locked: %s",
1083
+ self.device.nickName,
1084
+ session,
1085
+ )
1086
+ if session.data.identityId is None:
1087
+ await self._mqtt_client.get_cloud_client().session_by_auth_code()
1088
+
1073
1089
  except Exception as ex:
1074
- # Disconnect so we can reset state and try again
1075
- await asyncio.sleep(DBUS_ERROR_BACKOFF_TIME)
1076
1090
  _LOGGER.debug(
1077
1091
  "%s: error in _send_command_locked: %s",
1078
1092
  self.device.nickName,
@@ -1085,6 +1099,7 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
1085
1099
  assert self._mqtt_client is not None
1086
1100
  self._key = key
1087
1101
  _LOGGER.debug("%s: Sending command: %s", self.device.nickName, key)
1102
+
1088
1103
  await self.loop.run_in_executor(None, self._mqtt_client.get_cloud_client().send_cloud_command, self.iot_id, command)
1089
1104
  future = MammotionFuture()
1090
1105
  self._waiting_queue.append(future)
@@ -1163,3 +1178,4 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
1163
1178
  self._mqtt_client.disconnect()
1164
1179
 
1165
1180
 
1181
+
@@ -70,7 +70,7 @@ class MammotionMQTT:
70
70
  username=self._mqtt_username,
71
71
  )
72
72
 
73
- self._linkkit_client.enable_logger(level=logging.DEBUG)
73
+ self._linkkit_client.enable_logger(level=logging.ERROR)
74
74
  self._linkkit_client.on_connect = self._thing_on_connect
75
75
  self._linkkit_client.on_disconnect = self._on_disconnect
76
76
  self._linkkit_client.on_thing_enable = self._thing_on_thing_enable
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymammotion
3
- Version: 0.2.11
3
+ Version: 0.2.13
4
4
  Summary:
5
5
  License: GNU-3.0
6
6
  Author: Michael Arthur
@@ -1,10 +1,10 @@
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=IqmxgjDIgRoZvJvQnwYGOSl4XaCV4MoMKTlfhC9-6Ys,21830
3
+ pymammotion/aliyun/cloud_gateway.py,sha256=FCQzc24PHAhdO0rovTNv1yax4fG60CsLK24CxJikP5Y,21856
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
7
- pymammotion/aliyun/dataclass/dev_by_account_response.py,sha256=DtGeMCzoiFrfSniHoL6db9xcheQgmcTvGySkGBjKdKE,977
7
+ pymammotion/aliyun/dataclass/dev_by_account_response.py,sha256=YV7I1Gd3RyHXi369AzEKa604VOV5bmtjD1mVElg9wOw,1033
8
8
  pymammotion/aliyun/dataclass/login_by_oauth_response.py,sha256=6TQYAMyQ1jf_trsnTST007qlNXve3BqsvpV0Dwp7CFA,1245
9
9
  pymammotion/aliyun/dataclass/regions_response.py,sha256=CVPpdFhDD6_emWHyLRzOdp2j3HLPtP8tlNyzGnr8AcI,690
10
10
  pymammotion/aliyun/dataclass/session_by_authcode_response.py,sha256=_5vsyIxocoecEqygPTmhOQnzjwaK845ssIqbTeaLcmk,406
@@ -58,10 +58,10 @@ 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=oYInls6l_DjGU0VwXersSpqJtXDrH6yObcQb3V_f8oc,47043
61
+ pymammotion/mammotion/devices/mammotion.py,sha256=2aTMvODVOQnhSI1Sh5JcioApuQfGqjFTTWnAK33kXM4,47620
62
62
  pymammotion/mqtt/__init__.py,sha256=Ocs5e-HLJvTuDpVXyECEsWIvwsUaxzj7lZ9mSYutNDY,105
63
63
  pymammotion/mqtt/mammotion_future.py,sha256=WKnHqeHiS2Ut-SaDBNOxqh1jDLeTiyLTsJ7PNUexrjk,687
64
- pymammotion/mqtt/mammotion_mqtt.py,sha256=K9TokiQWYJloWu5Hom00g7cfGhWHDSWqbcU9AqW4C9Q,8071
64
+ pymammotion/mqtt/mammotion_mqtt.py,sha256=7V0JW2N9dshUJAGlg6d6Y5LKWYoXvlQd0o-9l6idPNg,8071
65
65
  pymammotion/proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
66
66
  pymammotion/proto/basestation.proto,sha256=_x5gAz3FkZXS1jtq4GgZgaDCuRU-UV-7HTFdsfQ3zbo,1034
67
67
  pymammotion/proto/basestation.py,sha256=js64_N2xQYRxWPRdVNEapO0qe7vBlfYnjW5sE8hi7hw,2026
@@ -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.11.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
115
- pymammotion-0.2.11.dist-info/METADATA,sha256=23mX4pxztKsCqetgHuL7QpSQJed402756WhSItalTAQ,3969
116
- pymammotion-0.2.11.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
117
- pymammotion-0.2.11.dist-info/RECORD,,
114
+ pymammotion-0.2.13.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
115
+ pymammotion-0.2.13.dist-info/METADATA,sha256=M0g1tC2ywqh4-m4zpy9ezjbhBNj-X9ffbz-GPPKJHUM,3969
116
+ pymammotion-0.2.13.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
117
+ pymammotion-0.2.13.dist-info/RECORD,,