@@ -72,13 +72,10 @@ class RpcStrategy:
7272
7373
7474class RpcChannel (V1RpcChannel ):
75- """Wrapper to expose V1RpcChannel interface with a specific set of RpcStrategies.
76-
77- This is used to provide a simpler interface to v1 traits for sending commands
78- over multiple possible transports (local, MQTT) with automatic fallback.
79- """
75+ """Provides a synchronous RPC interface around a transport channel."""
8076
8177 def __init__ (self , rpc_strategies : list [RpcStrategy ]) -> None :
78+ """Initialize the RpcChannel with on ordered list of strategies."""
8279 self ._rpc_strategies = rpc_strategies
8380
8481 @override
@@ -116,14 +113,11 @@ async def send_command(
116113
117114 @staticmethod
118115 async def _send_rpc (strategy : RpcStrategy , request : RequestMessage ) -> ResponseData | bytes :
119- """Send a command and return a parsed response RoborockBase type.
116+ """Send a command and return a decoded response type.
120117
121118 This provides an RPC interface over a given channel strategy. The device
122119 channel only supports publish and subscribe, so this function handles
123120 associating requests with their corresponding responses.
124-
125- The provided RpcStrategy defines how to encode/decode messages and which
126- channel to use for communication.
127121 """
128122 future : asyncio .Future [ResponseData | bytes ] = asyncio .Future ()
129123 _LOGGER .debug (
@@ -253,26 +247,18 @@ def _create_local_rpc_strategy(self) -> RpcStrategy | None:
253247 def _local_encoder (self , x : RequestMessage ) -> RoborockMessage :
254248 """Encode a request message for local transport.
255249
256- This is passed to the RpcStrategy as a function so that it will
257- read the current local channel's protocol version which changes as
258- the protocol version is discovered.
250+ This will read the current local channel's protocol version which
251+ changes as the protocol version is discovered.
259252 """
260253 if self ._local_channel is None :
261- # This is for typing and should not happen since we only create the
262- # strategy if local is connected and it will never get set back to
263- # None once connected.
264- raise ValueError ("Local channel is not available for encoding" )
254+ raise ValueError ("Local channel unavailable for encoding" )
265255 return x .encode_message (
266256 RoborockMessageProtocol .GENERAL_REQUEST ,
267257 version = self ._local_channel .protocol_version ,
268258 )
269259
270260 def _create_mqtt_rpc_strategy (self , decoder : Callable [[RoborockMessage ], Any ] = decode_rpc_response ) -> RpcStrategy :
271- """Create the RPC strategy for MQTT transport.
272-
273- This can optionally take a custom decoder for different response types
274- such as map data.
275- """
261+ """Create the RPC strategy for MQTT transport with optional custom decoder."""
276262 return RpcStrategy (
277263 name = "mqtt" ,
278264 channel = self ._mqtt_channel ,
0 commit comments