From 936f3eca51e72d4dc747161a82bcc75cf84fdd2e Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 9 May 2024 09:27:51 -0400 Subject: [PATCH 1/2] feat: improve some typing --- roborock/api.py | 4 ++-- roborock/version_1_apis/roborock_mqtt_client_v1.py | 2 +- roborock/version_a01_apis/roborock_client_a01.py | 4 +++- roborock/version_a01_apis/roborock_mqtt_client_a01.py | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/roborock/api.py b/roborock/api.py index d6da5eb..9b0c86f 100644 --- a/roborock/api.py +++ b/roborock/api.py @@ -49,10 +49,10 @@ def __init__(self, endpoint: str, device_info: DeviceData, queue_timeout: int = def __del__(self) -> None: self.release() - def release(self): + def release(self) -> None: self.sync_disconnect() - async def async_release(self): + async def async_release(self) -> None: await self.async_disconnect() @property diff --git a/roborock/version_1_apis/roborock_mqtt_client_v1.py b/roborock/version_1_apis/roborock_mqtt_client_v1.py index f9d885d..e06647b 100644 --- a/roborock/version_1_apis/roborock_mqtt_client_v1.py +++ b/roborock/version_1_apis/roborock_mqtt_client_v1.py @@ -71,5 +71,5 @@ async def _send_command( roborock_message = RoborockMessage(timestamp=timestamp, protocol=request_protocol, payload=payload) return await self.send_message(roborock_message) - async def get_map_v1(self): + async def get_map_v1(self) -> bytes | None: return await self.send_command(RoborockCommand.GET_MAP_V1) diff --git a/roborock/version_a01_apis/roborock_client_a01.py b/roborock/version_a01_apis/roborock_client_a01.py index c4d3cd3..e624c13 100644 --- a/roborock/version_a01_apis/roborock_client_a01.py +++ b/roborock/version_a01_apis/roborock_client_a01.py @@ -137,6 +137,8 @@ def on_message_received(self, messages: list[RoborockMessage]) -> None: if queue and queue.protocol == protocol: queue.resolve((converted_response, None)) - async def update_values(self, dyad_data_protocols: list[RoborockDyadDataProtocol | RoborockZeoProtocol]): + async def update_values( + self, dyad_data_protocols: list[RoborockDyadDataProtocol | RoborockZeoProtocol] + ) -> dict[RoborockDyadDataProtocol, typing.Any]: """This should handle updating for each given protocol.""" raise NotImplementedError diff --git a/roborock/version_a01_apis/roborock_mqtt_client_a01.py b/roborock/version_a01_apis/roborock_mqtt_client_a01.py index 8d4fb2a..82bfd56 100644 --- a/roborock/version_a01_apis/roborock_mqtt_client_a01.py +++ b/roborock/version_a01_apis/roborock_mqtt_client_a01.py @@ -57,7 +57,9 @@ async def send_message(self, roborock_message: RoborockMessage): dps_responses[dps] = response[0] return dps_responses - async def update_values(self, dyad_data_protocols: list[RoborockDyadDataProtocol | RoborockZeoProtocol]): + async def update_values( + self, dyad_data_protocols: list[RoborockDyadDataProtocol | RoborockZeoProtocol] + ) -> dict[RoborockDyadDataProtocol, typing.Any]: payload = {"dps": {RoborockDyadDataProtocol.ID_QUERY: str([int(protocol) for protocol in dyad_data_protocols])}} return await self.send_message( RoborockMessage( From d1da322990283b2e333f590f4631bd1399c1007d Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 9 May 2024 09:29:30 -0400 Subject: [PATCH 2/2] feat: add zeo to return --- roborock/version_a01_apis/roborock_client_a01.py | 2 +- roborock/version_a01_apis/roborock_mqtt_client_a01.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roborock/version_a01_apis/roborock_client_a01.py b/roborock/version_a01_apis/roborock_client_a01.py index e624c13..1c2e159 100644 --- a/roborock/version_a01_apis/roborock_client_a01.py +++ b/roborock/version_a01_apis/roborock_client_a01.py @@ -139,6 +139,6 @@ def on_message_received(self, messages: list[RoborockMessage]) -> None: async def update_values( self, dyad_data_protocols: list[RoborockDyadDataProtocol | RoborockZeoProtocol] - ) -> dict[RoborockDyadDataProtocol, typing.Any]: + ) -> dict[RoborockDyadDataProtocol | RoborockZeoProtocol, typing.Any]: """This should handle updating for each given protocol.""" raise NotImplementedError diff --git a/roborock/version_a01_apis/roborock_mqtt_client_a01.py b/roborock/version_a01_apis/roborock_mqtt_client_a01.py index 82bfd56..2cb2dc8 100644 --- a/roborock/version_a01_apis/roborock_mqtt_client_a01.py +++ b/roborock/version_a01_apis/roborock_mqtt_client_a01.py @@ -59,7 +59,7 @@ async def send_message(self, roborock_message: RoborockMessage): async def update_values( self, dyad_data_protocols: list[RoborockDyadDataProtocol | RoborockZeoProtocol] - ) -> dict[RoborockDyadDataProtocol, typing.Any]: + ) -> dict[RoborockDyadDataProtocol | RoborockZeoProtocol, typing.Any]: payload = {"dps": {RoborockDyadDataProtocol.ID_QUERY: str([int(protocol) for protocol in dyad_data_protocols])}} return await self.send_message( RoborockMessage(