Skip to content

Commit c1b20e3

Browse files
committed
fix: temp cache of protocol version until restart
1 parent f1bfa39 commit c1b20e3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

roborock/devices/local_channel.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@ class LocalChannel(Channel):
5151
format most parsing to higher-level components.
5252
"""
5353

54+
_protocol_cache: dict[str, LocalProtocolVersion] = {}
55+
5456
def __init__(self, host: str, local_key: str):
5557
self._host = host
5658
self._transport: asyncio.Transport | None = None
5759
self._protocol: _LocalProtocol | None = None
5860
self._subscribers: CallbackList[RoborockMessage] = CallbackList(_LOGGER)
5961
self._is_connected = False
60-
self._local_protocol_version: LocalProtocolVersion | None = None
62+
self._local_protocol_version: LocalProtocolVersion | None = self._protocol_cache.get(host)
6163
self._update_encoder_decoder(
6264
LocalChannelParams(local_key=local_key, connect_nonce=get_next_int(10000, 32767), ack_nonce=None)
6365
)
@@ -123,6 +125,7 @@ async def _hello(self):
123125
if params is not None:
124126
self._local_protocol_version = version
125127
self._update_encoder_decoder(params)
128+
self._protocol_cache[self._host] = self._local_protocol_version
126129
return
127130

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

0 commit comments

Comments
 (0)