Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce Freebox router Raid warning to one occurence #98740

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 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,21 @@ async def _update_disks_sensors(self) -> None:

async def _update_raids_sensors(self) -> None:
"""Update Freebox raids."""
# None at first request
if not self.supports_raid:
return

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
self.supports_raid = False
_LOGGER.info(
"Router %s API does not support RAID",
self.name,
)
return

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