Fix exception when trying to configure an ignored somfy mylink (#45198)

pull/45167/head
J. Nick Koston 2021-01-15 13:48:19 -10:00 committed by GitHub
parent 5677adc104
commit b3764da912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -118,7 +118,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
def _host_already_configured(self, host):
"""See if we already have an entry matching the host."""
for entry in self._async_current_entries():
if entry.data[CONF_HOST] == host:
if entry.data.get(CONF_HOST) == host:
return True
return False

View File

@ -461,6 +461,25 @@ async def test_form_user_already_configured_from_dhcp(hass):
assert len(mock_setup_entry.mock_calls) == 0
async def test_already_configured_with_ignored(hass):
"""Test ignored entries do not break checking for existing entries."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(domain=DOMAIN, data={}, source="ignore")
config_entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_DHCP},
data={
IP_ADDRESS: "1.1.1.1",
MAC_ADDRESS: "AA:BB:CC:DD:EE:FF",
HOSTNAME: "somfy_eeff",
},
)
assert result["type"] == "form"
async def test_dhcp_discovery(hass):
"""Test we can process the discovery from dhcp."""
await setup.async_setup_component(hass, "persistent_notification", {})