From 2ac7d11b8d0a68cadb441a2a1401602204d21117 Mon Sep 17 00:00:00 2001 From: Robert Hillis Date: Fri, 16 Feb 2024 05:22:30 -0500 Subject: [PATCH] Mitigate session closed error in Netgear LTE (#110412) --- homeassistant/components/netgear_lte/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/netgear_lte/__init__.py b/homeassistant/components/netgear_lte/__init__.py index 9faa2f361b9556..491ee0efe5980e 100644 --- a/homeassistant/components/netgear_lte/__init__.py +++ b/homeassistant/components/netgear_lte/__init__.py @@ -212,7 +212,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: host = entry.data[CONF_HOST] password = entry.data[CONF_PASSWORD] - if DOMAIN not in hass.data: + if not (data := hass.data.get(DOMAIN)) or data.websession.closed: websession = async_create_clientsession(hass, cookie_jar=CookieJar(unsafe=True)) hass.data[DOMAIN] = LTEData(websession) @@ -258,7 +258,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: if entry.state == ConfigEntryState.LOADED ] if len(loaded_entries) == 1: - hass.data.pop(DOMAIN) + hass.data.pop(DOMAIN, None) return unload_ok