Fix duplicate-configuration edge-case in Frontier Silicon config flow (#172916)

This commit is contained in:
Thijs W.
2026-06-23 00:11:51 +02:00
committed by GitHub
parent 30b648ea6a
commit 4f414d0035
2 changed files with 28 additions and 0 deletions
@@ -71,6 +71,7 @@ class FrontierSiliconConfigFlow(ConfigFlow, domain=DOMAIN):
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
self._async_abort_entries_match({CONF_WEBFSAPI_URL: self._webfsapi_url})
return await self._async_step_device_config_if_needed()
data_schema = self.add_suggested_values_to_schema(
@@ -245,6 +245,33 @@ async def test_invalid_device_url(
mock_setup_entry.assert_called_once()
async def test_user_already_configured_without_unique_id(
hass: HomeAssistant,
) -> None:
"""Test manual setup aborts when an entry with the same endpoint already exists."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id=None,
data={CONF_WEBFSAPI_URL: "http://1.1.1.1:80/webfsapi", CONF_PIN: DEFAULT_PIN},
)
entry.add_to_hass(hass)
with patch(
"homeassistant.components.frontier_silicon.config_flow.AFSAPI.get_radio_id",
side_effect=FSNotImplementedError,
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{CONF_HOST: "1.1.1.1", CONF_PORT: 80},
)
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured"
@pytest.mark.parametrize(
("radio_id_return_value", "radio_id_side_effect"),
[("mock_radio_id", None), (None, FSNotImplementedError)],