From e428d8c63cdcd752748142c78f77c6785faea217 Mon Sep 17 00:00:00 2001 From: Michael Arthur Date: Wed, 30 Oct 2024 20:45:37 +1300 Subject: [PATCH] add extra translations --- pymammotion/aliyun/cloud_gateway.py | 2 +- pymammotion/data/model/device.py | 2 ++ pymammotion/http/http.py | 3 ++- pymammotion/http/model/http.py | 20 +++++++++++++++++++- pyproject.toml | 6 +++--- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/pymammotion/aliyun/cloud_gateway.py b/pymammotion/aliyun/cloud_gateway.py index 1a0c248..4c5d7d9 100644 --- a/pymammotion/aliyun/cloud_gateway.py +++ b/pymammotion/aliyun/cloud_gateway.py @@ -700,7 +700,7 @@ def send_cloud_command(self, iot_id: str, command: bytes) -> str: def devices_by_account_response(self): return self._devices_by_account_response - def set_http(self, mammotion_http) -> None: + def set_http(self, mammotion_http: MammotionHTTP) -> None: self.mammotion_http = mammotion_http @property diff --git a/pymammotion/data/model/device.py b/pymammotion/data/model/device.py index bbc0a86..8cd0da5 100644 --- a/pymammotion/data/model/device.py +++ b/pymammotion/data/model/device.py @@ -12,6 +12,7 @@ from pymammotion.data.model.location import Location from pymammotion.data.model.report_info import ReportData from pymammotion.data.mqtt.properties import ThingPropertiesMessage +from pymammotion.http.model.http import ErrorInfo from pymammotion.proto.dev_net import DevNet from pymammotion.proto.luba_msg import LubaMsg from pymammotion.proto.luba_mul import SocMul @@ -45,6 +46,7 @@ class MowingDevice(DataClassORJSONMixin): err_code_list_time: Optional[list] = field(default_factory=list) limits: DeviceLimits = field(default_factory=DeviceLimits) device: Optional[LubaMsg] = field(default_factory=LubaMsg) + error_codes: dict[str, ErrorInfo] = field(default_factory=dict) @classmethod def from_raw(cls, raw: dict) -> "MowingDevice": diff --git a/pymammotion/http/http.py b/pymammotion/http/http.py index 3b74a11..8d61be5 100644 --- a/pymammotion/http/http.py +++ b/pymammotion/http/http.py @@ -18,6 +18,7 @@ def __init__(self, response: Response) -> None: self._headers = dict() self.login_info = LoginResponseData.from_dict(response.data) if response.data else None self._headers["Authorization"] = f"Bearer {self.login_info.access_token}" if response.data else None + self.response = response self.msg = response.msg self.code = response.code @@ -74,7 +75,7 @@ async def login(cls, session: ClientSession, username: str, password: str) -> Re ), ) as resp: data = await resp.json() - response = Response.from_dict(data) + response = Response[LoginResponseData].from_dict(data) # TODO catch errors from mismatch user / password elsewhere # Assuming the data format matches the expected structure return response diff --git a/pymammotion/http/model/http.py b/pymammotion/http/model/http.py index 6d8b2d0..a972b8c 100644 --- a/pymammotion/http/model/http.py +++ b/pymammotion/http/model/http.py @@ -9,7 +9,7 @@ @dataclass -class ErrorInfo: +class ErrorInfo(DataClassDictMixin): code: str platform: str module: str @@ -44,6 +44,24 @@ class ErrorInfo: sl_solution: str pt_implication: str pt_solution: str + hu_implication: str + hu_solution: str + hr_implication: str + hr_solution: str + no_implication: str + no_solution: str + fi_implication: str + fi_solution: str + ro_implication: str + ro_solution: str + bg_implication: str + bg_solution: str + et_implication: str + et_solution: str + lv_implication: str + lv_solution: str + lt_implication: str + lt_solution: str @dataclass diff --git a/pyproject.toml b/pyproject.toml index d1a4424..0678b5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [project] name = "pymammotion" -version = "0.2.95" +version = "0.2.97" [tool.poetry] name = "pymammotion" -version = "0.2.95" +version = "0.2.97" license = "GNU-3.0" description = "" readme = "README.md" @@ -61,7 +61,7 @@ mypy = "^1.11.2" autotyping = "^24.3.0" [tool.bumpver] -current_version = "0.2.95" +current_version = "0.2.97" version_pattern = "MAJOR.MINOR.PATCH" commit_message = "Bump version {old_version} -> {new_version}" commit = true