mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Guard against hostname change in lamarzocco discovery (#131873)
* Guard against hostname change in lamarzocco discovery * switch to abort_entries_match
This commit is contained in:
parent
a760786faf
commit
d9cef1e708
@ -291,6 +291,7 @@ class LmConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
CONF_ADDRESS: discovery_info.macaddress,
|
||||
}
|
||||
)
|
||||
self._async_abort_entries_match({CONF_ADDRESS: discovery_info.macaddress})
|
||||
|
||||
_LOGGER.debug(
|
||||
"Discovered La Marzocco machine %s through DHCP at address %s",
|
||||
|
@ -493,6 +493,27 @@ async def test_dhcp_discovery(
|
||||
}
|
||||
|
||||
|
||||
async def test_dhcp_discovery_abort_on_hostname_changed(
|
||||
hass: HomeAssistant,
|
||||
mock_lamarzocco: MagicMock,
|
||||
mock_cloud_client: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test dhcp discovery aborts when hostname was changed manually."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_DHCP},
|
||||
data=DhcpServiceInfo(
|
||||
ip="192.168.1.42",
|
||||
hostname="custom_name",
|
||||
macaddress="00:00:00:00:00:00",
|
||||
),
|
||||
)
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_dhcp_already_configured_and_update(
|
||||
hass: HomeAssistant,
|
||||
mock_lamarzocco: MagicMock,
|
||||
|
Loading…
x
Reference in New Issue
Block a user