1 """Update coordinators for Yardian."""
3 from __future__
import annotations
9 from pyyardian
import (
12 NotAuthorizedException,
21 from .const
import DOMAIN, MANUFACTURER
23 _LOGGER = logging.getLogger(__name__)
25 SCAN_INTERVAL = datetime.timedelta(seconds=30)
29 """Coordinator for Yardian API calls."""
35 controller: AsyncYardianClient,
37 """Initialize Yardian API communication."""
42 update_interval=SCAN_INTERVAL,
47 self.
yidyid = entry.data[
"yid"]
49 self.
_model_model = entry.data[
"model"]
53 """Return information about the device."""
56 identifiers={(DOMAIN, self.
yidyid)},
57 manufacturer=MANUFACTURER,
62 """Fetch data from Yardian device."""
64 async
with asyncio.timeout(10):
65 return await self.
controllercontroller.fetch_device_state()
67 except TimeoutError
as e:
68 raise UpdateFailed(
"Communication with Device was time out")
from e
69 except NotAuthorizedException
as e:
71 except NetworkException
as e:
72 raise UpdateFailed(
"Failed to communicate with Device")
from e
YardianDeviceState _async_update_data(self)
None __init__(self, HomeAssistant hass, ConfigEntry entry, AsyncYardianClient controller)
DeviceInfo device_info(self)