Remove EDL21 YAML configuration (#93551)

This commit is contained in:
G Johansson 2023-05-26 08:38:44 +02:00 committed by GitHub
parent 3633062024
commit 1f467fcc6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 86 deletions

View file

@ -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:

View file

@ -7,16 +7,14 @@ from typing import Any
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 @@ from homeassistant.const import (
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 @@ from .const import (
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 @@ SENSOR_UNIT_MAPPING = {
}
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,

View file

@ -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."
}
}
}

View file

@ -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"