mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Bump aiowebostv to 0.6.0 (#136206)
This commit is contained in:
parent
40ed0562bc
commit
66f945e852
@ -19,6 +19,7 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import Event, HomeAssistant
|
from homeassistant.core import Event, HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||||
from homeassistant.helpers import config_validation as cv, discovery
|
from homeassistant.helpers import config_validation as cv, discovery
|
||||||
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -50,7 +51,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: WebOsTvConfigEntry) -> b
|
|||||||
key = entry.data[CONF_CLIENT_SECRET]
|
key = entry.data[CONF_CLIENT_SECRET]
|
||||||
|
|
||||||
# Attempt a connection, but fail gracefully if tv is off for example.
|
# Attempt a connection, but fail gracefully if tv is off for example.
|
||||||
entry.runtime_data = client = WebOsClient(host, key)
|
entry.runtime_data = client = WebOsClient(
|
||||||
|
host, key, client_session=async_get_clientsession(hass)
|
||||||
|
)
|
||||||
with suppress(*WEBOSTV_EXCEPTIONS):
|
with suppress(*WEBOSTV_EXCEPTIONS):
|
||||||
try:
|
try:
|
||||||
await client.connect()
|
await client.connect()
|
||||||
@ -96,9 +99,15 @@ async def async_update_options(hass: HomeAssistant, entry: WebOsTvConfigEntry) -
|
|||||||
await hass.config_entries.async_reload(entry.entry_id)
|
await hass.config_entries.async_reload(entry.entry_id)
|
||||||
|
|
||||||
|
|
||||||
async def async_control_connect(host: str, key: str | None) -> WebOsClient:
|
async def async_control_connect(
|
||||||
|
hass: HomeAssistant, host: str, key: str | None
|
||||||
|
) -> WebOsClient:
|
||||||
"""LG Connection."""
|
"""LG Connection."""
|
||||||
client = WebOsClient(host, key)
|
client = WebOsClient(
|
||||||
|
host,
|
||||||
|
key,
|
||||||
|
client_session=async_get_clientsession(hass),
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
await client.connect()
|
await client.connect()
|
||||||
except WebOsTvPairError:
|
except WebOsTvPairError:
|
||||||
|
@ -69,7 +69,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
try:
|
try:
|
||||||
client = await async_control_connect(self._host, None)
|
client = await async_control_connect(self.hass, self._host, None)
|
||||||
except WebOsTvPairError:
|
except WebOsTvPairError:
|
||||||
errors["base"] = "error_pairing"
|
errors["base"] = "error_pairing"
|
||||||
except WEBOSTV_EXCEPTIONS:
|
except WEBOSTV_EXCEPTIONS:
|
||||||
@ -130,7 +130,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
try:
|
try:
|
||||||
client = await async_control_connect(self._host, None)
|
client = await async_control_connect(self.hass, self._host, None)
|
||||||
except WebOsTvPairError:
|
except WebOsTvPairError:
|
||||||
errors["base"] = "error_pairing"
|
errors["base"] = "error_pairing"
|
||||||
except WEBOSTV_EXCEPTIONS:
|
except WEBOSTV_EXCEPTIONS:
|
||||||
@ -154,7 +154,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
client_key = reconfigure_entry.data.get(CONF_CLIENT_SECRET)
|
client_key = reconfigure_entry.data.get(CONF_CLIENT_SECRET)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client = await async_control_connect(host, client_key)
|
client = await async_control_connect(self.hass, host, client_key)
|
||||||
except WebOsTvPairError:
|
except WebOsTvPairError:
|
||||||
errors["base"] = "error_pairing"
|
errors["base"] = "error_pairing"
|
||||||
except WEBOSTV_EXCEPTIONS:
|
except WEBOSTV_EXCEPTIONS:
|
||||||
@ -195,7 +195,7 @@ class OptionsFlowHandler(OptionsFlow):
|
|||||||
options_input = {CONF_SOURCES: user_input[CONF_SOURCES]}
|
options_input = {CONF_SOURCES: user_input[CONF_SOURCES]}
|
||||||
return self.async_create_entry(title="", data=options_input)
|
return self.async_create_entry(title="", data=options_input)
|
||||||
# Get sources
|
# Get sources
|
||||||
sources_list = await async_get_sources(self.host, self.key)
|
sources_list = await async_get_sources(self.hass, self.host, self.key)
|
||||||
if not sources_list:
|
if not sources_list:
|
||||||
errors["base"] = "cannot_retrieve"
|
errors["base"] = "cannot_retrieve"
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
from aiowebostv import WebOsTvCommandError
|
from aiowebostv import WebOsTvCommandError
|
||||||
from websockets.exceptions import ConnectionClosed, ConnectionClosedOK
|
|
||||||
|
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
|
|
||||||
@ -27,11 +27,10 @@ SERVICE_SELECT_SOUND_OUTPUT = "select_sound_output"
|
|||||||
LIVE_TV_APP_ID = "com.webos.app.livetv"
|
LIVE_TV_APP_ID = "com.webos.app.livetv"
|
||||||
|
|
||||||
WEBOSTV_EXCEPTIONS = (
|
WEBOSTV_EXCEPTIONS = (
|
||||||
OSError,
|
ConnectionResetError,
|
||||||
ConnectionClosed,
|
|
||||||
ConnectionClosedOK,
|
|
||||||
ConnectionRefusedError,
|
|
||||||
WebOsTvCommandError,
|
WebOsTvCommandError,
|
||||||
TimeoutError,
|
aiohttp.ClientConnectorError,
|
||||||
|
aiohttp.ServerDisconnectedError,
|
||||||
asyncio.CancelledError,
|
asyncio.CancelledError,
|
||||||
|
asyncio.TimeoutError,
|
||||||
)
|
)
|
||||||
|
@ -72,10 +72,10 @@ def async_get_client_by_device_entry(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_get_sources(host: str, key: str) -> list[str]:
|
async def async_get_sources(hass: HomeAssistant, host: str, key: str) -> list[str]:
|
||||||
"""Construct sources list."""
|
"""Construct sources list."""
|
||||||
try:
|
try:
|
||||||
client = await async_control_connect(host, key)
|
client = await async_control_connect(hass, host, key)
|
||||||
except WEBOSTV_EXCEPTIONS:
|
except WEBOSTV_EXCEPTIONS:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"domain": "webostv",
|
"domain": "webostv",
|
||||||
"name": "LG webOS Smart TV",
|
"name": "LG webOS TV",
|
||||||
"codeowners": ["@thecode"],
|
"codeowners": ["@thecode"],
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"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.5.0"],
|
"requirements": ["aiowebostv==0.6.0"],
|
||||||
"ssdp": [
|
"ssdp": [
|
||||||
{
|
{
|
||||||
"st": "urn:lge-com:service:webos-second-screen:1"
|
"st": "urn:lge-com:service:webos-second-screen:1"
|
||||||
|
@ -72,7 +72,5 @@ rules:
|
|||||||
|
|
||||||
# Platinum
|
# Platinum
|
||||||
async-dependency: done
|
async-dependency: done
|
||||||
inject-websession:
|
inject-websession: done
|
||||||
status: todo
|
|
||||||
comment: migrate to aiohttp
|
|
||||||
strict-typing: done
|
strict-typing: done
|
||||||
|
@ -3340,7 +3340,7 @@
|
|||||||
"integration_type": "hub",
|
"integration_type": "hub",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"name": "LG webOS Smart TV"
|
"name": "LG webOS TV"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@ -416,7 +416,7 @@ aiowaqi==3.1.0
|
|||||||
aiowatttime==0.1.1
|
aiowatttime==0.1.1
|
||||||
|
|
||||||
# homeassistant.components.webostv
|
# homeassistant.components.webostv
|
||||||
aiowebostv==0.5.0
|
aiowebostv==0.6.0
|
||||||
|
|
||||||
# homeassistant.components.withings
|
# homeassistant.components.withings
|
||||||
aiowithings==3.1.4
|
aiowithings==3.1.4
|
||||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@ -398,7 +398,7 @@ aiowaqi==3.1.0
|
|||||||
aiowatttime==0.1.1
|
aiowatttime==0.1.1
|
||||||
|
|
||||||
# homeassistant.components.webostv
|
# homeassistant.components.webostv
|
||||||
aiowebostv==0.5.0
|
aiowebostv==0.6.0
|
||||||
|
|
||||||
# homeassistant.components.withings
|
# homeassistant.components.withings
|
||||||
aiowithings==3.1.4
|
aiowithings==3.1.4
|
||||||
|
@ -107,7 +107,7 @@ async def test_options_flow_cannot_retrieve(hass: HomeAssistant, client) -> None
|
|||||||
"""Test options config flow cannot retrieve sources."""
|
"""Test options config flow cannot retrieve sources."""
|
||||||
entry = await setup_webostv(hass)
|
entry = await setup_webostv(hass)
|
||||||
|
|
||||||
client.connect.side_effect = ConnectionRefusedError
|
client.connect.side_effect = ConnectionResetError
|
||||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ async def test_form_cannot_connect(hass: HomeAssistant, client) -> None:
|
|||||||
data=MOCK_USER_CONFIG,
|
data=MOCK_USER_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
client.connect.side_effect = ConnectionRefusedError
|
client.connect.side_effect = ConnectionResetError
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input={}
|
result["flow_id"], user_input={}
|
||||||
)
|
)
|
||||||
@ -305,7 +305,7 @@ async def test_reauth_successful(hass: HomeAssistant, client) -> None:
|
|||||||
("side_effect", "error"),
|
("side_effect", "error"),
|
||||||
[
|
[
|
||||||
(WebOsTvPairError, "error_pairing"),
|
(WebOsTvPairError, "error_pairing"),
|
||||||
(ConnectionRefusedError, "cannot_connect"),
|
(ConnectionResetError, "cannot_connect"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_reauth_errors(hass: HomeAssistant, client, side_effect, error) -> None:
|
async def test_reauth_errors(hass: HomeAssistant, client, side_effect, error) -> None:
|
||||||
@ -360,7 +360,7 @@ async def test_reconfigure_successful(hass: HomeAssistant, client) -> None:
|
|||||||
("side_effect", "error"),
|
("side_effect", "error"),
|
||||||
[
|
[
|
||||||
(WebOsTvPairError, "error_pairing"),
|
(WebOsTvPairError, "error_pairing"),
|
||||||
(ConnectionRefusedError, "cannot_connect"),
|
(ConnectionResetError, "cannot_connect"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_reconfigure_errors(
|
async def test_reconfigure_errors(
|
||||||
|
@ -125,7 +125,7 @@ async def test_icon_not_found(
|
|||||||
("side_effect", "error"),
|
("side_effect", "error"),
|
||||||
[
|
[
|
||||||
(WebOsTvPairError, "Pairing with TV failed"),
|
(WebOsTvPairError, "Pairing with TV failed"),
|
||||||
(ConnectionRefusedError, "TV unreachable"),
|
(ConnectionResetError, "TV unreachable"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_connection_errors(
|
async def test_connection_errors(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user