Address late review comments for Comelit login (#102768)

This commit is contained in:
Simone Chemelli 2023-10-25 11:19:06 +02:00 committed by GitHub
parent dfc454d527
commit 4328f887be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,15 +68,13 @@ class ComelitSerialBridge(DataUpdateCoordinator):
async def _async_update_data(self) -> dict[str, Any]: async def _async_update_data(self) -> dict[str, Any]:
"""Update device data.""" """Update device data."""
_LOGGER.debug("Polling Comelit Serial Bridge host: %s", self._host) _LOGGER.debug("Polling Comelit Serial Bridge host: %s", self._host)
logged = False
try: try:
logged = await self.api.login() await self.api.login()
except exceptions.CannotConnect as err: except exceptions.CannotConnect as err:
_LOGGER.warning("Connection error for %s", self._host) _LOGGER.warning("Connection error for %s", self._host)
await self.api.close() await self.api.close()
raise UpdateFailed(f"Error fetching data: {repr(err)}") from err raise UpdateFailed(f"Error fetching data: {repr(err)}") from err
finally: except exceptions.CannotAuthenticate:
if not logged: raise ConfigEntryAuthFailed
raise ConfigEntryAuthFailed
return await self.api.get_all_devices() return await self.api.get_all_devices()