Skip to content

Commit

Permalink
consider Freebox router does not support Raid if the first enumeratio…
Browse files Browse the repository at this point in the history
…n raised an http error, fixes #98274
  • Loading branch information
fthiery committed Aug 21, 2023
1 parent a713d75 commit a2f9800
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions homeassistant/components/freebox/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(

self.devices: dict[str, dict[str, Any]] = {}
self.disks: dict[int, dict[str, Any]] = {}
self.supports_raid = True
self.raids: dict[int, dict[str, Any]] = {}
self.sensors_temperature: dict[str, int] = {}
self.sensors_connection: dict[str, float] = {}
Expand Down Expand Up @@ -159,14 +160,19 @@ async def _update_disks_sensors(self) -> None:

async def _update_raids_sensors(self) -> None:
"""Update Freebox raids."""
# None at first request
try:
fbx_raids: list[dict[str, Any]] = await self._api.storage.get_raids() or []
except HttpRequestError:
_LOGGER.warning("Unable to enumerate raid disks")
else:
for fbx_raid in fbx_raids:
self.raids[fbx_raid["id"]] = fbx_raid
if self.supports_raid:
try:
fbx_raids: list[dict[str, Any]] = (
await self._api.storage.get_raids() or []
)
except HttpRequestError:
_LOGGER.warning(
"This router model apparently does not support raid, will not enumerate further"
)
self.supports_raid = False
else:
for fbx_raid in fbx_raids:
self.raids[fbx_raid["id"]] = fbx_raid

async def update_home_devices(self) -> None:
"""Update Home devices (alarm, light, sensor, switch, remote ...)."""
Expand Down

0 comments on commit a2f9800

Please sign in to comment.