Skip to content

Conversation

@Lash-L
Copy link
Collaborator

@Lash-L Lash-L commented Nov 15, 2025

Fix L01 on the new devices api

Copilot finished reviewing on behalf of Lash-L November 15, 2025 18:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes L01 protocol encoding and decoding in the new devices API by properly handling protocol version information in local communication channels.

Key Changes:

  • Updated encode_message to use LocalProtocolVersion enum instead of plain strings for better type safety
  • Added protocol_version property to LocalChannel to expose the negotiated protocol version
  • Modified local RPC channel creation to pass the correct protocol version when encoding messages

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
roborock/protocols/v1_protocol.py Changed version parameter type from str to LocalProtocolVersion enum and updated encoding to use .value.encode()
roborock/devices/v1_rpc_channel.py Updated create_local_rpc_channel to pass the negotiated protocol version from local_channel.protocol_version
roborock/devices/local_channel.py Added protocol_version property that returns the negotiated version or defaults to V1; also fixed callback assignment in _update_encoder_decoder

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

format most parsing to higher-level components.
"""

_protocol_cache: dict[str, LocalProtocolVersion] = {}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can move the responsibility for this further upstream if you'd like.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i generally get the idea of caching things, but i'm having a hard time seeing how often this will get used. Are we creating local channels repeatedly? i would have thought once per session given once connected it will stay connected.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I would cache this like or in NetworkInfo, but i realize it could change if firmware version changes so i casee thats difficult)

# Callback to decode messages and dispatch to subscribers
self._data_received: Callable[[bytes], None] = decoder_callback(self._decoder, self._subscribers, _LOGGER)
if self._protocol:
self._protocol.messages_cb = self._data_received
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of mutating the object, lets just give it a different callback to this class that will invoke the right thing. (change the constructor value of _LocalProtocol(...) to point to something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants