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