Bump aiowebostv to 0.5.0 (#136097)

This commit is contained in:
Shay Levy 2025-01-20 20:31:45 +02:00 committed by GitHub
parent a84335ae6d
commit 8d99a54656
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 20 additions and 29 deletions

View File

@ -9,12 +9,7 @@ from urllib.parse import urlparse
from aiowebostv import WebOsTvPairError from aiowebostv import WebOsTvPairError
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigFlow, ConfigFlowResult, OptionsFlow
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_CLIENT_SECRET, CONF_HOST from homeassistant.const import CONF_CLIENT_SECRET, CONF_HOST
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
@ -24,7 +19,7 @@ from homeassistant.helpers.service_info.ssdp import (
SsdpServiceInfo, SsdpServiceInfo,
) )
from . import async_control_connect from . import WebOsTvConfigEntry, async_control_connect
from .const import CONF_SOURCES, DEFAULT_NAME, DOMAIN, WEBOSTV_EXCEPTIONS from .const import CONF_SOURCES, DEFAULT_NAME, DOMAIN, WEBOSTV_EXCEPTIONS
from .helpers import async_get_sources from .helpers import async_get_sources
@ -49,7 +44,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
@staticmethod @staticmethod
@callback @callback
def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlow: def async_get_options_flow(config_entry: WebOsTvConfigEntry) -> OptionsFlow:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return OptionsFlowHandler(config_entry) return OptionsFlowHandler(config_entry)
@ -186,7 +181,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
class OptionsFlowHandler(OptionsFlow): class OptionsFlowHandler(OptionsFlow):
"""Handle options.""" """Handle options."""
def __init__(self, config_entry: ConfigEntry) -> None: def __init__(self, config_entry: WebOsTvConfigEntry) -> None:
"""Initialize options flow.""" """Initialize options flow."""
self.host = config_entry.data[CONF_HOST] self.host = config_entry.data[CONF_HOST]
self.key = config_entry.data[CONF_CLIENT_SECRET] self.key = config_entry.data[CONF_CLIENT_SECRET]

View File

