1
0
mirror of https://github.com/natekspencer/hacs-oasis_mini.git synced 2025-11-14 16:13:51 -05:00

Better error handling

This commit is contained in:
Nathan Spencer
2024-08-03 17:31:30 -06:00
parent a44c035828
commit 33e62528ba
9 changed files with 1978 additions and 828 deletions

View File

@@ -47,15 +47,14 @@ class OasisMiniCoordinator(DataUpdateCoordinator[str]):
if not self.device.software_version:
await self.device.async_get_software_version()
data = await self.device.async_get_status()
self.attempt = 0
await self.device.async_get_current_track_details()
await self.device.async_get_playlist_details()
except Exception as ex: # pylint:disable=broad-except
if self.attempt > 2 or not self.data:
if self.attempt > 2 or not (data or self.data):
raise UpdateFailed(
f"Couldn't read from the Oasis Mini after {self.attempt} attempts"
) from ex
else:
self.attempt = 0
if data != self.data:
self.last_updated = datetime.now()