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,
|
FlowManagerIndexView,
|
||||||
FlowManagerResourceView,
|
FlowManagerResourceView,
|
||||||
)
|
)
|
||||||
from homeassistant.loader import async_get_config_flows
|
from homeassistant.loader import Integration, async_get_config_flows
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass):
|
async def async_setup(hass):
|
||||||
|
@ -63,19 +63,33 @@ class ConfigManagerEntryIndexView(HomeAssistantView):
|
||||||
integrations = {}
|
integrations = {}
|
||||||
type_filter = request.query["type"]
|
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
|
# Fetch all the integrations so we can check their type
|
||||||
for integration in await asyncio.gather(
|
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}
|
for domain in {entry.domain for entry in entries}
|
||||||
)
|
)
|
||||||
):
|
):
|
||||||
integrations[integration.domain] = integration
|
if integration:
|
||||||
|
integrations[integration.domain] = integration
|
||||||
|
|
||||||
entries = [
|
entries = [
|
||||||
entry
|
entry
|
||||||
for entry in entries
|
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])
|
return self.json([entry_json(entry) for entry in entries])
|
||||||
|
|
Loading…
Reference in New Issue