@ -9,7 +9,7 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.helpers.device_registry import DeviceEntry from homeassistant.helpers.device_registry import DeviceEntry
from . import async_control_connect from . import WebOsTvConfigEntry, async_control_connect
from .const import DOMAIN, LIVE_TV_APP_ID, WEBOSTV_EXCEPTIONS from .const import DOMAIN, LIVE_TV_APP_ID, WEBOSTV_EXCEPTIONS
@ -56,7 +56,9 @@ def async_get_client_by_device_entry(
Raises ValueError if client is not found. Raises ValueError if client is not found.
""" """
for config_entry_id in device.config_entries: for config_entry_id in device.config_entries:
entry = hass.config_entries.async_get_entry(config_entry_id) entry: WebOsTvConfigEntry | None = hass.config_entries.async_get_entry(
config_entry_id
)
if entry and entry.domain == DOMAIN: if entry and entry.domain == DOMAIN:
if entry.state is ConfigEntryState.LOADED: if entry.state is ConfigEntryState.LOADED:
return entry.runtime_data return entry.runtime_data

View File

@ -6,7 +6,7 @@
"documentation": "https://www.home-assistant.io/integrations/webostv", "documentation": "https://www.home-assistant.io/integrations/webostv",
"iot_class": "local_push", "iot_class": "local_push",
"loggers": ["aiowebostv"], "loggers": ["aiowebostv"],
"requirements": ["aiowebostv==0.4.2"], "requirements": ["aiowebostv==0.5.0"],
"ssdp": [ "ssdp": [
{ {
"st": "urn:lge-com:service:webos-second-screen:1" "st": "urn:lge-com:service:webos-second-screen:1"

View File

@ -196,7 +196,7 @@ class LgWebOSMediaPlayerEntity(RestoreEntity, MediaPlayerEntity):
self._attr_volume_level = None self._attr_volume_level = None
if self._client.volume is not None: if self._client.volume is not None:
self._attr_volume_level = cast(float, self._client.volume / 100.0) self._attr_volume_level = self._client.volume / 100.0
self._attr_source = self._current_source self._attr_source = self._current_source
self._attr_source_list = sorted(self._source_list) self._attr_source_list = sorted(self._source_list)
@ -240,13 +240,9 @@ class LgWebOSMediaPlayerEntity(RestoreEntity, MediaPlayerEntity):
) )
self._attr_assumed_state = True self._attr_assumed_state = True
if ( if self._client.is_on and self._client.media_state:
self._client.is_on
and self._client.media_state is not None
and self._client.media_state.get("foregroundAppInfo") is not None
):
self._attr_assumed_state = False self._attr_assumed_state = False
for entry in self._client.media_state.get("foregroundAppInfo"): for entry in self._client.media_state:
if entry.get("playState") == "playing": if entry.get("playState") == "playing":
self._attr_state = MediaPlayerState.PLAYING self._attr_state = MediaPlayerState.PLAYING
elif entry.get("playState") == "paused": elif entry.get("playState") == "paused":
@ -254,7 +250,7 @@ class LgWebOSMediaPlayerEntity(RestoreEntity, MediaPlayerEntity):
elif entry.get("playState") == "unloaded": elif entry.get("playState") == "unloaded":
self._attr_state = MediaPlayerState.IDLE self._attr_state = MediaPlayerState.IDLE
if self._client.system_info is not None or self.state != MediaPlayerState.OFF: if self.state != MediaPlayerState.OFF:
maj_v = self._client.software_info.get("major_ver") maj_v = self._client.software_info.get("major_ver")
min_v = self._client.software_info.get("minor_ver") min_v = self._client.software_info.get("minor_ver")
if maj_v and min_v: if maj_v and min_v:
@ -406,7 +402,7 @@ class LgWebOSMediaPlayerEntity(RestoreEntity, MediaPlayerEntity):
"""Play a piece of media.""" """Play a piece of media."""
_LOGGER.debug("Call play media type <%s>, Id <%s>", media_type, media_id) _LOGGER.debug("Call play media type <%s>, Id <%s>", media_type, media_id)
if media_type == MediaType.CHANNEL: if media_type == MediaType.CHANNEL and self._client.channels:
_LOGGER.debug("Searching channel") _LOGGER.debug("Searching channel")
partial_match_channel_id = None partial_match_channel_id = None
perfect_match_channel_id = None perfect_match_channel_id = None

View File

@ -77,6 +77,4 @@ rules:
inject-websession: inject-websession:
status: todo status: todo
comment: need to check if it is needed for websockets or migrate to aiohttp comment: need to check if it is needed for websockets or migrate to aiohttp
strict-typing: strict-typing: done
status: todo
comment: aiowebostv is not fully typed

2
requirements_all.txt generated
View File

@ -416,7 +416,7 @@ aiowaqi==3.1.0
aiowatttime==0.1.1 aiowatttime==0.1.1
# homeassistant.components.webostv # homeassistant.components.webostv
aiowebostv==0.4.2 aiowebostv==0.5.0
# homeassistant.components.withings # homeassistant.components.withings
aiowithings==3.1.4 aiowithings==3.1.4

View File

@ -398,7 +398,7 @@ aiowaqi==3.1.0
aiowatttime==0.1.1 aiowatttime==0.1.1
# homeassistant.components.webostv # homeassistant.components.webostv
aiowebostv==0.4.2 aiowebostv==0.5.0
# homeassistant.components.withings # homeassistant.components.withings
aiowithings==3.1.4 aiowithings==3.1.4

View File

@ -820,15 +820,15 @@ async def test_update_media_state(hass: HomeAssistant, client) -> None:
"""Test updating media state.""" """Test updating media state."""
await setup_webostv(hass) await setup_webostv(hass)
client.media_state = {"foregroundAppInfo": [{"playState": "playing"}]} client.media_state = [{"playState": "playing"}]
await client.mock_state_update() await client.mock_state_update()
assert hass.states.get(ENTITY_ID).state == MediaPlayerState.PLAYING assert hass.states.get(ENTITY_ID).state == MediaPlayerState.PLAYING
client.media_state = {"foregroundAppInfo": [{"playState": "paused"}]} client.media_state = [{"playState": "paused"}]
await client.mock_state_update() await client.mock_state_update()
assert hass.states.get(ENTITY_ID).state == MediaPlayerState.PAUSED assert hass.states.get(ENTITY_ID).state == MediaPlayerState.PAUSED
client.media_state = {"foregroundAppInfo": [{"playState": "unloaded"}]} client.media_state = [{"playState": "unloaded"}]
await client.mock_state_update() await client.mock_state_update()
assert hass.states.get(ENTITY_ID).state == MediaPlayerState.IDLE assert hass.states.get(ENTITY_ID).state == MediaPlayerState.IDLE