diff --git a/homeassistant/components/calendar/__init__.py b/homeassistant/components/calendar/__init__.py index c09f51d71e76..3cec3792612b 100644 --- a/homeassistant/components/calendar/__init__.py +++ b/homeassistant/components/calendar/__init__.py @@ -9,7 +9,7 @@ from typing import cast, final from aiohttp import web -from homeassistant.components import http +from homeassistant.components import frontend, http from homeassistant.config_entries import ConfigEntry from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant @@ -42,8 +42,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: hass.http.register_view(CalendarListView(component)) hass.http.register_view(CalendarEventView(component)) - hass.components.frontend.async_register_built_in_panel( - "calendar", "calendar", "hass:calendar" + frontend.async_register_built_in_panel( + hass, "calendar", "calendar", "hass:calendar" ) await component.async_setup(config) diff --git a/homeassistant/components/config/__init__.py b/homeassistant/components/config/__init__.py index e413b2141879..772f7376acca 100644 --- a/homeassistant/components/config/__init__.py +++ b/homeassistant/components/config/__init__.py @@ -6,6 +6,7 @@ import os import voluptuous as vol +from homeassistant.components import frontend from homeassistant.components.http import HomeAssistantView from homeassistant.const import CONF_ID, EVENT_COMPONENT_LOADED from homeassistant.core import HomeAssistant, callback @@ -35,8 +36,8 @@ ACTION_DELETE = "delete" async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the config component.""" - hass.components.frontend.async_register_built_in_panel( - "config", "config", "hass:cog", require_admin=True + frontend.async_register_built_in_panel( + hass, "config", "config", "hass:cog", require_admin=True ) async def setup_panel(panel_name): diff --git a/homeassistant/components/hassio/addon_panel.py b/homeassistant/components/hassio/addon_panel.py index 41107a6fa55a..4f7b24d8a85a 100644 --- a/homeassistant/components/hassio/addon_panel.py +++ b/homeassistant/components/hassio/addon_panel.py @@ -5,6 +5,7 @@ import logging from aiohttp import web +from homeassistant.components import frontend from homeassistant.components.http import HomeAssistantView from homeassistant.const import ATTR_ICON from homeassistant.core import HomeAssistant @@ -62,7 +63,7 @@ class HassIOAddonPanel(HomeAssistantView): async def delete(self, request, addon): """Handle remove add-on panel requests.""" - self.hass.components.frontend.async_remove_panel(addon) + frontend.async_remove_panel(self.hass, addon) return web.Response() async def get_panels(self): diff --git a/homeassistant/components/history/__init__.py b/homeassistant/components/history/__init__.py index 48a5204d2c05..1cbd18f44a70 100644 --- a/homeassistant/components/history/__init__.py +++ b/homeassistant/components/history/__init__.py @@ -12,7 +12,7 @@ from aiohttp import web from sqlalchemy import not_, or_ import voluptuous as vol -from homeassistant.components import websocket_api +from homeassistant.components import frontend, websocket_api from homeassistant.components.http import HomeAssistantView from homeassistant.components.recorder import history, models as history_models from homeassistant.components.recorder.statistics import ( @@ -98,9 +98,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: use_include_order = conf.get(CONF_ORDER) hass.http.register_view(HistoryPeriodView(filters, use_include_order)) - hass.components.frontend.async_register_built_in_panel( - "history", "history", "hass:chart-box" - ) + frontend.async_register_built_in_panel(hass, "history", "history", "hass:chart-box") websocket_api.async_register_command(hass, ws_get_statistics_during_period) websocket_api.async_register_command(hass, ws_get_list_statistic_ids) diff --git a/homeassistant/components/logbook/__init__.py b/homeassistant/components/logbook/__init__.py index f4724f793ecf..1af100397723 100644 --- a/homeassistant/components/logbook/__init__.py +++ b/homeassistant/components/logbook/__init__.py @@ -11,6 +11,7 @@ from sqlalchemy.orm import aliased from sqlalchemy.sql.expression import literal import voluptuous as vol +from homeassistant.components import frontend from homeassistant.components.automation import EVENT_AUTOMATION_TRIGGERED from homeassistant.components.history import sqlalchemy_filter_from_include_exclude_conf from homeassistant.components.http import HomeAssistantView @@ -154,8 +155,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: message = message.async_render(parse_result=False) async_log_entry(hass, name, message, domain, entity_id) - hass.components.frontend.async_register_built_in_panel( - "logbook", "logbook", "hass:format-list-bulleted-type" + frontend.async_register_built_in_panel( + hass, "logbook", "logbook", "hass:format-list-bulleted-type" ) if conf := config.get(DOMAIN, {}): diff --git a/homeassistant/components/mailbox/__init__.py b/homeassistant/components/mailbox/__init__.py index 1a5100123a5d..89b646beee48 100644 --- a/homeassistant/components/mailbox/__init__.py +++ b/homeassistant/components/mailbox/__init__.py @@ -11,6 +11,7 @@ from aiohttp import web from aiohttp.web_exceptions import HTTPNotFound import async_timeout +from homeassistant.components import frontend from homeassistant.components.http import HomeAssistantView from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import HomeAssistantError @@ -36,9 +37,7 @@ SCAN_INTERVAL = timedelta(seconds=30) async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Track states and offer events for mailboxes.""" mailboxes: list[Mailbox] = [] - hass.components.frontend.async_register_built_in_panel( - "mailbox", "mailbox", "mdi:mailbox" - ) + frontend.async_register_built_in_panel(hass, "mailbox", "mailbox", "mdi:mailbox") hass.http.register_view(MailboxPlatformsView(mailboxes)) hass.http.register_view(MailboxMessageView(mailboxes)) hass.http.register_view(MailboxMediaView(mailboxes)) diff --git a/homeassistant/components/map/__init__.py b/homeassistant/components/map/__init__.py index 0d8d0a2050a8..0ea1fbf2af93 100644 --- a/homeassistant/components/map/__init__.py +++ b/homeassistant/components/map/__init__.py @@ -1,4 +1,5 @@ """Support for showing device locations.""" +from homeassistant.components import frontend from homeassistant.core import HomeAssistant from homeassistant.helpers.typing import ConfigType @@ -7,7 +8,5 @@ DOMAIN = "map" async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Register the built-in map panel.""" - hass.components.frontend.async_register_built_in_panel( - "map", "map", "hass:tooltip-account" - ) + frontend.async_register_built_in_panel(hass, "map", "map", "hass:tooltip-account") return True diff --git a/homeassistant/components/media_source/__init__.py b/homeassistant/components/media_source/__init__.py index c73f517acd3d..717a4ad29d09 100644 --- a/homeassistant/components/media_source/__init__.py +++ b/homeassistant/components/media_source/__init__.py @@ -7,7 +7,7 @@ from urllib.parse import quote import voluptuous as vol -from homeassistant.components import websocket_api +from homeassistant.components import frontend, websocket_api from homeassistant.components.http.auth import async_sign_path from homeassistant.components.media_player.const import ATTR_MEDIA_CONTENT_ID from homeassistant.components.media_player.errors import BrowseError @@ -44,8 +44,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: hass.data[DOMAIN] = {} websocket_api.async_register_command(hass, websocket_browse_media) websocket_api.async_register_command(hass, websocket_resolve_media) - hass.components.frontend.async_register_built_in_panel( - "media-browser", "media_browser", "hass:play-box-multiple" + frontend.async_register_built_in_panel( + hass, "media-browser", "media_browser", "hass:play-box-multiple" ) local_source.async_setup(hass) await async_process_integration_platforms( diff --git a/homeassistant/components/my/__init__.py b/homeassistant/components/my/__init__.py index 4616571a2136..b547662d1889 100644 --- a/homeassistant/components/my/__init__.py +++ b/homeassistant/components/my/__init__.py @@ -1,4 +1,5 @@ """Support for my.home-assistant.io redirect service.""" +from homeassistant.components import frontend from homeassistant.core import HomeAssistant from homeassistant.helpers.typing import ConfigType @@ -8,7 +9,5 @@ URL_PATH = "_my_redirect" async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Register hidden _my_redirect panel.""" - hass.components.frontend.async_register_built_in_panel( - DOMAIN, frontend_url_path=URL_PATH - ) + frontend.async_register_built_in_panel(hass, DOMAIN, frontend_url_path=URL_PATH) return True diff --git a/homeassistant/components/panel_custom/__init__.py b/homeassistant/components/panel_custom/__init__.py index a7b3b2e30c88..d0ff0ad44a05 100644 --- a/homeassistant/components/panel_custom/__init__.py +++ b/homeassistant/components/panel_custom/__init__.py @@ -3,6 +3,7 @@ import logging import voluptuous as vol +from homeassistant.components import frontend from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.typing import ConfigType @@ -116,7 +117,8 @@ async def async_register_panel( config["_panel_custom"] = custom_panel_config - hass.components.frontend.async_register_built_in_panel( + frontend.async_register_built_in_panel( + hass, component_name="custom", sidebar_title=sidebar_title, sidebar_icon=sidebar_icon, diff --git a/homeassistant/components/panel_iframe/__init__.py b/homeassistant/components/panel_iframe/__init__.py index 8e2a98bc9803..8313bc4ba255 100644 --- a/homeassistant/components/panel_iframe/__init__.py +++ b/homeassistant/components/panel_iframe/__init__.py @@ -1,6 +1,7 @@ """Register an iFrame front end panel.""" import voluptuous as vol +from homeassistant.components import frontend from homeassistant.const import CONF_ICON, CONF_URL from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv @@ -40,7 +41,8 @@ CONFIG_SCHEMA = vol.Schema( async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the iFrame frontend panels.""" for url_path, info in config[DOMAIN].items(): - hass.components.frontend.async_register_built_in_panel( + frontend.async_register_built_in_panel( + hass, "iframe", info.get(CONF_TITLE), info.get(CONF_ICON), diff --git a/homeassistant/components/shopping_list/__init__.py b/homeassistant/components/shopping_list/__init__.py index 18fbb75e1754..5f6a13e8e13f 100644 --- a/homeassistant/components/shopping_list/__init__.py +++ b/homeassistant/components/shopping_list/__init__.py @@ -6,7 +6,7 @@ import uuid import voluptuous as vol from homeassistant import config_entries -from homeassistant.components import http, websocket_api +from homeassistant.components import frontend, http, websocket_api from homeassistant.components.http.data_validator import RequestDataValidator from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_NAME @@ -162,8 +162,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b hass.http.register_view(UpdateShoppingListItemView) hass.http.register_view(ClearCompletedItemsView) - hass.components.frontend.async_register_built_in_panel( - "shopping-list", "shopping_list", "mdi:cart" + frontend.async_register_built_in_panel( + hass, "shopping-list", "shopping_list", "mdi:cart" ) websocket_api.async_register_command(