Remove YAML import in WaterFurnace (#184389)

This commit is contained in:
Manu
2026-10-06 07:58:14 +02:00
committed by GitHub
parent f3bf8f5a64
commit 2219979752
4 changed files with 4 additions and 218 deletions
@@ -3,19 +3,14 @@
import asyncio
import logging
import probatio
from waterfurnace.waterfurnace import WaterFurnace, WFCredentialError, WFException
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import 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, ConfigEntryNotReady
from homeassistant.helpers import config_validation as cv, issue_registry as ir
from homeassistant.helpers.start import async_at_started
from homeassistant.helpers.typing import ConfigType
from .const import DOMAIN, INTEGRATION_TITLE
from .coordinator import (
WaterFurnaceCoordinator,
WaterFurnaceDeviceData,
@@ -26,72 +21,10 @@ _LOGGER = logging.getLogger(__name__)
PLATFORMS = [Platform.CLIMATE, Platform.SENSOR]
CONFIG_SCHEMA = probatio.Schema(
{
DOMAIN: probatio.Schema(
{
probatio.Required(CONF_USERNAME): cv.string,
probatio.Required(probatio.Secret(CONF_PASSWORD)): cv.string,
}
)
},
extra=probatio.ALLOW_EXTRA,
)
type WaterFurnaceConfigEntry = ConfigEntry[dict[str, WaterFurnaceDeviceData]]
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Import the WaterFurnace configuration from YAML."""
if DOMAIN not in config:
return True
hass.async_create_task(_async_setup(hass, config))
return True
async def _async_setup(hass: HomeAssistant, config: ConfigType) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data=config[DOMAIN],
)
if (
result.get("type") is FlowResultType.ABORT
and result.get("reason") != "already_configured"
):
ir.async_create_issue(
hass,
DOMAIN,
f"deprecated_yaml_import_issue_{result.get('reason')}",
breaks_in_ha_version="2026.8.0",
is_fixable=False,
issue_domain=DOMAIN,
severity=ir.IssueSeverity.WARNING,
translation_key=f"deprecated_yaml_import_issue_{result.get('reason')}",
translation_placeholders={
"domain": DOMAIN,
"integration_title": INTEGRATION_TITLE,
},
)
return
ir.async_create_issue(
hass,
HOMEASSISTANT_DOMAIN,
"deprecated_yaml",
breaks_in_ha_version="2026.8.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_coordinator(
hass: HomeAssistant,
username: str,
@@ -123,35 +123,3 @@ class WaterFurnaceConfigFlow(ConfigFlow, domain=DOMAIN):
),
errors=errors,
)
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
"""Handle import from YAML configuration."""
username = import_data[CONF_USERNAME]
password = import_data[CONF_PASSWORD]
client = WaterFurnace(username, password)
try:
# Login is a blocking call, run in executor
await self.hass.async_add_executor_job(client.login)
except WFCredentialError:
return self.async_abort(reason="invalid_auth")
except WFException:
return self.async_abort(reason="cannot_connect")
except Exception:
_LOGGER.exception("Unexpected error importing WaterFurnace configuration")
return self.async_abort(reason="unknown")
if not client.devices:
return self.async_abort(reason="no_devices")
if client.account_id is None:
return self.async_abort(reason="unknown")
await self.async_set_unique_id(str(client.account_id))
self._abort_if_unique_id_configured()
return self.async_create_entry(
title=f"WaterFurnace {username}",
data=import_data,
)
@@ -98,23 +98,5 @@
"name": "Water flow rate"
}
}
},
"issues": {
"deprecated_yaml_import_issue_cannot_connect": {
"description": "Configuring {integration_title} via YAML is deprecated and will be removed in a future release. While importing your configuration, we could not connect to {integration_title}. Please check your YAML configuration and restart Home Assistant, or remove the {domain} key from your configuration and configure the integration via the UI.",
"title": "[%key:component::waterfurnace::issues::deprecated_yaml_import_issue_unknown::title%]"
},
"deprecated_yaml_import_issue_invalid_auth": {
"description": "Configuring {integration_title} via YAML is deprecated and will be removed in a future release. While importing your configuration, invalid authentication details were found. Please correct your YAML configuration and restart Home Assistant, or remove the {domain} key from your configuration and configure the integration via the UI.",
"title": "[%key:component::waterfurnace::issues::deprecated_yaml_import_issue_unknown::title%]"
},
"deprecated_yaml_import_issue_no_devices": {
"description": "Configuring {integration_title} via YAML is deprecated and will be removed in a future release. While importing your configuration, no devices were found on your account. Please verify your account has devices and restart Home Assistant, or remove the {domain} key from your configuration and configure the integration via the UI.",
"title": "[%key:component::waterfurnace::issues::deprecated_yaml_import_issue_unknown::title%]"
},
"deprecated_yaml_import_issue_unknown": {
"description": "Configuring {integration_title} via YAML is deprecated and will be removed in a future release. While importing your configuration an unknown exception has been encountered. Please correct your YAML configuration and restart Home Assistant, or remove the {domain} key from your configuration and configure the integration via the UI.",
"title": "WaterFurnace YAML configuration import failed"
}
}
}
@@ -6,7 +6,7 @@ import pytest
from waterfurnace.waterfurnace import WFCredentialError, WFException
from homeassistant.components.waterfurnace.const import DOMAIN
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
@@ -166,103 +166,6 @@ async def test_user_flow_already_configured(
assert result["reason"] == "already_configured"
@pytest.mark.usefixtures("mock_setup_entry")
async def test_import_flow_success(
hass: HomeAssistant, mock_waterfurnace_client: Mock
) -> None:
"""Test successful import flow from YAML."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={CONF_USERNAME: "test_user", CONF_PASSWORD: "test_password"},
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "WaterFurnace test_user"
assert result["data"] == {
CONF_USERNAME: "test_user",
CONF_PASSWORD: "test_password",
}
assert result["result"].unique_id == "test_account_id"
async def test_import_flow_already_configured(
hass: HomeAssistant,
mock_waterfurnace_client: Mock,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test import flow when device is already configured."""
mock_config_entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={CONF_USERNAME: "test_user", CONF_PASSWORD: "test_password"},
)
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@pytest.mark.parametrize(
("exception", "reason"),
[
(WFCredentialError("Invalid credentials"), "invalid_auth"),
(WFException("Connection failed"), "cannot_connect"),
(Exception("Unexpected error"), "unknown"),
],
)
async def test_import_flow_exceptions(
hass: HomeAssistant,
mock_waterfurnace_client: Mock,
exception: Exception,
reason: str,
) -> None:
"""Test import flow with connection error."""
mock_waterfurnace_client.login.side_effect = exception
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={CONF_USERNAME: "test_user", CONF_PASSWORD: "test_password"},
)
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == reason
async def test_import_flow_account_id_none(
hass: HomeAssistant, mock_waterfurnace_client: Mock
) -> None:
"""Test import flow when account_id is None."""
mock_waterfurnace_client.account_id = None
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={CONF_USERNAME: "test_user", CONF_PASSWORD: "test_password"},
)
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown"
async def test_import_flow_no_devices(
hass: HomeAssistant, mock_waterfurnace_client: Mock
) -> None:
"""Test import flow with no devices."""
mock_waterfurnace_client.devices = []
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={CONF_USERNAME: "test_user", CONF_PASSWORD: "test_password"},
)
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices"
@pytest.mark.usefixtures("mock_setup_entry")
async def test_reauth_flow_success(
hass: HomeAssistant,