Handle config entries of integrations that are removed (#68928)
parent
217d98e008
commit
89daf4f96b
|
@ -18,7 +18,7 @@ from homeassistant.helpers.data_entry_flow import (
|
|||
FlowManagerIndexView,
|
||||
FlowManagerResourceView,
|
||||
)
|
||||
from homeassistant.loader import async_get_config_flows
|
||||
from homeassistant.loader import Integration, async_get_config_flows
|
||||
|
||||
|
||||
async def async_setup(hass):
|
||||
|
@ -63,19 +63,33 @@ class ConfigManagerEntryIndexView(HomeAssistantView):
|
|||
integrations = {}
|
||||
type_filter = request.query["type"]
|
||||
|
||||
async def load_integration(
|
||||
hass: HomeAssistant, domain: str
|
||||
) -> Integration | None:
|
||||
"""Load integration."""
|
||||
try:
|
||||
return await loader.async_get_integration(hass, domain)
|
||||
except loader.IntegrationNotFound:
|
||||
return None
|
||||
|
||||
# Fetch all the integrations so we can check their type
|
||||
for integration in await asyncio.gather(
|
||||
*(
|
||||
loader.async_get_integration(hass, domain)
|
||||
load_integration(hass, domain)
|
||||
for domain in {entry.domain for entry in entries}
|
||||
)
|
||||
):
|
||||
integrations[integration.domain] = integration
|
||||
if integration:
|
||||
integrations[integration.domain] = integration
|
||||
|
||||
entries = [
|
||||
entry
|
||||
for entry in entries
|
||||
if integrations[entry.domain].integration_type == type_filter
|
||||
if (type_filter != "helper" and entry.domain not in integrations)
|
||||
or (
|
||||
entry.domain in integrations
|
||||
and integrations[entry.domain].integration_type == type_filter
|
||||
)
|
||||
]
|
||||
|
||||
return self.json([entry_json(entry) for entry in entries])
|
||||
|
|
Loading…
Reference in New Issue