pymammotion 0.4.0a5__py3-none-any.whl → 0.4.0a6__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.
@@ -57,6 +57,8 @@ class AuthRefreshException(Exception):
57
57
  class DeviceOfflineException(Exception):
58
58
  """Raise exception when device is offline."""
59
59
 
60
+ class GatewayTimeoutException(Exception):
61
+ """Raise exception when the gateway times out."""
60
62
 
61
63
  class LoginException(Exception):
62
64
  """Raise exception when library cannot log in."""
@@ -657,7 +659,7 @@ class CloudIOTGateway:
657
659
  iot_token=self._session_by_authcode_response.data.iotToken,
658
660
  )
659
661
 
660
- # TODO move to using InvokeThingServiceRequest()
662
+ # TODO move to using InvokeThingServiceRequest()
661
663
 
662
664
  message_id = str(uuid.uuid4())
663
665
 
@@ -689,6 +691,10 @@ class CloudIOTGateway:
689
691
  str(response_body_dict.get("code")),
690
692
  str(response_body_dict.get("message")),
691
693
  )
694
+ if response_body_dict.get("code") == 20056:
695
+ logger.debug("Gateway timeout.")
696
+ raise GatewayTimeoutException(response_body_dict.get("code"))
697
+
692
698
  if response_body_dict.get("code") == 29003:
693
699
  logger.debug(self._session_by_authcode_response.data.identityId)
694
700
  self.sign_out()
@@ -1,22 +1,22 @@
1
1
  """MowingDevice class to wrap around the betterproto dataclasses."""
2
2
 
3
3
  from dataclasses import dataclass, field
4
- from typing import Optional
5
4
 
6
5
  import betterproto
7
6
  from mashumaro.mixins.orjson import DataClassORJSONMixin
8
7
 
9
8
  from pymammotion.data.model import HashList, RapidState
10
- from pymammotion.data.model.device_info import MowerInfo, DeviceFirmwares
9
+ from pymammotion.data.model.device_info import DeviceFirmwares, MowerInfo
11
10
  from pymammotion.data.model.location import Location
12
11
  from pymammotion.data.model.report_info import ReportData
13
12
  from pymammotion.data.mqtt.properties import ThingPropertiesMessage
14
13
  from pymammotion.http.model.http import ErrorInfo
15
14
  from pymammotion.proto.mctrl_sys import (
15
+ DeviceFwInfo,
16
16
  MowToAppInfoT,
17
17
  ReportInfoData,
18
18
  SystemRapidStateTunnelMsg,
19
- SystemUpdateBufMsg, DeviceFwInfo,
19
+ SystemUpdateBufMsg,
20
20
  )
21
21
  from pymammotion.utility.constant import WorkMode
22
22
  from pymammotion.utility.conversions import parse_double
@@ -35,7 +35,7 @@ class MowingDevice(DataClassORJSONMixin):
35
35
  report_data: ReportData = field(default_factory=ReportData)
36
36
  device_firmwares: DeviceFirmwares = field(default_factory=DeviceFirmwares)
37
37
  err_code_list: list = field(default_factory=list)
38
- err_code_list_time: Optional[list] = field(default_factory=list)
38
+ err_code_list_time: list | None = field(default_factory=list)
39
39
  error_codes: dict[str, ErrorInfo] = field(default_factory=dict)
40
40
 
41
41
  def buffer(self, buffer_list: SystemUpdateBufMsg) -> None:
@@ -24,6 +24,7 @@ class MowerInfo(DataClassORJSONMixin):
24
24
  product_key: str = ""
25
25
  model_id: str = ""
26
26
 
27
+
27
28
  @dataclass
28
29
  class DeviceFirmwares(DataClassORJSONMixin):
29
30
  device_version: str = ""
@@ -34,4 +35,4 @@ class DeviceFirmwares(DataClassORJSONMixin):
34
35
  right_motor_driver: str = ""
35
36
  rtk_rover_station: str = ""
36
37
  rtk_version: str = ""
37
- version: str = ""
38
+ version: str = ""
@@ -1,8 +1,9 @@
1
1
  """Manage state from notifications into MowingDevice."""
2
2
 
3
3
  import logging
4
+ from collections.abc import Awaitable, Callable
4
5
  from datetime import datetime
5
- from typing import Any, Awaitable, Callable, Optional
6
+ from typing import Any
6
7
 
7
8
  import betterproto
8
9
 
@@ -10,7 +11,7 @@ from pymammotion.data.model.device import MowingDevice
10
11
  from pymammotion.data.model.device_info import SideLight
11
12
  from pymammotion.data.model.hash_list import AreaHashNameList
12
13
  from pymammotion.data.mqtt.properties import ThingPropertiesMessage
13
- from pymammotion.proto.dev_net import WifiIotStatusReport, DrvDevInfoResp
14
+ from pymammotion.proto.dev_net import DrvDevInfoResp, WifiIotStatusReport
14
15
  from pymammotion.proto.luba_msg import LubaMsg
15
16
  from pymammotion.proto.mctrl_nav import AppGetAllAreaHashName, NavGetCommDataAck, NavGetHashListAck, SvgMessageAckT
16
17
  from pymammotion.proto.mctrl_sys import DeviceProductTypeInfoT, TimeCtrlLight
@@ -26,12 +27,10 @@ class StateManager:
26
27
 
27
28
  def __init__(self, device: MowingDevice) -> None:
28
29
  self._device = device
29
- self.gethash_ack_callback: Optional[Callable[[NavGetHashListAck], Awaitable[None]]] = None
30
- self.get_commondata_ack_callback: Optional[Callable[[NavGetCommDataAck | SvgMessageAckT], Awaitable[None]]] = (
31
- None
32
- )
33
- self.on_notification_callback: Optional[Callable[[tuple[str, Any | None]], Awaitable[None]]] = None
34
- self.queue_command_callback: Optional[Callable[[str, dict[str, Any]], Awaitable[bytes]]] = None
30
+ self.gethash_ack_callback: Callable[[NavGetHashListAck], Awaitable[None]] | None = None
31
+ self.get_commondata_ack_callback: Callable[[NavGetCommDataAck | SvgMessageAckT], Awaitable[None]] | None = None
32
+ self.on_notification_callback: Callable[[tuple[str, Any | None]], Awaitable[None]] | None = None
33
+ self.queue_command_callback: Callable[[str, dict[str, Any]], Awaitable[bytes]] | None = None
35
34
  self.last_updated_at = datetime.now()
36
35
 
37
36
  def get_device(self) -> MowingDevice:
@@ -124,7 +123,7 @@ class StateManager:
124
123
  case "toapp_devinfo_resp":
125
124
  toapp_devinfo_resp: DrvDevInfoResp = net_msg[1]
126
125
  for resp in toapp_devinfo_resp.resp_ids:
127
- if resp.res is "DRV_RESULT_SUC":
126
+ if resp.res == "DRV_RESULT_SUC":
128
127
  self._device.mower_state.swversion = resp.info
129
128
  self._device.device_firmwares.device_version = resp.info
130
129
 
@@ -2,4 +2,4 @@
2
2
 
3
3
  from .linkkit import LinkKit
4
4
 
5
- __all__ = ["LinkKit"]
5
+ __all__ = ["LinkKit"]