Update homekit to use async_get_integrations (#88550)
This commit is contained in:
parent
8806c3dd20
commit
906d397736
1 changed files with 8 additions and 12 deletions
|
@ -1,7 +1,6 @@
|
||||||
"""Config flow for HomeKit integration."""
|
"""Config flow for HomeKit integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from collections.abc import Iterable
|
from collections.abc import Iterable
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import random
|
import random
|
||||||
|
@ -37,7 +36,7 @@ from homeassistant.helpers.entityfilter import (
|
||||||
CONF_INCLUDE_DOMAINS,
|
CONF_INCLUDE_DOMAINS,
|
||||||
CONF_INCLUDE_ENTITIES,
|
CONF_INCLUDE_ENTITIES,
|
||||||
)
|
)
|
||||||
from homeassistant.loader import async_get_integration
|
from homeassistant.loader import async_get_integrations
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_ENTITY_CONFIG,
|
CONF_ENTITY_CONFIG,
|
||||||
|
@ -163,17 +162,14 @@ def _async_cameras_from_entities(entities: list[str]) -> dict[str, str]:
|
||||||
|
|
||||||
async def _async_name_to_type_map(hass: HomeAssistant) -> dict[str, str]:
|
async def _async_name_to_type_map(hass: HomeAssistant) -> dict[str, str]:
|
||||||
"""Create a mapping of types of devices/entities HomeKit can support."""
|
"""Create a mapping of types of devices/entities HomeKit can support."""
|
||||||
integrations = await asyncio.gather(
|
integrations = await async_get_integrations(hass, SUPPORTED_DOMAINS)
|
||||||
*(async_get_integration(hass, domain) for domain in SUPPORTED_DOMAINS),
|
return {
|
||||||
return_exceptions=True,
|
domain: integration_or_exception.name
|
||||||
)
|
if (integration_or_exception := integrations[domain])
|
||||||
name_to_type_map = {
|
and not isinstance(integration_or_exception, Exception)
|
||||||
domain: domain
|
else domain
|
||||||
if isinstance(integrations[idx], Exception)
|
for domain in SUPPORTED_DOMAINS
|
||||||
else integrations[idx].name
|
|
||||||
for idx, domain in enumerate(SUPPORTED_DOMAINS)
|
|
||||||
}
|
}
|
||||||
return name_to_type_map
|
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue