Skip to content

Commit ac21c9b

Browse files
committed
fix: attempt to fix l01
1 parent 20afa92 commit ac21c9b

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

roborock/devices/local_channel.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ async def _hello(self):
125125

126126
raise RoborockException("Failed to connect to device with any known protocol")
127127

128+
@property
129+
def protocol_version(self) -> LocalProtocolVersion:
130+
"""Return the negotiated local protocol version, or a sensible default."""
131+
if self._local_protocol_version is not None:
132+
return self._local_protocol_version
133+
return LocalProtocolVersion.V1
134+
128135
@property
129136
def is_connected(self) -> bool:
130137
"""Check if the channel is currently connected."""

roborock/devices/v1_rpc_channel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def create_local_rpc_channel(local_channel: LocalChannel) -> V1RpcChannel:
188188
return PayloadEncodedV1RpcChannel(
189189
"local",
190190
local_channel,
191-
lambda x: x.encode_message(RoborockMessageProtocol.GENERAL_REQUEST),
191+
lambda x: x.encode_message(RoborockMessageProtocol.GENERAL_REQUEST, version=local_channel.protocol_version),
192192
decode_rpc_response,
193193
)
194194

roborock/protocols/v1_protocol.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,17 @@ class RequestMessage:
7373
request_id: int = field(default_factory=lambda: get_next_int(10000, 32767))
7474

7575
def encode_message(
76-
self, protocol: RoborockMessageProtocol, security_data: SecurityData | None = None, version: str = "1.0"
76+
self,
77+
protocol: RoborockMessageProtocol,
78+
security_data: SecurityData | None = None,
79+
version: LocalProtocolVersion = LocalProtocolVersion.V1,
7780
) -> RoborockMessage:
7881
"""Convert the request message to a RoborockMessage."""
7982
return RoborockMessage(
8083
timestamp=self.timestamp,
8184
protocol=protocol,
8285
payload=self._as_payload(security_data=security_data),
83-
version=version.encode(),
86+
version=version.value.encode(),
8487
)
8588

8689
def _as_payload(self, security_data: SecurityData | None) -> bytes:

0 commit comments

Comments
 (0)