diff --git a/homeassistant/components/incomfort/__init__.py b/homeassistant/components/incomfort/__init__.py index 39e471b7614a98..708c0d391b89a4 100644 --- a/homeassistant/components/incomfort/__init__.py +++ b/homeassistant/components/incomfort/__init__.py @@ -6,13 +6,11 @@ from incomfortclient import IncomfortError, InvalidHeaterList import voluptuous as vol -from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry +from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platform -from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant -from homeassistant.data_entry_flow import FlowResultType +from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed -from homeassistant.helpers import config_validation as cv, issue_registry as ir -from homeassistant.helpers.typing import ConfigType +from homeassistant.helpers import config_validation as cv from .const import DOMAIN from .coordinator import InComfortDataCoordinator, async_connect_gateway @@ -43,53 +41,6 @@ type InComfortConfigEntry = ConfigEntry[InComfortDataCoordinator] -async def _async_import(hass: HomeAssistant, config: ConfigType) -> None: - """Import config entry from configuration.yaml.""" - if not hass.config_entries.async_entries(DOMAIN): - # Start import flow - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=config - ) - if result["type"] == FlowResultType.ABORT: - ir.async_create_issue( - hass, - DOMAIN, - f"deprecated_yaml_import_issue_{result['reason']}", - breaks_in_ha_version="2025.1.0", - is_fixable=False, - issue_domain=DOMAIN, - severity=ir.IssueSeverity.WARNING, - translation_key=f"deprecated_yaml_import_issue_{result['reason']}", - translation_placeholders={ - "domain": DOMAIN, - "integration_title": INTEGRATION_TITLE, - }, - ) - return - - ir.async_create_issue( - hass, - HOMEASSISTANT_DOMAIN, - f"deprecated_yaml_{DOMAIN}", - breaks_in_ha_version="2025.1.0", - is_fixable=False, - issue_domain=DOMAIN, - severity=ir.IssueSeverity.WARNING, - translation_key="deprecated_yaml", - translation_placeholders={ - "domain": DOMAIN, - "integration_title": INTEGRATION_TITLE, - }, - ) - - -async def async_setup(hass: HomeAssistant, hass_config: ConfigType) -> bool: - """Create an Intergas InComfort/Intouch system.""" - if config := hass_config.get(DOMAIN): - hass.async_create_task(_async_import(hass, config)) - return True - - async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up a config entry.""" try: diff --git a/homeassistant/components/incomfort/config_flow.py b/homeassistant/components/incomfort/config_flow.py index e905f0d743dd03..f4838a9771d5b8 100644 --- a/homeassistant/components/incomfort/config_flow.py +++ b/homeassistant/components/incomfort/config_flow.py @@ -81,11 +81,3 @@ async def async_step_user( return self.async_show_form( step_id="user", data_schema=CONFIG_SCHEMA, errors=errors ) - - async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: - """Import `incomfort` config entry from configuration.yaml.""" - errors: dict[str, str] | None = None - if (errors := await async_try_connect_gateway(self.hass, import_data)) is None: - return self.async_create_entry(title=TITLE, data=import_data) - reason = next(iter(errors.items()))[1] - return self.async_abort(reason=reason) diff --git a/tests/components/incomfort/test_config_flow.py b/tests/components/incomfort/test_config_flow.py index 7a942dab817fc3..d909ae111ba907 100644 --- a/tests/components/incomfort/test_config_flow.py +++ b/tests/components/incomfort/test_config_flow.py @@ -7,7 +7,7 @@ import pytest from homeassistant.components.incomfort import DOMAIN -from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER +from homeassistant.config_entries import SOURCE_USER from homeassistant.const import CONF_HOST, CONF_PASSWORD from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -38,50 +38,6 @@ async def test_form( assert len(mock_setup_entry.mock_calls) == 1 -async def test_import( - hass: HomeAssistant, mock_setup_entry: AsyncMock, mock_incomfort: MagicMock -) -> None: - """Test we van import from YAML.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_CONFIG - ) - await hass.async_block_till_done() - assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["title"] == "Intergas InComfort/Intouch Lan2RF gateway" - assert result["data"] == MOCK_CONFIG - assert len(mock_setup_entry.mock_calls) == 1 - - -@pytest.mark.parametrize( - ("exc", "abort_reason"), - [ - (IncomfortError(ClientResponseError(None, None, status=401)), "auth_error"), - (IncomfortError(ClientResponseError(None, None, status=404)), "not_found"), - (IncomfortError(ClientResponseError(None, None, status=500)), "unknown"), - (IncomfortError, "unknown"), - (InvalidHeaterList, "no_heaters"), - (ValueError, "unknown"), - (TimeoutError, "timeout_error"), - ], -) -async def test_import_fails( - hass: HomeAssistant, - mock_setup_entry: AsyncMock, - mock_incomfort: MagicMock, - exc: Exception, - abort_reason: str, -) -> None: - """Test YAML import fails.""" - mock_incomfort().heaters.side_effect = exc - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_CONFIG - ) - await hass.async_block_till_done() - assert result["type"] is FlowResultType.ABORT - assert result["reason"] == abort_reason - assert len(mock_setup_entry.mock_calls) == 0 - - async def test_entry_already_configured(hass: HomeAssistant) -> None: """Test aborting if the entry is already configured.""" entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG)