mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Avoid closing shared aiohttp session in Vodafone Station (#146471)
This commit is contained in:
parent
d71ddcf69e
commit
936d56f9af
@ -37,7 +37,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: VodafoneConfigEntry) ->
|
|||||||
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
||||||
coordinator = entry.runtime_data
|
coordinator = entry.runtime_data
|
||||||
await coordinator.api.logout()
|
await coordinator.api.logout()
|
||||||
await coordinator.api.close()
|
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
@ -48,7 +48,6 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
|
|||||||
await api.login()
|
await api.login()
|
||||||
finally:
|
finally:
|
||||||
await api.logout()
|
await api.logout()
|
||||||
await api.close()
|
|
||||||
|
|
||||||
return {"title": data[CONF_HOST]}
|
return {"title": data[CONF_HOST]}
|
||||||
|
|
||||||
|
@ -117,32 +117,29 @@ class VodafoneStationRouter(DataUpdateCoordinator[UpdateCoordinatorDataType]):
|
|||||||
async def _async_update_data(self) -> UpdateCoordinatorDataType:
|
async def _async_update_data(self) -> UpdateCoordinatorDataType:
|
||||||
"""Update router data."""
|
"""Update router data."""
|
||||||
_LOGGER.debug("Polling Vodafone Station host: %s", self._host)
|
_LOGGER.debug("Polling Vodafone Station host: %s", self._host)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
try:
|
await self.api.login()
|
||||||
await self.api.login()
|
raw_data_devices = await self.api.get_devices_data()
|
||||||
raw_data_devices = await self.api.get_devices_data()
|
data_sensors = await self.api.get_sensor_data()
|
||||||
data_sensors = await self.api.get_sensor_data()
|
await self.api.logout()
|
||||||
await self.api.logout()
|
except exceptions.CannotAuthenticate as err:
|
||||||
except exceptions.CannotAuthenticate as err:
|
raise ConfigEntryAuthFailed(
|
||||||
raise ConfigEntryAuthFailed(
|
translation_domain=DOMAIN,
|
||||||
translation_domain=DOMAIN,
|
translation_key="cannot_authenticate",
|
||||||
translation_key="cannot_authenticate",
|
translation_placeholders={"error": repr(err)},
|
||||||
translation_placeholders={"error": repr(err)},
|
) from err
|
||||||
) from err
|
except (
|
||||||
except (
|
exceptions.CannotConnect,
|
||||||
exceptions.CannotConnect,
|
exceptions.AlreadyLogged,
|
||||||
exceptions.AlreadyLogged,
|
exceptions.GenericLoginError,
|
||||||
exceptions.GenericLoginError,
|
JSONDecodeError,
|
||||||
JSONDecodeError,
|
) as err:
|
||||||
) as err:
|
raise UpdateFailed(
|
||||||
raise UpdateFailed(
|
translation_domain=DOMAIN,
|
||||||
translation_domain=DOMAIN,
|
translation_key="update_failed",
|
||||||
translation_key="update_failed",
|
translation_placeholders={"error": repr(err)},
|
||||||
translation_placeholders={"error": repr(err)},
|
) from err
|
||||||
) from err
|
|
||||||
except (ConfigEntryAuthFailed, UpdateFailed):
|
|
||||||
await self.api.close()
|
|
||||||
raise
|
|
||||||
|
|
||||||
utc_point_in_time = dt_util.utcnow()
|
utc_point_in_time = dt_util.utcnow()
|
||||||
data_devices = {
|
data_devices = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user