From 1f467fcc6a333c9a10c338fd1e181e9fac2faaa5 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Fri, 26 May 2023 08:38:44 +0200 Subject: [PATCH] Remove EDL21 YAML configuration (#93551) --- homeassistant/components/edl21/config_flow.py | 13 ------- homeassistant/components/edl21/sensor.py | 39 +------------------ homeassistant/components/edl21/strings.json | 6 --- tests/components/edl21/test_config_flow.py | 30 +------------- 4 files changed, 2 insertions(+), 86 deletions(-) diff --git a/homeassistant/components/edl21/config_flow.py b/homeassistant/components/edl21/config_flow.py index b66a988958b9b..0bedcc515efd4 100644 --- a/homeassistant/components/edl21/config_flow.py +++ b/homeassistant/components/edl21/config_flow.py @@ -1,10 +1,8 @@ """Config flow for EDL21 integration.""" -from typing import Any import voluptuous as vol from homeassistant import config_entries -from homeassistant.const import CONF_NAME from homeassistant.data_entry_flow import FlowResult from .const import CONF_SERIAL_PORT, DEFAULT_TITLE, DOMAIN @@ -21,17 +19,6 @@ class EDL21ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): VERSION = 1 - async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult: - """Import a config entry from configuration.yaml.""" - - self._async_abort_entries_match( - {CONF_SERIAL_PORT: import_config[CONF_SERIAL_PORT]} - ) - return self.async_create_entry( - title=import_config[CONF_NAME] or DEFAULT_TITLE, - data=import_config, - ) - async def async_step_user( self, user_input: dict[str, str] | None = None ) -> FlowResult: diff --git a/homeassistant/components/edl21/sensor.py b/homeassistant/components/edl21/sensor.py index e526f951f1c6b..c85f4a1f5b163 100644 --- a/homeassistant/components/edl21/sensor.py +++ b/homeassistant/components/edl21/sensor.py @@ -7,16 +7,14 @@ from sml import SmlGetListResponse from sml.asyncio import SmlProtocol -import voluptuous as vol from homeassistant.components.sensor import ( - PLATFORM_SCHEMA, SensorDeviceClass, SensorEntity, SensorEntityDescription, SensorStateClass, ) -from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry +from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_NAME, DEGREE, @@ -27,15 +25,12 @@ UnitOfPower, ) from homeassistant.core import HomeAssistant, callback -from homeassistant.helpers import config_validation as cv from homeassistant.helpers.dispatcher import ( async_dispatcher_connect, async_dispatcher_send, ) from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.util.dt import utcnow from .const import ( @@ -48,13 +43,6 @@ MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60) -PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( - { - vol.Required(CONF_SERIAL_PORT): cv.string, - vol.Optional(CONF_NAME, default=""): cv.string, - }, -) - # OBIS format: A-B:C.D.E*F SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( # A=1: Electricity @@ -279,31 +267,6 @@ } -async def async_setup_platform( - hass: HomeAssistant, - config: ConfigType, - async_add_entities: AddEntitiesCallback, - discovery_info: DiscoveryInfoType | None = None, -) -> None: - """Set up EDL21 sensors via configuration.yaml and show deprecation warning.""" - async_create_issue( - hass, - DOMAIN, - "deprecated_yaml", - breaks_in_ha_version="2023.6.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, - ) - ) - - async def async_setup_entry( hass: HomeAssistant, config_entry: ConfigEntry, diff --git a/homeassistant/components/edl21/strings.json b/homeassistant/components/edl21/strings.json index 284e8229c59b5..764cc41d2a406 100644 --- a/homeassistant/components/edl21/strings.json +++ b/homeassistant/components/edl21/strings.json @@ -11,11 +11,5 @@ } } } - }, - "issues": { - "deprecated_yaml": { - "title": "EDL21 YAML configuration is being removed", - "description": "Configuring EDL21 using YAML is being removed.\n\nYour existing YAML configuration has been imported into the UI automatically.\n\nRemove the EDL21 YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue." - } } } diff --git a/tests/components/edl21/test_config_flow.py b/tests/components/edl21/test_config_flow.py index 4dbd69b237184..030ff7ae63e42 100644 --- a/tests/components/edl21/test_config_flow.py +++ b/tests/components/edl21/test_config_flow.py @@ -3,7 +3,7 @@ import pytest from homeassistant.components.edl21.const import CONF_SERIAL_PORT, DEFAULT_TITLE, DOMAIN -from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER +from homeassistant.config_entries import SOURCE_USER from homeassistant.const import CONF_NAME from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -51,31 +51,3 @@ async def test_integration_already_exists(hass: HomeAssistant) -> None: assert result["type"] == FlowResultType.ABORT assert result["reason"] == "already_configured" - - -async def test_create_entry_by_import(hass: HomeAssistant) -> None: - """Test that the import step works.""" - - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_IMPORT}, - data=VALID_LEGACY_CONFIG, - ) - - assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == VALID_LEGACY_CONFIG[CONF_NAME] - assert result["data"][CONF_NAME] == VALID_LEGACY_CONFIG[CONF_NAME] - assert result["data"][CONF_SERIAL_PORT] == VALID_LEGACY_CONFIG[CONF_SERIAL_PORT] - - # Test the import step with an empty string as name - # (the name is optional in the old schema and defaults to "") - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_IMPORT}, - data={CONF_SERIAL_PORT: "/dev/ttyUSB2", CONF_NAME: ""}, - ) - - assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == DEFAULT_TITLE - assert result["data"][CONF_NAME] == "" - assert result["data"][CONF_SERIAL_PORT] == "/dev/ttyUSB2"