mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Clean up unused import steps from HomeWizard config flow (#86002)
This commit is contained in:
parent
dd18708b63
commit
c26d620ab1
@ -1,4 +1,4 @@
|
||||
"""Config flow for Homewizard."""
|
||||
"""Config flow for HomeWizard."""
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Mapping
|
||||
@ -11,7 +11,7 @@ from homewizard_energy.models import Device
|
||||
from voluptuous import Required, Schema
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import persistent_notification, zeroconf
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.const import CONF_IP_ADDRESS
|
||||
from homeassistant.data_entry_flow import AbortFlow, FlowResult
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
@ -38,23 +38,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self.config: dict[str, str | int] = {}
|
||||
self.entry: config_entries.ConfigEntry | None = None
|
||||
|
||||
async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult:
|
||||
"""Handle a flow initiated by older `homewizard_energy` component."""
|
||||
_LOGGER.debug("config_flow async_step_import")
|
||||
|
||||
persistent_notification.async_create(
|
||||
self.hass,
|
||||
title="HomeWizard Energy",
|
||||
message=(
|
||||
"The custom integration of HomeWizard Energy has been migrated to core."
|
||||
" You can safely remove the custom integration from the"
|
||||
" custom_integrations folder."
|
||||
),
|
||||
notification_id=f"homewizard_energy_to_{DOMAIN}",
|
||||
)
|
||||
|
||||
return await self.async_step_user({CONF_IP_ADDRESS: import_config["host"]})
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
@ -97,11 +80,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
data: dict[str, str] = {CONF_IP_ADDRESS: user_input[CONF_IP_ADDRESS]}
|
||||
|
||||
if self.source == config_entries.SOURCE_IMPORT:
|
||||
old_config_entry_id = self.context["old_config_entry_id"]
|
||||
assert self.hass.config_entries.async_get_entry(old_config_entry_id)
|
||||
data["old_config_entry_id"] = old_config_entry_id
|
||||
|
||||
# Add entry
|
||||
return self.async_create_entry(
|
||||
title=f"{device_info.product_name} ({device_info.serial})",
|
||||
|
@ -112,39 +112,6 @@ async def test_discovery_flow_works(hass, aioclient_mock):
|
||||
assert result["result"].unique_id == "HWE-P1_aabbccddeeff"
|
||||
|
||||
|
||||
async def test_config_flow_imports_entry(aioclient_mock, hass):
|
||||
"""Test config flow accepts imported configuration."""
|
||||
|
||||
device = get_mock_device()
|
||||
|
||||
mock_entry = MockConfigEntry(domain="homewizard_energy", data={"host": "1.2.3.4"})
|
||||
mock_entry.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.homewizard.config_flow.HomeWizardEnergy",
|
||||
return_value=device,
|
||||
), patch(
|
||||
"homeassistant.components.homewizard.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_IMPORT,
|
||||
"old_config_entry_id": mock_entry.entry_id,
|
||||
},
|
||||
data=mock_entry.data,
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["title"] == "P1 meter (aabbccddeeff)"
|
||||
assert result["data"][CONF_IP_ADDRESS] == "1.2.3.4"
|
||||
|
||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||
assert len(device.device.mock_calls) == len(device.close.mock_calls)
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_discovery_disabled_api(hass, aioclient_mock):
|
||||
"""Test discovery detecting disabled api."""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user