hass-reos-integration/custom_components/reos_integration/coordinator.py

34 lines
893 B
Python

from datetime import timedelta
import logging
import async_timeout
from homeassistant.components.light import LightEntity
from homeassistant.core import callback
from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
DataUpdateCoordinator,
UpdateFailed,
)
from .const import DOMAIN
from .reos_api import ReosApi
_LOGGER = logging.getLogger(__name__)
class ReosCoordinator(DataUpdateCoordinator):
def __init__(self, hass, api: ReosApi):
super().__init__(
hass,
_LOGGER,
name="Reos Locks",
update_interval=timedelta(hours=6),
)
self.api = api
async def _async_update_data(self):
_LOGGER.info("_async_update_data")
locks = await self.api.get_locks()
return {lock.lock_id: lock for lock in locks}