Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions roborock/devices/local_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions roborock/devices/v1_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 0 additions & 13 deletions tests/devices/test_local_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +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."""
await local_channel.connect()
Expand Down Expand Up @@ -228,7 +217,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(
Expand All @@ -242,7 +230,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:
Expand Down
16 changes: 0 additions & 16 deletions tests/devices/test_v1_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down