mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +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,
|
config_validation as cv,
|
||||||
device_registry as dr,
|
device_registry as dr,
|
||||||
entity_registry as er,
|
entity_registry as er,
|
||||||
|
issue_registry as ir,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
@ -68,6 +69,7 @@ from .const import (
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# *_SCHEMA required for deprecated import from configuration.yaml, can be removed in 2025.4.0
|
||||||
CLIMATE_SCHEMA = vol.Schema(
|
CLIMATE_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Optional(CONF_PRECISION): vol.In(
|
vol.Optional(CONF_PRECISION): vol.In(
|
||||||
@ -159,8 +161,20 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
# Deprecated import from configuration.yaml, can be removed in 2025.4.0
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the OpenTherm Gateway component."""
|
"""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:
|
if not hass.config_entries.async_entries(DOMAIN) and DOMAIN in config:
|
||||||
conf = config[DOMAIN]
|
conf = config[DOMAIN]
|
||||||
for device_id, device_config in conf.items():
|
for device_id, device_config in conf.items():
|
||||||
|
@ -95,6 +95,7 @@ class OpenThermGwConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle manual initiation of the config flow."""
|
"""Handle manual initiation of the config flow."""
|
||||||
return await self.async_step_init(user_input)
|
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:
|
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||||
"""Import an OpenTherm Gateway device as a config entry.
|
"""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": {
|
"options": {
|
||||||
"step": {
|
"step": {
|
||||||
"init": {
|
"init": {
|
||||||
|
@ -54,6 +54,7 @@ async def test_form_user(
|
|||||||
assert mock_pyotgw.return_value.disconnect.await_count == 1
|
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(
|
async def test_form_import(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_pyotgw: MagicMock,
|
mock_pyotgw: MagicMock,
|
||||||
|
@ -4,13 +4,18 @@ from unittest.mock import MagicMock
|
|||||||
|
|
||||||
from pyotgw.vars import OTGW, OTGW_ABOUT
|
from pyotgw.vars import OTGW, OTGW_ABOUT
|
||||||
|
|
||||||
|
from homeassistant import setup
|
||||||
from homeassistant.components.opentherm_gw.const import (
|
from homeassistant.components.opentherm_gw.const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
OpenThermDeviceIdentifier,
|
OpenThermDeviceIdentifier,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_ID
|
from homeassistant.const import CONF_ID
|
||||||
from homeassistant.core import HomeAssistant
|
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
|
from .conftest import MOCK_GATEWAY_ID, VERSION_TEST
|
||||||
|
|
||||||
@ -148,3 +153,25 @@ async def test_climate_entity_migration(
|
|||||||
updated_entry.unique_id
|
updated_entry.unique_id
|
||||||
== f"{mock_config_entry.data[CONF_ID]}-{OpenThermDeviceIdentifier.THERMOSTAT}-thermostat_entity"
|
== 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