From 49d68a1f977e036774d924d2254cd855b9793456 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Sat, 6 Dec 2025 08:28:04 -0800 Subject: [PATCH 1/3] fix: Lower log level for internal protocol connection details --- roborock/devices/local_channel.py | 4 ++-- roborock/devices/v1_channel.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/roborock/devices/local_channel.py b/roborock/devices/local_channel.py index 6092bb29..331af4ee 100644 --- a/roborock/devices/local_channel.py +++ b/roborock/devices/local_channel.py @@ -176,7 +176,7 @@ def is_local_connected(self) -> bool: async def connect(self) -> None: """Connect to the device and negotiate protocol.""" if self._is_connected: - _LOGGER.warning("Already connected") + _LOGGER.debug("Unexpected call to connect when already connected") return _LOGGER.debug("Connecting to %s:%s", self._host, _PORT) loop = asyncio.get_running_loop() @@ -214,7 +214,7 @@ def close(self) -> None: def _connection_lost(self, exc: Exception | None) -> None: """Handle connection loss.""" - _LOGGER.warning("Connection lost to %s", self._host, exc_info=exc) + _LOGGER.debug("Connection lost to %s", self._host, exc_info=exc) if self._keep_alive_task: self._keep_alive_task.cancel() self._keep_alive_task = None diff --git a/roborock/devices/v1_channel.py b/roborock/devices/v1_channel.py index 15b51a83..feeb2404 100644 --- a/roborock/devices/v1_channel.py +++ b/roborock/devices/v1_channel.py @@ -90,7 +90,7 @@ async def send_command( try: decoded_response = await self._send_rpc(strategy, request) except RoborockException as e: - _LOGGER.warning("Command %s failed on %s channel: %s", method, strategy.name, e) + _LOGGER.debug("Command %s failed on %s channel: %s", method, strategy.name, e) last_exception = e except Exception as e: _LOGGER.exception("Unexpected error sending command %s on %s channel", method, strategy.name) @@ -282,7 +282,7 @@ async def subscribe(self, callback: Callable[[RoborockMessage], None]) -> Callab try: await self._local_connect(prefer_cache=True) except RoborockException as err: - _LOGGER.warning("Could not establish local connection for device %s: %s", self._device_uid, err) + _LOGGER.debug("First local connection attempt for device %s failed, will retry: %s", self._device_uid, err) # Start a background task to manage the local connection health. This # happens independent of whether we were able to connect locally now. From cb955d700a8edc714d96493517b9e716a9dbca64 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Sat, 6 Dec 2025 10:02:40 -0800 Subject: [PATCH 2/3] chore: remove tests for logging --- tests/devices/test_local_channel.py | 12 ------------ tests/devices/test_v1_channel.py | 16 ---------------- 2 files changed, 28 deletions(-) diff --git a/tests/devices/test_local_channel.py b/tests/devices/test_local_channel.py index 661b3df9..ac7719f7 100644 --- a/tests/devices/test_local_channel.py +++ b/tests/devices/test_local_channel.py @@ -102,16 +102,6 @@ async def test_connection_failure(local_channel: LocalChannel, mock_loop: Mock) assert local_channel._is_connected is False -async def test_already_connected_warning( - local_channel: LocalChannel, mock_loop: Mock, caplog: pytest.LogCaptureFixture -) -> None: - """Test warning when trying to connect when already connected.""" - await local_channel.connect() - await local_channel.connect() # Second connection attempt - - assert "Already connected" in caplog.text - assert mock_loop.create_connection.call_count == 1 - async def test_close_connection(local_channel: LocalChannel, mock_loop: Mock, mock_transport: Mock) -> None: """Test closing the connection.""" @@ -228,7 +218,6 @@ async def test_connection_lost_callback( assert local_channel._is_connected is False assert local_channel._transport is None - assert "Connection lost to 192.168.1.100" in caplog.text async def test_connection_lost_without_exception( @@ -242,7 +231,6 @@ async def test_connection_lost_without_exception( assert local_channel._is_connected is False assert local_channel._transport is None - assert "Connection lost to 192.168.1.100" in caplog.text async def test_hello_fallback_to_l01_protocol(mock_loop: Mock, mock_transport: Mock) -> None: diff --git a/tests/devices/test_v1_channel.py b/tests/devices/test_v1_channel.py index 794c8620..2e68a023 100644 --- a/tests/devices/test_v1_channel.py +++ b/tests/devices/test_v1_channel.py @@ -254,22 +254,6 @@ async def test_v1_channel_subscribe_already_connected_error(v1_channel: V1Channe await v1_channel.subscribe(Mock()) -async def test_v1_channel_local_connection_warning_logged( - v1_channel: V1Channel, - mock_mqtt_channel: Mock, - mock_local_channel: Mock, - warning_caplog: pytest.LogCaptureFixture, -) -> None: - """Test that local connection failures are logged as warnings.""" - mock_mqtt_channel.response_queue.append(TEST_NETWORK_INFO_RESPONSE) - mock_local_channel.connect.side_effect = RoborockException("Local connection failed") - - await v1_channel.subscribe(Mock()) - - assert "Could not establish local connection for device abc123" in warning_caplog.text - assert "Local connection failed" in warning_caplog.text - - async def test_v1_channel_send_command_local_preferred( v1_channel: V1Channel, mock_mqtt_channel: Mock, From e59ed41b8ba338b3dc920f8eae5fecf720c97d40 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Sat, 6 Dec 2025 15:25:47 -0800 Subject: [PATCH 3/3] chore: fix lint erors --- tests/devices/test_local_channel.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/devices/test_local_channel.py b/tests/devices/test_local_channel.py index ac7719f7..5c1226c8 100644 --- a/tests/devices/test_local_channel.py +++ b/tests/devices/test_local_channel.py @@ -102,7 +102,6 @@ async def test_connection_failure(local_channel: LocalChannel, mock_loop: Mock) assert local_channel._is_connected is False - async def test_close_connection(local_channel: LocalChannel, mock_loop: Mock, mock_transport: Mock) -> None: """Test closing the connection.""" await local_channel.connect()