Skip to content

Commit ad5b4d3

Browse files
committed
Fix local API
1 parent 35932b2 commit ad5b4d3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

roborock/local_api.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ class _LocalProtocol(asyncio.Protocol):
2525
messages_cb: Callable[[bytes], None]
2626
connection_lost_cb: Callable[[Exception | None], None]
2727

28+
def data_received(self, bytes) -> None:
29+
"""Called when data is received from the transport."""
30+
self.messages_cb(bytes)
31+
32+
def connection_lost(self, exc: Exception | None) -> None:
33+
"""Called when the transport connection is lost."""
34+
self.connection_lost_cb(exc)
35+
2836

2937
class RoborockLocalClient(RoborockClient, ABC):
3038
"""Roborock local client base class."""

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def handle_write(data: bytes) -> None:
209209
if response is not None:
210210
_LOGGER.debug("Replying with %s", response)
211211
loop = asyncio.get_running_loop()
212-
loop.call_soon(protocol.messages_cb, response)
212+
loop.call_soon(protocol.data_received, response)
213213

214214
closed = asyncio.Event()
215215

0 commit comments

Comments
 (0)