Fix WebSocketTimeoutException in SamsungTV (#68114)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet
2022-03-14 17:32:14 +01:00
committed by GitHub
parent 3de341099f
commit c0860931b3

View File

@@ -10,7 +10,7 @@ from samsungctl import Remote
from samsungctl.exceptions import AccessDenied, ConnectionClosed, UnhandledResponse from samsungctl.exceptions import AccessDenied, ConnectionClosed, UnhandledResponse
from samsungtvws import SamsungTVWS from samsungtvws import SamsungTVWS
from samsungtvws.exceptions import ConnectionFailure, HttpApiError from samsungtvws.exceptions import ConnectionFailure, HttpApiError
from websocket import WebSocketException from websocket import WebSocketException, WebSocketTimeoutException
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
@@ -318,8 +318,8 @@ class SamsungTVWSBridge(SamsungTVBridge):
def _get_app_list(self) -> dict[str, str] | None: def _get_app_list(self) -> dict[str, str] | None:
"""Get installed app list.""" """Get installed app list."""
if self._app_list is None: if self._app_list is None and (remote := self._get_remote()):
if remote := self._get_remote(): with contextlib.suppress(WebSocketTimeoutException):
raw_app_list: list[dict[str, str]] = remote.app_list() raw_app_list: list[dict[str, str]] = remote.app_list()
self._app_list = { self._app_list = {
app["name"]: app["appId"] app["name"]: app["appId"]