diff --git a/homeassistant/components/config/config_entries.py b/homeassistant/components/config/config_entries.py index 39c5bce25cb4..88715ab876e4 100644 --- a/homeassistant/components/config/config_entries.py +++ b/homeassistant/components/config/config_entries.py @@ -1,7 +1,6 @@ """Http views to control the config manager.""" from __future__ import annotations -import asyncio from http import HTTPStatus from typing import Any @@ -26,6 +25,7 @@ from homeassistant.loader import ( IntegrationNotFound, async_get_config_flows, async_get_integration, + async_get_integrations, ) @@ -493,14 +493,12 @@ async def async_matching_config_entries( integrations = {} # Fetch all the integrations so we can check their type - tasks = ( - async_get_integration(hass, domain) - for domain in {entry.domain for entry in entries} - ) - results = await asyncio.gather(*tasks, return_exceptions=True) - for integration_or_exc in results: + domains = {entry.domain for entry in entries} + for domain_key, integration_or_exc in ( + await async_get_integrations(hass, domains) + ).items(): if isinstance(integration_or_exc, Integration): - integrations[integration_or_exc.domain] = integration_or_exc + integrations[domain_key] = integration_or_exc elif not isinstance(integration_or_exc, IntegrationNotFound): raise integration_or_exc diff --git a/tests/components/config/test_config_entries.py b/tests/components/config/test_config_entries.py index 396962900b13..cf8df6aef682 100644 --- a/tests/components/config/test_config_entries.py +++ b/tests/components/config/test_config_entries.py @@ -1446,8 +1446,8 @@ async def test_get_entries_ws( # Verify we skip broken integrations with patch( - "homeassistant.components.config.config_entries.async_get_integration", - side_effect=IntegrationNotFound("any"), + "homeassistant.components.config.config_entries.async_get_integrations", + return_value={"any": IntegrationNotFound("any")}, ): await ws_client.send_json( { @@ -1534,8 +1534,8 @@ async def test_get_entries_ws( # Verify we don't send config entries when only helpers are requested with patch( - "homeassistant.components.config.config_entries.async_get_integration", - side_effect=IntegrationNotFound("any"), + "homeassistant.components.config.config_entries.async_get_integrations", + return_value={"any": IntegrationNotFound("any")}, ): await ws_client.send_json( { @@ -1552,8 +1552,8 @@ async def test_get_entries_ws( # Verify we raise if something really goes wrong with patch( - "homeassistant.components.config.config_entries.async_get_integration", - side_effect=Exception, + "homeassistant.components.config.config_entries.async_get_integrations", + return_value={"any": Exception()}, ): await ws_client.send_json( {