python-roborock 0.18.7__tar.gz → 0.18.8__tar.gz
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.
- {python_roborock-0.18.7 → python_roborock-0.18.8}/PKG-INFO +1 -1
- {python_roborock-0.18.7 → python_roborock-0.18.8}/pyproject.toml +1 -1
- {python_roborock-0.18.7 → python_roborock-0.18.8}/roborock/local_api.py +41 -30
- {python_roborock-0.18.7 → python_roborock-0.18.8}/LICENSE +0 -0
- {python_roborock-0.18.7 → python_roborock-0.18.8}/README.md +0 -0
- {python_roborock-0.18.7 → python_roborock-0.18.8}/roborock/__init__.py +0 -0
- {python_roborock-0.18.7 → python_roborock-0.18.8}/roborock/api.py +0 -0
- {python_roborock-0.18.7 → python_roborock-0.18.8}/roborock/cli.py +0 -0
- {python_roborock-0.18.7 → python_roborock-0.18.8}/roborock/cloud_api.py +0 -0
- {python_roborock-0.18.7 → python_roborock-0.18.8}/roborock/code_mappings.py +0 -0
- {python_roborock-0.18.7 → python_roborock-0.18.8}/roborock/const.py +0 -0
- {python_roborock-0.18.7 → python_roborock-0.18.8}/roborock/containers.py +0 -0
- {python_roborock-0.18.7 → python_roborock-0.18.8}/roborock/exceptions.py +0 -0
- {python_roborock-0.18.7 → python_roborock-0.18.8}/roborock/protocol.py +0 -0
- {python_roborock-0.18.7 → python_roborock-0.18.8}/roborock/roborock_future.py +0 -0
- {python_roborock-0.18.7 → python_roborock-0.18.8}/roborock/roborock_message.py +0 -0
- {python_roborock-0.18.7 → python_roborock-0.18.8}/roborock/roborock_typing.py +0 -0
- {python_roborock-0.18.7 → python_roborock-0.18.8}/roborock/util.py +0 -0
|
@@ -9,7 +9,11 @@ import async_timeout
|
|
|
9
9
|
|
|
10
10
|
from . import DeviceData
|
|
11
11
|
from .api import COMMANDS_SECURED, QUEUE_TIMEOUT, RoborockClient
|
|
12
|
-
from .exceptions import
|
|
12
|
+
from .exceptions import (
|
|
13
|
+
CommandVacuumError,
|
|
14
|
+
RoborockConnectionException,
|
|
15
|
+
RoborockException,
|
|
16
|
+
)
|
|
13
17
|
from .protocol import MessageParser
|
|
14
18
|
from .roborock_message import RoborockMessage, RoborockMessageProtocol
|
|
15
19
|
from .roborock_typing import CommandInfoMap, RoborockCommand
|
|
@@ -47,10 +51,14 @@ class RoborockLocalClient(RoborockClient, asyncio.Protocol):
|
|
|
47
51
|
return self.transport and self.transport.is_reading()
|
|
48
52
|
|
|
49
53
|
async def keep_alive_func(self, _=None):
|
|
50
|
-
|
|
54
|
+
try:
|
|
55
|
+
await self.ping()
|
|
56
|
+
except RoborockException:
|
|
57
|
+
pass
|
|
51
58
|
self.keep_alive_task = self.loop.call_later(10, lambda: asyncio.create_task(self.keep_alive_func()))
|
|
52
59
|
|
|
53
60
|
async def async_connect(self) -> None:
|
|
61
|
+
should_ping = False
|
|
54
62
|
async with self._mutex:
|
|
55
63
|
try:
|
|
56
64
|
if not self.is_connected():
|
|
@@ -61,10 +69,12 @@ class RoborockLocalClient(RoborockClient, asyncio.Protocol):
|
|
|
61
69
|
lambda: self, self.host, 58867
|
|
62
70
|
)
|
|
63
71
|
_LOGGER.info(f"Connected to {self.host}")
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
except Exception as e:
|
|
72
|
+
should_ping = True
|
|
73
|
+
except BaseException as e:
|
|
67
74
|
raise RoborockConnectionException(f"Failed connecting to {self.host}") from e
|
|
75
|
+
if should_ping:
|
|
76
|
+
await self.hello()
|
|
77
|
+
await self.keep_alive_func()
|
|
68
78
|
|
|
69
79
|
def sync_disconnect(self) -> None:
|
|
70
80
|
if self.transport and self.loop.is_running():
|
|
@@ -95,28 +105,33 @@ class RoborockLocalClient(RoborockClient, asyncio.Protocol):
|
|
|
95
105
|
)
|
|
96
106
|
|
|
97
107
|
async def hello(self):
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
request_id = 1
|
|
109
|
+
protocol = RoborockMessageProtocol.HELLO_REQUEST
|
|
110
|
+
try:
|
|
111
|
+
return await self.send_message(
|
|
112
|
+
RoborockMessage(
|
|
113
|
+
protocol=protocol,
|
|
114
|
+
payload=None,
|
|
115
|
+
seq=request_id,
|
|
116
|
+
version=b"1.0",
|
|
117
|
+
random=22,
|
|
105
118
|
)
|
|
106
|
-
|
|
107
|
-
|
|
119
|
+
)
|
|
120
|
+
except Exception as e:
|
|
121
|
+
_LOGGER.error(e)
|
|
108
122
|
|
|
109
123
|
async def ping(self):
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
request_id = 2
|
|
125
|
+
protocol = RoborockMessageProtocol.PING_REQUEST
|
|
126
|
+
return await self.send_message(
|
|
127
|
+
RoborockMessage(
|
|
128
|
+
protocol=protocol,
|
|
129
|
+
payload=None,
|
|
130
|
+
seq=request_id,
|
|
131
|
+
version=b"1.0",
|
|
132
|
+
random=23,
|
|
133
|
+
)
|
|
134
|
+
)
|
|
120
135
|
|
|
121
136
|
async def send_command(self, method: RoborockCommand, params: Optional[list | dict] = None):
|
|
122
137
|
roborock_message = self.build_roborock_message(method, params)
|
|
@@ -136,12 +151,8 @@ class RoborockLocalClient(RoborockClient, asyncio.Protocol):
|
|
|
136
151
|
(response, err) = await self._async_response(request_id, response_protocol)
|
|
137
152
|
if err:
|
|
138
153
|
raise CommandVacuumError("", err) from err
|
|
139
|
-
|
|
140
|
-
f"method {roborock_message.get_method()}"
|
|
141
|
-
if roborock_message.protocol == 4
|
|
142
|
-
else f"protocol {RoborockMessageProtocol(roborock_message.protocol).name}"
|
|
143
|
-
)
|
|
144
|
-
_LOGGER.debug(f"id={request_id} Response from {method}: {response}")
|
|
154
|
+
if roborock_message.protocol == 4:
|
|
155
|
+
_LOGGER.debug(f"id={request_id} Response from method {roborock_message.get_method()}: {response}")
|
|
145
156
|
return response
|
|
146
157
|
|
|
147
158
|
def _send_msg_raw(self, data: bytes):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|