bug fixes
This commit is contained in:
30
custom_components/fpl/fplDataUpdateCoordinator.py
Normal file
30
custom_components/fpl/fplDataUpdateCoordinator.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import logging
|
||||
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
from homeassistant.core import HomeAssistant
|
||||
from datetime import timedelta
|
||||
|
||||
from .fplapi import FplApi
|
||||
from .const import DOMAIN
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=7200)
|
||||
|
||||
_LOGGER: logging.Logger = logging.getLogger(__package__)
|
||||
|
||||
|
||||
class FplDataUpdateCoordinator(DataUpdateCoordinator):
|
||||
"""Class to manage fetching data from the API."""
|
||||
|
||||
def __init__(self, hass: HomeAssistant, client: FplApi) -> None:
|
||||
"""Initialize."""
|
||||
self.api = client
|
||||
self.platforms = []
|
||||
|
||||
super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=SCAN_INTERVAL)
|
||||
|
||||
async def _async_update_data(self):
|
||||
"""Update data via library."""
|
||||
try:
|
||||
return await self.api.async_get_data()
|
||||
except Exception as exception:
|
||||
raise UpdateFailed() from exception
|
||||
Reference in New Issue
Block a user