Skip to content

Conversation

@allenporter
Copy link
Contributor

This merges the two packages v1_channel and v1_rpc_channel since they are very closely related. The differences between the RPC types are now handled with RpcStrategy (encoding, decoding, which channel, health checking, etc). The "PayloadEncodedV1RpcChannel" is now _send_rpc which accepts the rpc strategy.

The V1RpcChannel interface is moved to the v1_protocol module and now has a single implementation that handles everyting (the PickFirstAvailable logic as well as the response parsing).

Overall the code is now less generalized, but is probably easier to understand since its all in a single place. Notably, all the rpc code was already tested via the v1_channel interface.

This merges the two packages v1_channel and v1_rpc_channel since they are very closely related. The differences between the RPC types are now handled with `RpcStrategy` (encoding, decoding, which channel, health checking, etc). The "PayloadEncodedV1RpcChannel" is now `_send_rpc` which accepts the rpc strategy.

The `V1RpcChannel` interface is moved to the `v1_protocol` module and now has a single implementation that handles everyting (the `PickFirstAvailable`  logic as well as the response parsing).

Overall the code is now less generalized, but is probably easier to understand since its all in a single place. Notably, all the rpc code was already tested via the v1_channel interface.
Copilot AI review requested due to automatic review settings November 29, 2025 16:05
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 refactors the V1 RPC channel implementation by consolidating the v1_rpc_channel and v1_channel modules. The refactoring introduces a strategy pattern via RpcStrategy to handle different transport methods (MQTT, local) with their specific encoding, decoding, and health checking requirements.

Key Changes:

  • Moved V1RpcChannel Protocol from v1_rpc_channel.py to v1_protocol.py for better organization
  • Introduced RpcStrategy dataclass to encapsulate transport-specific configuration (encoder, decoder, channel, health manager)
  • Consolidated RPC logic into a single RpcChannel implementation with automatic fallback between transports
  • Removed separate channel factory functions in favor of dynamic strategy creation methods

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
roborock/protocols/v1_protocol.py Added V1RpcChannel Protocol definition with overloaded send_command method to support both typed and untyped responses
roborock/devices/v1_channel.py Introduced RpcStrategy and RpcChannel classes; consolidated all RPC logic including transport selection, encoding/decoding, and error handling with automatic fallback
roborock/devices/v1_rpc_channel.py Deleted entire file - functionality merged into v1_channel.py
roborock/devices/mqtt_channel.py Fixed docstring from "V1Channel" to "MQTT channel" for accuracy
roborock/devices/traits/v1/common.py Updated import to use V1RpcChannel from v1_protocol module
roborock/devices/traits/v1/__init__.py Updated import to use V1RpcChannel from v1_protocol module
tests/devices/test_v1_device.py Updated import for decode_rpc_response from v1_protocol module
tests/devices/test_v1_channel.py Updated mock patch location for create_map_response_decoder; updated test expectations to reflect new fallback behavior; changed test commands from CHANGE_SOUND_VOLUME to GET_STATUS to match test fixtures

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

@allenporter allenporter merged commit f3487e8 into Python-roborock:main Nov 29, 2025
7 checks passed
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.

2 participants