-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoordinator.py
More file actions
39 lines (29 loc) · 1.04 KB
/
coordinator.py
File metadata and controls
39 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Component to embed nexia devices."""
from __future__ import annotations
from datetime import timedelta
import logging
from typing import Any
from .nexiaux360.home import NexiaHome
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
_LOGGER = logging.getLogger(__name__)
DEFAULT_UPDATE_RATE = 120
class NexiaDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
"""DataUpdateCoordinator for nexia homes."""
def __init__(
self,
hass: HomeAssistant,
nexia_home: NexiaHome,
) -> None:
"""Initialize DataUpdateCoordinator for the nexia home."""
self.nexia_home = nexia_home
super().__init__(
hass,
_LOGGER,
name="Nexia update",
update_interval=timedelta(seconds=DEFAULT_UPDATE_RATE),
always_update=False,
)
async def _async_update_data(self) -> dict[str, Any]:
"""Fetch data from API endpoint."""
return await self.nexia_home.update()