diff --git a/custom_components/hacs/__init__.py b/custom_components/hacs/__init__.py index 755ec25d9ed..6fa1b95e6e6 100644 --- a/custom_components/hacs/__init__.py +++ b/custom_components/hacs/__init__.py @@ -7,7 +7,6 @@ from __future__ import annotations import os -from typing import Any from aiogithubapi import AIOGitHubAPIException, GitHub, GitHubAPI from aiogithubapi.const import ACCEPT_HEADERS @@ -19,7 +18,6 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.discovery import async_load_platform from homeassistant.helpers.event import async_call_later -from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue from homeassistant.helpers.start import async_at_start from homeassistant.loader import async_get_integration import voluptuous as vol @@ -29,52 +27,33 @@ from .data_client import HacsDataClient from .enums import ConfigurationType, HacsDisabledReason, HacsStage, LovelaceMode from .frontend import async_register_frontend -from .utils.configuration_schema import hacs_config_combined from .utils.data import HacsData -from .utils.logger import LOGGER from .utils.queue_manager import QueueManager from .utils.version import version_left_higher_or_equal_then_right from .websocket import async_register_websocket_commands -CONFIG_SCHEMA = vol.Schema({DOMAIN: hacs_config_combined()}, extra=vol.ALLOW_EXTRA) - -async def async_initialize_integration( +async def _async_initialize_integration( hass: HomeAssistant, - *, - config_entry: ConfigEntry | None = None, - config: dict[str, Any] | None = None, + config_entry: ConfigEntry, ) -> bool: """Initialize the integration""" hass.data[DOMAIN] = hacs = HacsBase() hacs.enable_hacs() - if config is not None: - if DOMAIN not in config: - return True - if hacs.configuration.config_type == ConfigurationType.CONFIG_ENTRY: - return True - hacs.configuration.update_from_dict( - { - "config_type": ConfigurationType.YAML, - **config[DOMAIN], - "config": config[DOMAIN], - } - ) - - if config_entry is not None: - if config_entry.source == SOURCE_IMPORT: - hass.async_create_task(hass.config_entries.async_remove(config_entry.entry_id)) - return False + if config_entry.source == SOURCE_IMPORT: + # Import is not supported + hass.async_create_task(hass.config_entries.async_remove(config_entry.entry_id)) + return False - hacs.configuration.update_from_dict( - { - "config_entry": config_entry, - "config_type": ConfigurationType.CONFIG_ENTRY, - **config_entry.data, - **config_entry.options, - } - ) + hacs.configuration.update_from_dict( + { + "config_entry": config_entry, + "config_type": ConfigurationType.CONFIG_ENTRY, + **config_entry.data, + **config_entry.options, + } + ) integration = await async_get_integration(hass, DOMAIN) @@ -217,33 +196,10 @@ async def async_try_startup(_=None): return True -async def async_setup(hass: HomeAssistant, config: dict[str, Any]) -> bool: - """Set up this integration using yaml.""" - if DOMAIN in config: - async_create_issue( - hass, - DOMAIN, - "deprecated_yaml_configuration", - is_fixable=False, - issue_domain=DOMAIN, - severity=IssueSeverity.WARNING, - translation_key="deprecated_yaml_configuration", - learn_more_url="https://hacs.xyz/docs/configuration/options", - ) - LOGGER.warning( - "YAML configuration of HACS is deprecated and will be " - "removed in version 2.0.0, there will be no automatic " - "import of this. " - "Please remove it from your configuration, " - "restart Home Assistant and use the UI to configure it instead." - ) - return await async_initialize_integration(hass=hass, config=config) - - async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up this integration using UI.""" config_entry.async_on_unload(config_entry.add_update_listener(async_reload_entry)) - setup_result = await async_initialize_integration(hass=hass, config_entry=config_entry) + setup_result = await _async_initialize_integration(hass=hass, config_entry=config_entry) hacs: HacsBase = hass.data[DOMAIN] return setup_result and not hacs.system.disabled diff --git a/custom_components/hacs/diagnostics.py b/custom_components/hacs/diagnostics.py index f2991bd8886..2834bb40ccd 100644 --- a/custom_components/hacs/diagnostics.py +++ b/custom_components/hacs/diagnostics.py @@ -10,7 +10,6 @@ from .base import HacsBase from .const import DOMAIN -from .utils.configuration_schema import TOKEN async def async_get_config_entry_diagnostics( @@ -79,4 +78,4 @@ async def async_get_config_entry_diagnostics( except GitHubException as exception: data["rate_limit"] = str(exception) - return async_redact_data(data, (TOKEN,)) + return async_redact_data(data, ("token",)) diff --git a/custom_components/hacs/translations/en.json b/custom_components/hacs/translations/en.json index ef4b3ed5acb..79272b01010 100644 --- a/custom_components/hacs/translations/en.json +++ b/custom_components/hacs/translations/en.json @@ -71,10 +71,6 @@ "removed": { "title": "Repository removed from HACS", "description": "Because {reason}, `{name}` has been removed from HACS. Please visit the [HACS Panel](/hacs/repository/{repositry_id}) to remove it." - }, - "deprecated_yaml_configuration": { - "title": "YAML configuration is deprecated", - "description": "YAML configuration of HACS is deprecated and will be removed in version 2.0.0, there will be no automatic import of this.\nPlease remove it from your configuration, restart Home Assistant and use the UI to configure it instead." } } } \ No newline at end of file diff --git a/custom_components/hacs/utils/configuration_schema.py b/custom_components/hacs/utils/configuration_schema.py index 268fc4ce64d..b015e715346 100644 --- a/custom_components/hacs/utils/configuration_schema.py +++ b/custom_components/hacs/utils/configuration_schema.py @@ -1,15 +1,8 @@ """HACS Configuration Schemas.""" -# pylint: disable=dangerous-default-value -import voluptuous as vol - -from ..const import LOCALE # Configuration: -TOKEN = "token" SIDEPANEL_TITLE = "sidepanel_title" SIDEPANEL_ICON = "sidepanel_icon" -FRONTEND_REPO = "frontend_repo" -FRONTEND_REPO_URL = "frontend_repo_url" APPDAEMON = "appdaemon" NETDAEMON = "netdaemon" @@ -18,57 +11,3 @@ DEBUG = "debug" RELEASE_LIMIT = "release_limit" EXPERIMENTAL = "experimental" - -# Config group -PATH_OR_URL = "frontend_repo_path_or_url" - - -def hacs_base_config_schema(config: dict = {}) -> dict: - """Return a shcema configuration dict for HACS.""" - if not config: - config = { - TOKEN: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", - } - return { - vol.Required(TOKEN, default=config.get(TOKEN)): str, - } - - -def hacs_config_option_schema(options: dict = {}) -> dict: - """Return a shcema for HACS configuration options.""" - if not options: - options = { - APPDAEMON: False, - COUNTRY: "ALL", - DEBUG: False, - EXPERIMENTAL: False, - NETDAEMON: False, - RELEASE_LIMIT: 5, - SIDEPANEL_ICON: "hacs:hacs", - SIDEPANEL_TITLE: "HACS", - FRONTEND_REPO: "", - FRONTEND_REPO_URL: "", - } - return { - vol.Optional(SIDEPANEL_TITLE, default=options.get(SIDEPANEL_TITLE)): str, - vol.Optional(SIDEPANEL_ICON, default=options.get(SIDEPANEL_ICON)): str, - vol.Optional(RELEASE_LIMIT, default=options.get(RELEASE_LIMIT)): int, - vol.Optional(COUNTRY, default=options.get(COUNTRY)): vol.In(LOCALE), - vol.Optional(APPDAEMON, default=options.get(APPDAEMON)): bool, - vol.Optional(NETDAEMON, default=options.get(NETDAEMON)): bool, - vol.Optional(DEBUG, default=options.get(DEBUG)): bool, - vol.Optional(EXPERIMENTAL, default=options.get(EXPERIMENTAL)): bool, - vol.Exclusive(FRONTEND_REPO, PATH_OR_URL): str, - vol.Exclusive(FRONTEND_REPO_URL, PATH_OR_URL): str, - } - - -def hacs_config_combined() -> dict: - """Combine the configuration options.""" - base = hacs_base_config_schema() - options = hacs_config_option_schema() - - for option in options: - base[option] = options[option] - - return base diff --git a/tests/common.py b/tests/common.py index 84f9a364323..8dc0d3f2ead 100644 --- a/tests/common.py +++ b/tests/common.py @@ -45,7 +45,6 @@ from custom_components.hacs.const import DOMAIN from custom_components.hacs.enums import HacsCategory from custom_components.hacs.repositories.base import HacsManifest, HacsRepository -from custom_components.hacs.utils.configuration_schema import TOKEN as CONF_TOKEN from custom_components.hacs.utils.logger import LOGGER TOKEN = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -844,7 +843,7 @@ def create_config_entry( minor_version=0, domain=DOMAIN, title="", - data={CONF_TOKEN: TOKEN, **(data or {})}, + data={"token": TOKEN, **(data or {})}, source="user", options={**(options or {})}, unique_id="12345", @@ -854,7 +853,7 @@ def create_config_entry( version=1, domain=DOMAIN, title="", - data={CONF_TOKEN: TOKEN, **(data or {})}, + data={"token": TOKEN, **(data or {})}, source="user", options={**(options or {})}, unique_id="12345",