hass-core/homeassistant/components/devialet/coordinator.py
fwestenberg d3b04a5a58
Add Devialet integration (#86551)
* Add Devialet

* Bump Devialet==1.4.0

* Bump Devialet==1.4.1

* Sort manifest and add shorthand

* Black formatting

* Fix incompatible type

* Add type guarding for name

* Rename host keywork in tests

* Fix Devialet tests

* Add update coordinator

* Update devialet tests

* Create unique_id from entry data
2023-11-28 13:56:17 +01:00

32 lines
867 B
Python

"""Class representing a Devialet update coordinator."""
from datetime import timedelta
import logging
from devialet import DevialetApi
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
SCAN_INTERVAL = timedelta(seconds=5)
class DevialetCoordinator(DataUpdateCoordinator):
"""Devialet update coordinator."""
def __init__(self, hass: HomeAssistant, client: DevialetApi) -> None:
"""Initialize the coordinator."""
super().__init__(
hass,
_LOGGER,
name=DOMAIN,
update_interval=SCAN_INTERVAL,
)
self.client = client
async def _async_update_data(self):
"""Fetch data from API endpoint."""
await self.client.async_update()