Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cyr-ius committed May 8, 2024
1 parent b6737dd commit b9d8d93
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions custom_components/bbox/coordinator.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"""Corddinator for Bbox."""

from __future__ import annotations

import logging
from datetime import timedelta
import logging
from typing import Any

from bboxpy import Bbox

from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
Expand All @@ -17,7 +19,7 @@


class BboxDataUpdateCoordinator(DataUpdateCoordinator):
"""Define an object to fetch datas."""
"""Define an object to fetch data."""

def __init__(
self,
Expand All @@ -36,7 +38,7 @@ def __init__(
)

async def _async_update_data(self) -> dict[str, dict[str, Any]]:
"""Fetch datas."""
"""Fetch data."""
try:
bbox_info = self.check_list(await self.bbox.device.async_get_bbox_info())
devices = self.check_list(await self.bbox.lan.async_get_connected_devices())
Expand All @@ -46,27 +48,27 @@ async def _async_update_data(self) -> dict[str, dict[str, Any]]:
# lan_stats = self.check_list(await self.bbox.lan.async_get_lan_stats())
# voicemail = self.check_list(await self.bbox.voip.async_get_voip_voicemail())
# device_info = self.check_list(await self.bbox.lan.async_get_device_infos())

return {
"info": bbox_info,
"devices": devices,
"wan_ip_stats": wan_ip_stats,
# "wan": wan,
# "iptv_channels_infos": iptv_channels_infos,
# "lan_stats": lan_stats,
# "voicemail": voicemail,
# "device_info": device_info,
}
except Exception as error:
_LOGGER.error(error)
raise UpdateFailed from error

return {
"info": bbox_info,
"devices": devices,
"wan_ip_stats": wan_ip_stats,
# "wan": wan,
# "iptv_channels_infos": iptv_channels_infos,
# "lan_stats": lan_stats,
# "voicemail": voicemail,
# "device_info": device_info,
}

@staticmethod
def check_list(obj: dict[str, dict[str, Any]]) -> dict[str, Any]:
"""Return element if one only."""
if isinstance(obj, list) and len(obj) == 1:
return obj[0]
else:
raise UpdateFailed(
"The call is not a list or it contains more than one element"
)

raise UpdateFailed(
"The call is not a list or it contains more than one element"
)

0 comments on commit b9d8d93

Please sign in to comment.