From ab9aa4466e9390b356387a441483755aa4adf5e8 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 19 May 2021 23:15:00 +0200 Subject: [PATCH] Fix SolarEdge active check on entry setup (#50873) --- homeassistant/components/solaredge/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/solaredge/__init__.py b/homeassistant/components/solaredge/__init__.py index df38756cd69..cb56817fe87 100644 --- a/homeassistant/components/solaredge/__init__.py +++ b/homeassistant/components/solaredge/__init__.py @@ -25,17 +25,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: response = await hass.async_add_executor_job( api.get_details, entry.data[CONF_SITE_ID] ) - except KeyError as ex: - LOGGER.error("Missing details data in SolarEdge response") - raise ConfigEntryNotReady from ex except (ConnectTimeout, HTTPError) as ex: LOGGER.error("Could not retrieve details from SolarEdge API") raise ConfigEntryNotReady from ex - if response["details"]["status"].lower() != "active": + if "details" not in response: + LOGGER.error("Missing details data in SolarEdge response") + raise ConfigEntryNotReady + + if response["details"].get("status", "").lower() != "active": LOGGER.error("SolarEdge site is not active") return False - LOGGER.debug("Credentials correct and site is active") hass.data.setdefault(DOMAIN, {})[entry.entry_id] = {DATA_API_CLIENT: api} hass.config_entries.async_setup_platforms(entry, PLATFORMS)