mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Fix saving options with missing ignored sources in BraviaTV (#83891)
fix https://github.com/home-assistant/core/issues/83217 fixes undefined
This commit is contained in:
parent
aa23a125bf
commit
e32074c74e
@ -264,6 +264,12 @@ class BraviaTVOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry):
|
||||
|
||||
sources = coordinator.source_map.values()
|
||||
source_list = [item["title"] for item in sources]
|
||||
ignored_sources = self.options.get(CONF_IGNORED_SOURCES, [])
|
||||
|
||||
for item in ignored_sources:
|
||||
if item not in source_list:
|
||||
source_list.append(item)
|
||||
|
||||
self.data_schema = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_IGNORED_SOURCES): cv.multi_select(source_list),
|
||||
|
@ -422,6 +422,19 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert config_entry.options == {CONF_IGNORED_SOURCES: ["HDMI 1", "HDMI 2"]}
|
||||
|
||||
# Test that saving with missing sources is ok
|
||||
with patch(
|
||||
"pybravia.BraviaTV.get_external_status",
|
||||
return_value=BRAVIA_SOURCES[1:],
|
||||
):
|
||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"], user_input={CONF_IGNORED_SOURCES: ["HDMI 1"]}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert config_entry.options == {CONF_IGNORED_SOURCES: ["HDMI 1"]}
|
||||
|
||||
|
||||
async def test_options_flow_error(hass: HomeAssistant) -> None:
|
||||
"""Test config flow options."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user