diff --git a/homeassistant/components/neato/__init__.py b/homeassistant/components/neato/__init__.py index 196961652f0..b172d84533c 100644 --- a/homeassistant/components/neato/__init__.py +++ b/homeassistant/components/neato/__init__.py @@ -4,42 +4,19 @@ import logging import aiohttp from pybotvac import Account from pybotvac.exceptions import NeatoException -import voluptuous as vol -from homeassistant.components.application_credentials import ( - ClientCredential, - async_import_client_credential, -) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, CONF_TOKEN, Platform -from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant +from homeassistant.const import CONF_TOKEN, Platform +from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady -from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv -from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue -from homeassistant.helpers.typing import ConfigType +from homeassistant.helpers import config_entry_oauth2_flow from . import api -from .const import NEATO_CONFIG, NEATO_DOMAIN, NEATO_LOGIN +from .const import NEATO_DOMAIN, NEATO_LOGIN from .hub import NeatoHub _LOGGER = logging.getLogger(__name__) - -CONFIG_SCHEMA = vol.Schema( - vol.All( - cv.deprecated(NEATO_DOMAIN), - { - NEATO_DOMAIN: vol.Schema( - { - vol.Required(CONF_CLIENT_ID): cv.string, - vol.Required(CONF_CLIENT_SECRET): cv.string, - } - ) - }, - ), - extra=vol.ALLOW_EXTRA, -) - PLATFORMS = [ Platform.BUTTON, Platform.CAMERA, @@ -49,49 +26,9 @@ PLATFORMS = [ ] -async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Set up the Neato component.""" - hass.data[NEATO_DOMAIN] = {} - - if NEATO_DOMAIN not in config: - return True - - hass.data[NEATO_CONFIG] = config[NEATO_DOMAIN] - await async_import_client_credential( - hass, - NEATO_DOMAIN, - ClientCredential( - config[NEATO_DOMAIN][CONF_CLIENT_ID], - config[NEATO_DOMAIN][CONF_CLIENT_SECRET], - ), - ) - _LOGGER.warning( - "Configuration of Neato integration in YAML is deprecated and " - "will be removed in a future release; Your existing OAuth " - "Application Credentials have been imported into the UI " - "automatically and can be safely removed from your " - "configuration.yaml file" - ) - async_create_issue( - hass, - HOMEASSISTANT_DOMAIN, - f"deprecated_yaml_{NEATO_DOMAIN}", - breaks_in_ha_version="2024.2.0", - is_fixable=False, - issue_domain=NEATO_DOMAIN, - severity=IssueSeverity.WARNING, - translation_key="deprecated_yaml", - translation_placeholders={ - "domain": NEATO_DOMAIN, - "integration_title": "Neato Botvac", - }, - ) - - return True - - async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up config entry.""" + hass.data.setdefault(NEATO_DOMAIN, {}) if CONF_TOKEN not in entry.data: raise ConfigEntryAuthFailed diff --git a/homeassistant/components/neato/const.py b/homeassistant/components/neato/const.py index 0cd8fb932ce..4ec894179ea 100644 --- a/homeassistant/components/neato/const.py +++ b/homeassistant/components/neato/const.py @@ -3,7 +3,6 @@ NEATO_DOMAIN = "neato" CONF_VENDOR = "vendor" -NEATO_CONFIG = "neato_config" NEATO_LOGIN = "neato_login" NEATO_MAP_DATA = "neato_map_data" NEATO_PERSISTENT_MAPS = "neato_persistent_maps" diff --git a/tests/components/neato/test_config_flow.py b/tests/components/neato/test_config_flow.py index 1e0ec5bb944..191721c2e74 100644 --- a/tests/components/neato/test_config_flow.py +++ b/tests/components/neato/test_config_flow.py @@ -4,6 +4,10 @@ from unittest.mock import patch from pybotvac.neato import Neato from homeassistant import config_entries, data_entry_flow, setup +from homeassistant.components.application_credentials import ( + ClientCredential, + async_import_client_credential, +) from homeassistant.components.neato.const import NEATO_DOMAIN from homeassistant.core import HomeAssistant from homeassistant.helpers import config_entry_oauth2_flow @@ -27,12 +31,9 @@ async def test_full_flow( current_request_with_host: None, ) -> None: """Check full flow.""" - assert await setup.async_setup_component( - hass, - "neato", - { - "neato": {"client_id": CLIENT_ID, "client_secret": CLIENT_SECRET}, - }, + assert await setup.async_setup_component(hass, "neato", {}) + await async_import_client_credential( + hass, NEATO_DOMAIN, ClientCredential(CLIENT_ID, CLIENT_SECRET) ) result = await hass.config_entries.flow.async_init( @@ -101,12 +102,9 @@ async def test_reauth( current_request_with_host: None, ) -> None: """Test initialization of the reauth flow.""" - assert await setup.async_setup_component( - hass, - "neato", - { - "neato": {"client_id": CLIENT_ID, "client_secret": CLIENT_SECRET}, - }, + assert await setup.async_setup_component(hass, "neato", {}) + await async_import_client_credential( + hass, NEATO_DOMAIN, ClientCredential(CLIENT_ID, CLIENT_SECRET) ) MockConfigEntry(