diff --git a/homeassistant/components/config/__init__.py b/homeassistant/components/config/__init__.py index 05e5d3b9a2d..38259099b7a 100644 --- a/homeassistant/components/config/__init__.py +++ b/homeassistant/components/config/__init__.py @@ -26,6 +26,7 @@ from homeassistant.util.yaml.loader import JSON_TYPE _DataT = TypeVar("_DataT", dict[str, dict[str, Any]], list[dict[str, Any]]) DOMAIN = "config" + SECTIONS = ( "area_registry", "auth", @@ -50,24 +51,13 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: hass, "config", "config", "hass:cog", require_admin=True ) - async def setup_panel(panel_name: str) -> None: - """Set up a panel.""" + for panel_name in SECTIONS: panel = importlib.import_module(f".{panel_name}", __name__) - if not panel: - return - - success = await panel.async_setup(hass) - - if success: + if panel.async_setup(hass): key = f"{DOMAIN}.{panel_name}" hass.bus.async_fire(EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: key}) - tasks = [asyncio.create_task(setup_panel(panel_name)) for panel_name in SECTIONS] - - if tasks: - await asyncio.wait(tasks) - return True diff --git a/homeassistant/components/config/area_registry.py b/homeassistant/components/config/area_registry.py index c8dc7450183..31841717109 100644 --- a/homeassistant/components/config/area_registry.py +++ b/homeassistant/components/config/area_registry.py @@ -10,7 +10,8 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.area_registry import AreaEntry, async_get -async def async_setup(hass: HomeAssistant) -> bool: +@callback +def async_setup(hass: HomeAssistant) -> bool: """Enable the Area Registry views.""" websocket_api.async_register_command(hass, websocket_list_areas) websocket_api.async_register_command(hass, websocket_create_area) diff --git a/homeassistant/components/config/auth.py b/homeassistant/components/config/auth.py index 355dc739a9c..0409bf0f0f4 100644 --- a/homeassistant/components/config/auth.py +++ b/homeassistant/components/config/auth.py @@ -7,7 +7,7 @@ import voluptuous as vol from homeassistant.auth.models import User from homeassistant.components import websocket_api -from homeassistant.core import HomeAssistant +from homeassistant.core import HomeAssistant, callback WS_TYPE_LIST = "config/auth/list" SCHEMA_WS_LIST = websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend( @@ -20,7 +20,8 @@ SCHEMA_WS_DELETE = websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend( ) -async def async_setup(hass: HomeAssistant) -> bool: +@callback +def async_setup(hass: HomeAssistant) -> bool: """Enable the Home Assistant views.""" websocket_api.async_register_command( hass, WS_TYPE_LIST, websocket_list, SCHEMA_WS_LIST diff --git a/homeassistant/components/config/auth_provider_homeassistant.py b/homeassistant/components/config/auth_provider_homeassistant.py index c8b7e91f5a7..0c58cad536e 100644 --- a/homeassistant/components/config/auth_provider_homeassistant.py +++ b/homeassistant/components/config/auth_provider_homeassistant.py @@ -7,11 +7,12 @@ import voluptuous as vol from homeassistant.auth.providers import homeassistant as auth_ha from homeassistant.components import websocket_api -from homeassistant.core import HomeAssistant +from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import Unauthorized -async def async_setup(hass: HomeAssistant) -> bool: +@callback +def async_setup(hass: HomeAssistant) -> bool: """Enable the Home Assistant views.""" websocket_api.async_register_command(hass, websocket_create) websocket_api.async_register_command(hass, websocket_delete) diff --git a/homeassistant/components/config/automation.py b/homeassistant/components/config/automation.py index 02131fe2169..cf637b0aa23 100644 --- a/homeassistant/components/config/automation.py +++ b/homeassistant/components/config/automation.py @@ -11,13 +11,14 @@ from homeassistant.components.automation.config import ( ) from homeassistant.config import AUTOMATION_CONFIG_PATH from homeassistant.const import CONF_ID, SERVICE_RELOAD -from homeassistant.core import HomeAssistant +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import config_validation as cv, entity_registry as er from . import ACTION_DELETE, EditIdBasedConfigView -async def async_setup(hass: HomeAssistant) -> bool: +@callback +def async_setup(hass: HomeAssistant) -> bool: """Set up the Automation config API.""" async def hook(action: str, config_key: str) -> None: diff --git a/homeassistant/components/config/config_entries.py b/homeassistant/components/config/config_entries.py index 79d1320ba52..36a26311bce 100644 --- a/homeassistant/components/config/config_entries.py +++ b/homeassistant/components/config/config_entries.py @@ -30,7 +30,8 @@ from homeassistant.loader import ( ) -async def async_setup(hass: HomeAssistant) -> bool: +@callback +def async_setup(hass: HomeAssistant) -> bool: """Enable the Home Assistant views.""" hass.http.register_view(ConfigManagerEntryIndexView) hass.http.register_view(ConfigManagerEntryResourceView) diff --git a/homeassistant/components/config/core.py b/homeassistant/components/config/core.py index e6eac5f6e8e..c3e070a3751 100644 --- a/homeassistant/components/config/core.py +++ b/homeassistant/components/config/core.py @@ -9,13 +9,14 @@ import voluptuous as vol from homeassistant.components import websocket_api from homeassistant.components.http import HomeAssistantView, require_admin from homeassistant.components.sensor import async_update_suggested_units -from homeassistant.core import HomeAssistant +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import check_config, config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.util import location, unit_system -async def async_setup(hass: HomeAssistant) -> bool: +@callback +def async_setup(hass: HomeAssistant) -> bool: """Set up the Hassbian config.""" hass.http.register_view(CheckConfigView) websocket_api.async_register_command(hass, websocket_update_config) diff --git a/homeassistant/components/config/device_registry.py b/homeassistant/components/config/device_registry.py index aa861a515fd..7bd76310929 100644 --- a/homeassistant/components/config/device_registry.py +++ b/homeassistant/components/config/device_registry.py @@ -17,7 +17,8 @@ from homeassistant.helpers.device_registry import ( ) -async def async_setup(hass: HomeAssistant) -> bool: +@callback +def async_setup(hass: HomeAssistant) -> bool: """Enable the Device Registry views.""" websocket_api.async_register_command(hass, websocket_list_devices) diff --git a/homeassistant/components/config/entity_registry.py b/homeassistant/components/config/entity_registry.py index 11a4617adfa..66a1ceeba69 100644 --- a/homeassistant/components/config/entity_registry.py +++ b/homeassistant/components/config/entity_registry.py @@ -18,7 +18,8 @@ from homeassistant.helpers import ( from homeassistant.helpers.json import json_dumps -async def async_setup(hass: HomeAssistant) -> bool: +@callback +def async_setup(hass: HomeAssistant) -> bool: """Enable the Entity Registry views.""" websocket_api.async_register_command(hass, websocket_get_entities) diff --git a/homeassistant/components/config/scene.py b/homeassistant/components/config/scene.py index efbfd73db05..01bdce0c8bc 100644 --- a/homeassistant/components/config/scene.py +++ b/homeassistant/components/config/scene.py @@ -7,13 +7,14 @@ import uuid from homeassistant.components.scene import DOMAIN, PLATFORM_SCHEMA from homeassistant.config import SCENE_CONFIG_PATH from homeassistant.const import CONF_ID, SERVICE_RELOAD -from homeassistant.core import DOMAIN as HA_DOMAIN, HomeAssistant +from homeassistant.core import DOMAIN as HA_DOMAIN, HomeAssistant, callback from homeassistant.helpers import config_validation as cv, entity_registry as er from . import ACTION_DELETE, EditIdBasedConfigView -async def async_setup(hass: HomeAssistant) -> bool: +@callback +def async_setup(hass: HomeAssistant) -> bool: """Set up the Scene config API.""" async def hook(action: str, config_key: str) -> None: diff --git a/homeassistant/components/config/script.py b/homeassistant/components/config/script.py index aa8a2a52d83..d181ad94286 100644 --- a/homeassistant/components/config/script.py +++ b/homeassistant/components/config/script.py @@ -10,13 +10,14 @@ from homeassistant.components.script.config import ( ) from homeassistant.config import SCRIPT_CONFIG_PATH from homeassistant.const import SERVICE_RELOAD -from homeassistant.core import HomeAssistant +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import config_validation as cv, entity_registry as er from . import ACTION_DELETE, EditKeyBasedConfigView -async def async_setup(hass: HomeAssistant) -> bool: +@callback +def async_setup(hass: HomeAssistant) -> bool: """Set up the script config API.""" async def hook(action: str, config_key: str) -> None: diff --git a/tests/components/config/test_area_registry.py b/tests/components/config/test_area_registry.py index 1d1e14173f7..5fa22a06e51 100644 --- a/tests/components/config/test_area_registry.py +++ b/tests/components/config/test_area_registry.py @@ -10,10 +10,10 @@ from tests.common import ANY @pytest.fixture -def client(hass, hass_ws_client): +async def client(hass, hass_ws_client): """Fixture that can interact with the config manager API.""" - hass.loop.run_until_complete(area_registry.async_setup(hass)) - return hass.loop.run_until_complete(hass_ws_client(hass)) + area_registry.async_setup(hass) + return await hass_ws_client(hass) async def test_list_areas( diff --git a/tests/components/config/test_auth.py b/tests/components/config/test_auth.py index c85b9ba3b0f..21ca81e74ac 100644 --- a/tests/components/config/test_auth.py +++ b/tests/components/config/test_auth.py @@ -10,9 +10,9 @@ from tests.typing import WebSocketGenerator @pytest.fixture(autouse=True) -def setup_config(hass, aiohttp_client): +async def setup_config(hass, aiohttp_client): """Fixture that sets up the auth provider homeassistant module.""" - hass.loop.run_until_complete(auth_config.async_setup(hass)) + auth_config.async_setup(hass) async def test_list_requires_admin( diff --git a/tests/components/config/test_auth_provider_homeassistant.py b/tests/components/config/test_auth_provider_homeassistant.py index e28bdbf9a81..a8d5a1a23fd 100644 --- a/tests/components/config/test_auth_provider_homeassistant.py +++ b/tests/components/config/test_auth_provider_homeassistant.py @@ -14,7 +14,7 @@ from tests.typing import WebSocketGenerator @pytest.fixture(autouse=True) async def setup_config(hass, local_auth): """Fixture that sets up the auth provider .""" - await auth_ha.async_setup(hass) + auth_ha.async_setup(hass) @pytest.fixture diff --git a/tests/components/config/test_config_entries.py b/tests/components/config/test_config_entries.py index dbdc113e9e3..844b4bdb3b4 100644 --- a/tests/components/config/test_config_entries.py +++ b/tests/components/config/test_config_entries.py @@ -42,7 +42,7 @@ def mock_test_component(hass): async def client(hass, hass_client): """Fixture that can interact with the config manager API.""" await async_setup_component(hass, "http", {}) - await config_entries.async_setup(hass) + config_entries.async_setup(hass) return await hass_client() diff --git a/tests/components/config/test_device_registry.py b/tests/components/config/test_device_registry.py index 4a784a6eff1..5f0c423fc21 100644 --- a/tests/components/config/test_device_registry.py +++ b/tests/components/config/test_device_registry.py @@ -16,10 +16,10 @@ def stub_blueprint_populate_autouse(stub_blueprint_populate: None) -> None: @pytest.fixture -def client(hass, hass_ws_client): +async def client(hass, hass_ws_client): """Fixture that can interact with the config manager API.""" - hass.loop.run_until_complete(device_registry.async_setup(hass)) - return hass.loop.run_until_complete(hass_ws_client(hass)) + device_registry.async_setup(hass) + return await hass_ws_client(hass) async def test_list_devices( diff --git a/tests/components/config/test_entity_registry.py b/tests/components/config/test_entity_registry.py index 46af23a6d1f..ab125651729 100644 --- a/tests/components/config/test_entity_registry.py +++ b/tests/components/config/test_entity_registry.py @@ -30,7 +30,7 @@ async def client( hass: HomeAssistant, hass_ws_client: WebSocketGenerator ) -> MockHAClientWebSocket: """Fixture that can interact with the config manager API.""" - await entity_registry.async_setup(hass) + entity_registry.async_setup(hass) return await hass_ws_client(hass)