Remove deprecated import from configuration.yaml from opentherm_gw (#139581)

* Remove deprecated import from configuration.yaml in opentherm_gw

* Remove tests for removed funcionality from opentherm_gw
This commit is contained in:
mvn23 2025-03-01 19:45:07 +01:00 committed by GitHub
parent 2de941bc11
commit 9a331de878
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 2 additions and 117 deletions

View File

@ -10,7 +10,7 @@ from serial import SerialException
import voluptuous as vol
from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
ATTR_DATE,
ATTR_ID,
@ -21,9 +21,6 @@ from homeassistant.const import (
CONF_ID,
CONF_NAME,
EVENT_HOMEASSISTANT_STOP,
PRECISION_HALVES,
PRECISION_TENTHS,
PRECISION_WHOLE,
Platform,
)
from homeassistant.core import HomeAssistant, ServiceCall
@ -32,10 +29,8 @@ from homeassistant.helpers import (
config_validation as cv,
device_registry as dr,
entity_registry as er,
issue_registry as ir,
)
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.typing import ConfigType
from .const import (
ATTR_CH_OVRD,
@ -44,9 +39,6 @@ from .const import (
ATTR_LEVEL,
ATTR_TRANSP_ARG,
ATTR_TRANSP_CMD,
CONF_CLIMATE,
CONF_FLOOR_TEMP,
CONF_PRECISION,
CONF_TEMPORARY_OVRD_MODE,
CONNECTION_TIMEOUT,
DATA_GATEWAYS,
@ -70,29 +62,6 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
# *_SCHEMA required for deprecated import from configuration.yaml, can be removed in 2025.4.0
CLIMATE_SCHEMA = vol.Schema(
{
vol.Optional(CONF_PRECISION): vol.In(
[PRECISION_TENTHS, PRECISION_HALVES, PRECISION_WHOLE]
),
vol.Optional(CONF_FLOOR_TEMP, default=False): cv.boolean,
}
)
CONFIG_SCHEMA = vol.Schema(
{
DOMAIN: cv.schema_with_slug_keys(
{
vol.Required(CONF_DEVICE): cv.string,
vol.Optional(CONF_CLIMATE, default={}): CLIMATE_SCHEMA,
vol.Optional(CONF_NAME): cv.string,
}
)
},
extra=vol.ALLOW_EXTRA,
)
PLATFORMS = [
Platform.BINARY_SENSOR,
Platform.BUTTON,
@ -164,33 +133,6 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
return True
# Deprecated import from configuration.yaml, can be removed in 2025.4.0
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the OpenTherm Gateway component."""
if DOMAIN in config:
ir.async_create_issue(
hass,
DOMAIN,
"deprecated_import_from_configuration_yaml",
breaks_in_ha_version="2025.4.0",
is_fixable=False,
is_persistent=False,
severity=ir.IssueSeverity.WARNING,
translation_key="deprecated_import_from_configuration_yaml",
)
if not hass.config_entries.async_entries(DOMAIN) and DOMAIN in config:
conf = config[DOMAIN]
for device_id, device_config in conf.items():
device_config[CONF_ID] = device_id
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=device_config
)
)
return True
def register_services(hass: HomeAssistant) -> None:
"""Register services for the component."""
service_reset_schema = vol.Schema(

View File

@ -354,12 +354,6 @@
}
}
},
"issues": {
"deprecated_import_from_configuration_yaml": {
"title": "Deprecated configuration",
"description": "Configuration of the OpenTherm Gateway integration through configuration.yaml is deprecated. Your configuration has been migrated to config entries. Please remove any OpenTherm Gateway configuration from your configuration.yaml."
}
},
"options": {
"step": {
"init": {

View File

@ -54,30 +54,6 @@ async def test_form_user(
assert mock_pyotgw.return_value.disconnect.await_count == 1
# Deprecated import from configuration.yaml, can be removed in 2025.4.0
async def test_form_import(
hass: HomeAssistant,
mock_pyotgw: MagicMock,
mock_setup_entry: AsyncMock,
) -> None:
"""Test import from existing config."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data={CONF_ID: "legacy_gateway", CONF_DEVICE: "/dev/ttyUSB1"},
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "legacy_gateway"
assert result["data"] == {
CONF_NAME: "legacy_gateway",
CONF_DEVICE: "/dev/ttyUSB1",
CONF_ID: "legacy_gateway",
}
assert mock_pyotgw.return_value.connect.await_count == 1
assert mock_pyotgw.return_value.disconnect.await_count == 1
async def test_form_duplicate_entries(
hass: HomeAssistant,
mock_pyotgw: MagicMock,

View File

@ -4,18 +4,13 @@ from unittest.mock import MagicMock
from pyotgw.vars import OTGW, OTGW_ABOUT
from homeassistant import setup
from homeassistant.components.opentherm_gw.const import (
DOMAIN,
OpenThermDeviceIdentifier,
)
from homeassistant.const import CONF_ID
from homeassistant.core import HomeAssistant
from homeassistant.helpers import (
device_registry as dr,
entity_registry as er,
issue_registry as ir,
)
from homeassistant.helpers import device_registry as dr, entity_registry as er
from .conftest import MOCK_GATEWAY_ID, VERSION_TEST
@ -153,25 +148,3 @@ async def test_climate_entity_migration(
updated_entry.unique_id
== f"{mock_config_entry.data[CONF_ID]}-{OpenThermDeviceIdentifier.THERMOSTAT}-thermostat_entity"
)
# Deprecation test, can be removed in 2025.4.0
async def test_configuration_yaml_deprecation(
hass: HomeAssistant,
issue_registry: ir.IssueRegistry,
mock_config_entry: MockConfigEntry,
mock_pyotgw: MagicMock,
) -> None:
"""Test that existing configuration in configuration.yaml creates an issue."""
await setup.async_setup_component(
hass, DOMAIN, {DOMAIN: {"legacy_gateway": {"device": "/dev/null"}}}
)
await hass.async_block_till_done()
assert (
issue_registry.async_get_issue(
DOMAIN, "deprecated_import_from_configuration_yaml"
)
is not None
)