mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Fix webostv configure sources when selected source is missing (#65195)
* Fix webostv configure sources when selected source is missing * Add comment for filtering duplicates
This commit is contained in:
parent
30440cd1ba
commit
caa5578134
@ -178,11 +178,14 @@ class OptionsFlowHandler(config_entries.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 = self.options.get(CONF_SOURCES, "")
|
|
||||||
sources_list = await async_get_sources(self.host, self.key)
|
sources_list = await async_get_sources(self.host, self.key)
|
||||||
if not sources_list:
|
if not sources_list:
|
||||||
errors["base"] = "cannot_retrieve"
|
errors["base"] = "cannot_retrieve"
|
||||||
|
|
||||||
|
sources = [s for s in self.options.get(CONF_SOURCES, []) if s in sources_list]
|
||||||
|
if not sources:
|
||||||
|
sources = sources_list
|
||||||
|
|
||||||
options_schema = vol.Schema(
|
options_schema = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Optional(
|
vol.Optional(
|
||||||
@ -204,7 +207,11 @@ async def async_get_sources(host: str, key: str) -> list[str]:
|
|||||||
except WEBOSTV_EXCEPTIONS:
|
except WEBOSTV_EXCEPTIONS:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
return [
|
return list(
|
||||||
|
dict.fromkeys( # Preserve order when filtering duplicates
|
||||||
|
[
|
||||||
*(app["title"] for app in client.apps.values()),
|
*(app["title"] for app in client.apps.values()),
|
||||||
*(app["label"] for app in client.inputs.values()),
|
*(app["label"] for app in client.inputs.values()),
|
||||||
]
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user