Improve reliability of august setup with recent api changes (#65314)

This commit is contained in:
J. Nick Koston 2022-01-31 10:21:47 -06:00 committed by Paulus Schoutsen
parent 7117395489
commit 961cf15e6e

View File

@ -206,12 +206,28 @@ class AugustData(AugustSubscriberMixin):
await self._async_refresh_device_detail_by_ids(self._subscriptions.keys()) await self._async_refresh_device_detail_by_ids(self._subscriptions.keys())
async def _async_refresh_device_detail_by_ids(self, device_ids_list): async def _async_refresh_device_detail_by_ids(self, device_ids_list):
await asyncio.gather( """Refresh each device in sequence.
*(
self._async_refresh_device_detail_by_id(device_id) This used to be a gather but it was less reliable with august's
for device_id in device_ids_list recent api changes.
)
) The august api has been timing out for some devices so
we want the ones that it isn't timing out for to keep working.
"""
for device_id in device_ids_list:
try:
await self._async_refresh_device_detail_by_id(device_id)
except asyncio.TimeoutError:
_LOGGER.warning(
"Timed out calling august api during refresh of device: %s",
device_id,
)
except (ClientResponseError, CannotConnect) as err:
_LOGGER.warning(
"Error from august api during refresh of device: %s",
device_id,
exc_info=err,
)
async def _async_refresh_device_detail_by_id(self, device_id): async def _async_refresh_device_detail_by_id(self, device_id):
if device_id in self._locks_by_id: if device_id in self._locks_by_id: