Move mill coordinator to separate module (#117493)

This commit is contained in:
epenet 2024-05-15 13:52:32 +02:00 committed by GitHub
parent 4803db7cf0
commit 60193a3c2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 27 deletions

View file

@ -0,0 +1,38 @@
"""Coordinator for the mill component."""
from __future__ import annotations
from datetime import timedelta
import logging
from mill import Mill
from mill_local import Mill as MillLocal
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
class MillDataUpdateCoordinator(DataUpdateCoordinator):
"""Class to manage fetching Mill data."""
def __init__(
self,
hass: HomeAssistant,
update_interval: timedelta | None = None,
*,
mill_data_connection: Mill | MillLocal,
) -> None:
"""Initialize global Mill data updater."""
self.mill_data_connection = mill_data_connection
super().__init__(
hass,
_LOGGER,
name=DOMAIN,
update_method=mill_data_connection.fetch_heater_and_sensor_data,
update_interval=update_interval,
)