From 0df4642b62b52fe3f0dd0a627fc4387aba729495 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 4 Aug 2022 21:03:26 +0200 Subject: [PATCH] Remove YAML configuration from Simplepush (#76175) --- .../components/simplepush/config_flow.py | 13 --------- homeassistant/components/simplepush/notify.py | 27 +++++-------------- .../components/simplepush/strings.json | 6 ++--- .../simplepush/translations/en.json | 6 ++--- .../components/simplepush/test_config_flow.py | 13 --------- 5 files changed, 12 insertions(+), 53 deletions(-) diff --git a/homeassistant/components/simplepush/config_flow.py b/homeassistant/components/simplepush/config_flow.py index cf08a341114..0f0073c5099 100644 --- a/homeassistant/components/simplepush/config_flow.py +++ b/homeassistant/components/simplepush/config_flow.py @@ -1,7 +1,6 @@ """Config flow for simplepush integration.""" from __future__ import annotations -import logging from typing import Any from simplepush import UnknownError, send, send_encrypted @@ -13,8 +12,6 @@ from homeassistant.data_entry_flow import FlowResult from .const import ATTR_ENCRYPTED, CONF_DEVICE_KEY, CONF_SALT, DEFAULT_NAME, DOMAIN -_LOGGER = logging.getLogger(__name__) - def validate_input(entry: dict[str, str]) -> dict[str, str] | None: """Validate user input.""" @@ -76,13 +73,3 @@ class SimplePushFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ), errors=errors, ) - - async def async_step_import(self, import_config: dict[str, str]) -> FlowResult: - """Import a config entry from configuration.yaml.""" - _LOGGER.warning( - "Configuration of the simplepush integration in YAML is deprecated and " - "will be removed in a future release; Your existing configuration " - "has been imported into the UI automatically and can be safely removed " - "from your configuration.yaml file" - ) - return await self.async_step_user(import_config) diff --git a/homeassistant/components/simplepush/notify.py b/homeassistant/components/simplepush/notify.py index 2e58748f323..8bcf166ad25 100644 --- a/homeassistant/components/simplepush/notify.py +++ b/homeassistant/components/simplepush/notify.py @@ -5,34 +5,24 @@ import logging from typing import Any from simplepush import BadRequest, UnknownError, send, send_encrypted -import voluptuous as vol from homeassistant.components.notify import ( ATTR_TITLE, ATTR_TITLE_DEFAULT, - PLATFORM_SCHEMA, + PLATFORM_SCHEMA as BASE_PLATFORM_SCHEMA, BaseNotificationService, ) from homeassistant.components.notify.const import ATTR_DATA from homeassistant.components.repairs.issue_handler import async_create_issue from homeassistant.components.repairs.models import IssueSeverity -from homeassistant.config_entries import SOURCE_IMPORT from homeassistant.const import CONF_EVENT, CONF_PASSWORD from homeassistant.core import HomeAssistant -import homeassistant.helpers.config_validation as cv from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -from .const import ATTR_ENCRYPTED, ATTR_EVENT, CONF_DEVICE_KEY, CONF_SALT, DOMAIN +from .const import ATTR_EVENT, CONF_DEVICE_KEY, CONF_SALT, DOMAIN -# Configuring simplepush under the notify platform will be removed in 2022.9.0 -PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( - { - vol.Required(CONF_DEVICE_KEY): cv.string, - vol.Optional(CONF_EVENT): cv.string, - vol.Inclusive(CONF_PASSWORD, ATTR_ENCRYPTED): cv.string, - vol.Inclusive(CONF_SALT, ATTR_ENCRYPTED): cv.string, - } -) +# Configuring Simplepush under the notify has been removed in 2022.9.0 +PLATFORM_SCHEMA = BASE_PLATFORM_SCHEMA _LOGGER = logging.getLogger(__name__) @@ -47,16 +37,11 @@ async def async_get_service( async_create_issue( hass, DOMAIN, - "deprecated_yaml", + "removed_yaml", breaks_in_ha_version="2022.9.0", is_fixable=False, severity=IssueSeverity.WARNING, - translation_key="deprecated_yaml", - ) - hass.async_create_task( - hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=config - ) + translation_key="removed_yaml", ) return None diff --git a/homeassistant/components/simplepush/strings.json b/homeassistant/components/simplepush/strings.json index 77ed05c4b48..68ee5c7a9ed 100644 --- a/homeassistant/components/simplepush/strings.json +++ b/homeassistant/components/simplepush/strings.json @@ -19,9 +19,9 @@ } }, "issues": { - "deprecated_yaml": { - "title": "The Simplepush YAML configuration is being removed", - "description": "Configuring Simplepush using YAML is being removed.\n\nYour existing YAML configuration has been imported into the UI automatically.\n\nRemove the Simplepush YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue." + "removed_yaml": { + "title": "The Simplepush YAML configuration has been removed", + "description": "Configuring Simplepush using YAML has been removed.\n\nYour existing YAML configuration is not used by Home Assistant.\n\nRemove the Simplepush YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue." } } } diff --git a/homeassistant/components/simplepush/translations/en.json b/homeassistant/components/simplepush/translations/en.json index 8674616dda1..205d3549a52 100644 --- a/homeassistant/components/simplepush/translations/en.json +++ b/homeassistant/components/simplepush/translations/en.json @@ -19,9 +19,9 @@ } }, "issues": { - "deprecated_yaml": { - "description": "Configuring Simplepush using YAML is being removed.\n\nYour existing YAML configuration has been imported into the UI automatically.\n\nRemove the Simplepush YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue.", - "title": "The Simplepush YAML configuration is being removed" + "removed_yaml": { + "description": "Configuring Simplepush using YAML has been removed.\n\nYour existing YAML configuration is not used by Home Assistant.\n\nRemove the Simplepush YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue.", + "title": "The Simplepush YAML configuration has been removed" } } } \ No newline at end of file diff --git a/tests/components/simplepush/test_config_flow.py b/tests/components/simplepush/test_config_flow.py index 6c37fb7ffe6..6f0d6a73aa4 100644 --- a/tests/components/simplepush/test_config_flow.py +++ b/tests/components/simplepush/test_config_flow.py @@ -129,16 +129,3 @@ async def test_error_on_connection_failure(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["errors"] == {"base": "cannot_connect"} - - -async def test_flow_import(hass: HomeAssistant) -> None: - """Test an import flow.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data=MOCK_CONFIG, - ) - - assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY - assert result["title"] == "simplepush" - assert result["data"] == MOCK_CONFIG