mirror of
https://github.com/natekspencer/hacs-oasis_mini.git
synced 2025-12-06 18:44:14 -05:00
Update coordinator to not fail if no devices have been initialized
This commit is contained in:
@@ -129,29 +129,18 @@ class OasisDeviceCoordinator(DataUpdateCoordinator[list[OasisDevice]]):
|
|||||||
except Exception:
|
except Exception:
|
||||||
_LOGGER.exception("Error fetching playlists from cloud")
|
_LOGGER.exception("Error fetching playlists from cloud")
|
||||||
|
|
||||||
any_success = False
|
|
||||||
|
|
||||||
for device in devices:
|
for device in devices:
|
||||||
try:
|
try:
|
||||||
ready = await self.mqtt_client.wait_until_ready(
|
ready = await self.mqtt_client.wait_until_ready(
|
||||||
device, request_status=True
|
device, request_status=True
|
||||||
)
|
)
|
||||||
if not ready:
|
if not ready:
|
||||||
_LOGGER.warning(
|
_LOGGER.debug(
|
||||||
"Timeout waiting for Oasis device %s to be ready",
|
"Oasis device %s not ready yet; will retry on next update",
|
||||||
device.serial_number,
|
device.serial_number,
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
mac = await device.async_get_mac_address()
|
|
||||||
if not mac:
|
|
||||||
_LOGGER.warning(
|
|
||||||
"Could not get MAC address for Oasis device %s",
|
|
||||||
device.serial_number,
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
|
|
||||||
any_success = True
|
|
||||||
device.schedule_track_refresh()
|
device.schedule_track_refresh()
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -159,17 +148,7 @@ class OasisDeviceCoordinator(DataUpdateCoordinator[list[OasisDevice]]):
|
|||||||
"Error preparing Oasis device %s", device.serial_number
|
"Error preparing Oasis device %s", device.serial_number
|
||||||
)
|
)
|
||||||
|
|
||||||
if any_success:
|
|
||||||
self.attempt = 0
|
self.attempt = 0
|
||||||
else:
|
|
||||||
if self.attempt > 2 or not self.data:
|
|
||||||
raise UpdateFailed(
|
|
||||||
"Couldn't read from any Oasis device "
|
|
||||||
f"after {self.attempt} attempts"
|
|
||||||
)
|
|
||||||
|
|
||||||
except UpdateFailed:
|
|
||||||
raise
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
if self.attempt > 2 or not (devices or self.data):
|
if self.attempt > 2 or not (devices or self.data):
|
||||||
raise UpdateFailed(
|
raise UpdateFailed(
|
||||||
|
|||||||
@@ -327,7 +327,6 @@ class OasisMqttClient(OasisClientProtocol):
|
|||||||
# Wait for initialization
|
# Wait for initialization
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(is_initialized_event.wait(), timeout=timeout)
|
await asyncio.wait_for(is_initialized_event.wait(), timeout=timeout)
|
||||||
return True
|
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Timeout (%.1fs) waiting for initialization from %s",
|
"Timeout (%.1fs) waiting for initialization from %s",
|
||||||
@@ -335,6 +334,8 @@ class OasisMqttClient(OasisClientProtocol):
|
|||||||
serial,
|
serial,
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
async def async_get_mac_address(self, device: OasisDevice) -> str | None:
|
async def async_get_mac_address(self, device: OasisDevice) -> str | None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user