Bump samsungtvws to v2.1.0 (#67483)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-03-02 19:09:06 +01:00 committed by GitHub
parent a4915eb704
commit b245ba6d57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 9 deletions

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from abc import ABC, abstractmethod
from asyncio.exceptions import TimeoutError as AsyncioTimeoutError
import contextlib
from typing import Any
from typing import Any, cast
from samsungctl import Remote
from samsungctl.exceptions import AccessDenied, ConnectionClosed, UnhandledResponse
@ -313,10 +313,12 @@ class SamsungTVWSBridge(SamsungTVBridge):
"""Get installed app list."""
if self._app_list is None:
if remote := self._get_remote():
raw_app_list: list[dict[str, str]] = remote.app_list()
raw_app_list = remote.app_list()
self._app_list = {
app["name"]: app["appId"]
for app in sorted(raw_app_list, key=lambda app: app["name"])
for app in sorted(
raw_app_list or [], key=lambda app: cast(str, app["name"])
)
}
return self._app_list
@ -355,8 +357,8 @@ class SamsungTVWSBridge(SamsungTVBridge):
host=self.host,
port=self.port,
token=self.token,
timeout=config[CONF_TIMEOUT],
name=config[CONF_NAME],
timeout=TIMEOUT_REQUEST,
name=VALUE_CONF_NAME,
) as remote:
remote.open()
self.token = remote.token
@ -379,6 +381,7 @@ class SamsungTVWSBridge(SamsungTVBridge):
async def async_device_info(self) -> dict[str, Any] | None:
"""Try to gather infos of this TV."""
if self._rest_api is None:
assert self.port
self._rest_api = SamsungTVAsyncRest(
host=self.host,
session=async_get_clientsession(self.hass),
@ -423,7 +426,7 @@ class SamsungTVWSBridge(SamsungTVBridge):
# Different reasons, e.g. hostname not resolveable
pass
def _get_remote(self) -> SamsungTVWS:
def _get_remote(self) -> SamsungTVWS | None:
"""Create or return a remote control instance."""
if self._remote is None:
# We need to create a new instance to reconnect.
@ -431,6 +434,7 @@ class SamsungTVWSBridge(SamsungTVBridge):
LOGGER.debug(
"Create SamsungTVWSBridge for %s (%s)", CONF_NAME, self.host
)
assert self.port
self._remote = SamsungTVWS(
host=self.host,
port=self.port,

View File

@ -5,7 +5,7 @@
"requirements": [
"getmac==0.8.2",
"samsungctl[websocket]==0.7.1",
"samsungtvws[async]==2.0.0",
"samsungtvws[async]==2.1.0",
"wakeonlan==2.0.1"
],
"ssdp": [

View File

@ -2093,7 +2093,7 @@ rxv==0.7.0
samsungctl[websocket]==0.7.1
# homeassistant.components.samsungtv
samsungtvws[async]==2.0.0
samsungtvws[async]==2.1.0
# homeassistant.components.satel_integra
satel_integra==0.3.4

View File

@ -1330,7 +1330,7 @@ rxv==0.7.0
samsungctl[websocket]==0.7.1
# homeassistant.components.samsungtv
samsungtvws[async]==2.0.0
samsungtvws[async]==2.1.0
# homeassistant.components.dhcp
scapy==2.4.5