diff --git a/homeassistant/components/opentherm_gw/__init__.py b/homeassistant/components/opentherm_gw/__init__.py index c7a52e3d5d3..d5dae367959 100644 --- a/homeassistant/components/opentherm_gw/__init__.py +++ b/homeassistant/components/opentherm_gw/__init__.py @@ -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(): diff --git a/homeassistant/components/opentherm_gw/config_flow.py b/homeassistant/components/opentherm_gw/config_flow.py index 3cf8a1c4594..1f52b47cbad 100644 --- a/homeassistant/components/opentherm_gw/config_flow.py +++ b/homeassistant/components/opentherm_gw/config_flow.py @@ -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. diff --git a/homeassistant/components/opentherm_gw/strings.json b/homeassistant/components/opentherm_gw/strings.json index b23e1eb7687..f0573db0531 100644 --- a/homeassistant/components/opentherm_gw/strings.json +++ b/homeassistant/components/opentherm_gw/strings.json @@ -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": { diff --git a/tests/components/opentherm_gw/test_config_flow.py b/tests/components/opentherm_gw/test_config_flow.py index 4f4a6cfce31..57bea4e55dc 100644 --- a/tests/components/opentherm_gw/test_config_flow.py +++ b/tests/components/opentherm_gw/test_config_flow.py @@ -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, diff --git a/tests/components/opentherm_gw/test_init.py b/tests/components/opentherm_gw/test_init.py index 4085e25c614..3e85afbf782 100644 --- a/tests/components/opentherm_gw/test_init.py +++ b/tests/components/opentherm_gw/test_init.py @@ -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 + )