From a81a4ad44b2fa0f6df9ed197d29074e4b9836d55 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 30 Jan 2021 09:45:46 -0600 Subject: [PATCH] Fix exception when a unifi config entry is ignored (#45735) * Fix exception when a unifi config entry is ignored * Fix existing test --- homeassistant/components/unifi/config_flow.py | 2 +- tests/components/unifi/test_config_flow.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/unifi/config_flow.py b/homeassistant/components/unifi/config_flow.py index 85203204b2f0..0ea55c157477 100644 --- a/homeassistant/components/unifi/config_flow.py +++ b/homeassistant/components/unifi/config_flow.py @@ -236,7 +236,7 @@ class UnifiFlowHandler(config_entries.ConfigFlow, domain=UNIFI_DOMAIN): def _host_already_configured(self, host): """See if we already have a unifi entry matching the host.""" for entry in self._async_current_entries(): - if not entry.data: + if not entry.data or CONF_CONTROLLER not in entry.data: continue if entry.data[CONF_CONTROLLER][CONF_HOST] == host: return True diff --git a/tests/components/unifi/test_config_flow.py b/tests/components/unifi/test_config_flow.py index 6eb049b573ac..88c1cbe586de 100644 --- a/tests/components/unifi/test_config_flow.py +++ b/tests/components/unifi/test_config_flow.py @@ -546,7 +546,7 @@ async def test_form_ssdp_gets_form_with_ignored_entry(hass): await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry( domain=UNIFI_DOMAIN, - data={}, + data={"not_controller_key": None}, source=config_entries.SOURCE_IGNORE, ) entry.add_to_hass(hass)