Handle ignored shelly entries when discovering via zeroconf (#86039)
fixes https://github.com/home-assistant/core/issues/85879pull/86058/head
parent
4138e518ef
commit
96578f3f89
|
@ -217,7 +217,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
"""Abort and reconnect soon if the device with the mac address is already configured."""
|
||||
if (
|
||||
current_entry := await self.async_set_unique_id(mac)
|
||||
) and current_entry.data[CONF_HOST] == host:
|
||||
) and current_entry.data.get(CONF_HOST) == host:
|
||||
await async_reconnect_soon(self.hass, current_entry)
|
||||
if host == INTERNAL_WIFI_AP_IP:
|
||||
# If the device is broadcasting the internal wifi ap ip
|
||||
|
|
|
@ -706,6 +706,30 @@ async def test_zeroconf_already_configured(hass):
|
|||
assert entry.data["host"] == "1.1.1.1"
|
||||
|
||||
|
||||
async def test_zeroconf_ignored(hass):
|
||||
"""Test zeroconf when the device was previously ignored."""
|
||||
|
||||
entry = MockConfigEntry(
|
||||
domain="shelly",
|
||||
unique_id="test-mac",
|
||||
data={},
|
||||
source=config_entries.SOURCE_IGNORE,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"aioshelly.common.get_info",
|
||||
return_value={"mac": "test-mac", "type": "SHSW-1", "auth": False},
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
data=DISCOVERY_INFO,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_zeroconf_with_wifi_ap_ip(hass):
|
||||
"""Test we ignore the Wi-FI AP IP."""
|
||||
|
||||
|
|
Loading…
Reference in New Issue