1
mirror of https://github.com/home-assistant/core synced 2024-08-06 09:34:49 +02:00

Adjust websocket bridge logging in SamsungTV (#67809)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-03-07 23:31:57 +01:00 committed by GitHub
parent d1ef92c17a
commit c70bed86ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 10 deletions

View File

@ -435,7 +435,7 @@ class SamsungTVWSBridge(SamsungTVBridge):
"""Create or return a remote control instance."""
if self._remote is None or not self._remote.is_alive():
# We need to create a new instance to reconnect.
LOGGER.debug("Create SamsungTVWSBridge for %s (%s)", CONF_NAME, self.host)
LOGGER.debug("Create SamsungTVWSBridge for %s", self.host)
assert self.port
self._remote = SamsungTVWSAsyncRemote(
host=self.host,
@ -449,20 +449,24 @@ class SamsungTVWSBridge(SamsungTVBridge):
# This is only happening when the auth was switched to DENY
# A removed auth will lead to socket timeout because waiting for auth popup is just an open socket
except ConnectionFailure as err:
LOGGER.debug("ConnectionFailure %s", err.__repr__())
LOGGER.info(
"Failed to get remote for %s, re-authentication required: %s",
self.host,
err.__repr__(),
)
self._notify_reauth_callback()
except (WebSocketException, AsyncioTimeoutError, OSError) as err:
LOGGER.debug("WebSocketException, OSError %s", err.__repr__())
LOGGER.debug(
"Failed to get remote for %s: %s", self.host, err.__repr__()
)
self._remote = None
else:
LOGGER.debug(
"Created SamsungTVWSBridge for %s (%s)", CONF_NAME, self.host
)
LOGGER.debug("Created SamsungTVWSBridge for %s", self.host)
if self._device_info is None:
# Initialise device info on first connect
await self.async_device_info()
if self.token != self._remote.token:
LOGGER.debug(
LOGGER.info(
"SamsungTVWSBridge has provided a new token %s",
self._remote.token,
)
@ -477,5 +481,7 @@ class SamsungTVWSBridge(SamsungTVBridge):
# Close the current remote connection
await self._remote.close()
self._remote = None
except OSError:
LOGGER.debug("Could not establish connection")
except OSError as err:
LOGGER.debug(
"Error closing connection to %s: %s", self.host, err.__repr__()
)

View File

@ -695,7 +695,7 @@ async def test_turn_off_ws_os_error(
assert await hass.services.async_call(
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
)
assert "Could not establish connection" in caplog.text
assert "Error closing connection" in caplog.text
async def test_volume_up(hass: HomeAssistant, remote: Mock) -> None: