Strip out deleted entities when configuring homekit (#59844)
This commit is contained in:
parent
8fb84270d5
commit
0fb21af07f
2 changed files with 91 additions and 11 deletions
|
@ -330,13 +330,19 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
|||
return self.async_create_entry(title="", data=self.hk_options)
|
||||
|
||||
all_supported_devices = await _async_get_supported_devices(self.hass)
|
||||
# Strip out devices that no longer exist to prevent error in the UI
|
||||
devices = [
|
||||
device_id
|
||||
for device_id in self.hk_options.get(CONF_DEVICES, [])
|
||||
if device_id in all_supported_devices
|
||||
]
|
||||
return self.async_show_form(
|
||||
step_id="advanced",
|
||||
data_schema=vol.Schema(
|
||||
{
|
||||
vol.Optional(
|
||||
CONF_DEVICES, default=self.hk_options.get(CONF_DEVICES, [])
|
||||
): cv.multi_select(all_supported_devices)
|
||||
vol.Optional(CONF_DEVICES, default=devices): cv.multi_select(
|
||||
all_supported_devices
|
||||
)
|
||||
}
|
||||
),
|
||||
)
|
||||
|
@ -445,13 +451,16 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
|||
)
|
||||
|
||||
data_schema = {}
|
||||
entities = entity_filter.get(CONF_INCLUDE_ENTITIES, [])
|
||||
if self.hk_options[CONF_HOMEKIT_MODE] == HOMEKIT_MODE_ACCESSORY:
|
||||
entity_schema = vol.In
|
||||
else:
|
||||
if entities:
|
||||
include_exclude_mode = MODE_INCLUDE
|
||||
else:
|
||||
entity_schema = vol.In
|
||||
# Strip out entities that no longer exist to prevent error in the UI
|
||||
entities = [
|
||||
entity_id
|
||||
for entity_id in entity_filter.get(CONF_INCLUDE_ENTITIES, [])
|
||||
if entity_id in all_supported_entities
|
||||
]
|
||||
if self.hk_options[CONF_HOMEKIT_MODE] != HOMEKIT_MODE_ACCESSORY:
|
||||
include_exclude_mode = MODE_INCLUDE
|
||||
if not entities:
|
||||
include_exclude_mode = MODE_EXCLUDE
|
||||
entities = entity_filter.get(CONF_EXCLUDE_ENTITIES, [])
|
||||
data_schema[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue