mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Deprecate opentherm_gw configuration through configuration.yaml (#125045)
* Create an issue in the issue registry if deprecated config is found in configuration.yaml * Add deprecation comments to functions that can be removed after deprecation period * Add test for the creation of a deprecation issue Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
parent
a7a219b99b
commit
45ab6e9b06
@ -32,6 +32,7 @@ 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
|
||||
@ -68,6 +69,7 @@ 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(
|
||||
@ -159,8 +161,20 @@ 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():
|
||||
|
@ -95,6 +95,7 @@ class OpenThermGwConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle manual initiation of the config flow."""
|
||||
return await self.async_step_init(user_input)
|
||||
|
||||
# Deprecated import from configuration.yaml, can be removed in 2025.4.0
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import an OpenTherm Gateway device as a config entry.
|
||||
|
||||
|
@ -316,6 +316,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"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": {
|
||||
|
@ -54,6 +54,7 @@ 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,
|
||||
|
@ -4,13 +4,18 @@ 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
|
||||
from homeassistant.helpers import (
|
||||
device_registry as dr,
|
||||
entity_registry as er,
|
||||
issue_registry as ir,
|
||||
)
|
||||
|
||||
from .conftest import MOCK_GATEWAY_ID, VERSION_TEST
|
||||
|
||||
@ -148,3 +153,25 @@ 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
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user