From adb0d85511d49dade5606ff63349dda44e311b1a Mon Sep 17 00:00:00 2001 From: Robert Hillis Date: Fri, 27 Jan 2023 21:38:25 -0500 Subject: [PATCH] Fix D-Link config flow auth (#86824) --- homeassistant/components/dlink/__init__.py | 2 +- homeassistant/components/dlink/config_flow.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/dlink/__init__.py b/homeassistant/components/dlink/__init__.py index 528e5182b31..40fce4acf76 100644 --- a/homeassistant/components/dlink/__init__.py +++ b/homeassistant/components/dlink/__init__.py @@ -23,7 +23,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: entry.data[CONF_USERNAME], entry.data[CONF_USE_LEGACY_PROTOCOL], ) - if not smartplug.authenticated and entry.data[CONF_USE_LEGACY_PROTOCOL]: + if not smartplug.authenticated and smartplug.use_legacy_protocol: raise ConfigEntryNotReady("Cannot connect/authenticate") hass.data.setdefault(DOMAIN, {})[entry.entry_id] = SmartPlugData(smartplug) diff --git a/homeassistant/components/dlink/config_flow.py b/homeassistant/components/dlink/config_flow.py index 686448cfd81..4499e2efffc 100644 --- a/homeassistant/components/dlink/config_flow.py +++ b/homeassistant/components/dlink/config_flow.py @@ -131,6 +131,6 @@ class DLinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): except Exception as ex: # pylint: disable=broad-except _LOGGER.exception("Unexpected exception: %s", ex) return "unknown" - if smartplug.authenticated: - return None - return "cannot_connect" + if not smartplug.authenticated and smartplug.use_legacy_protocol: + return "cannot_connect" + return None