1 """SwitchBot Cloud coordinator."""
3 from asyncio
import timeout
4 from logging
import getLogger
7 from switchbot_api
import CannotConnect, Device, Remote, SwitchBotAPI
12 from .const
import DEFAULT_SCAN_INTERVAL, DOMAIN
14 _LOGGER = getLogger(__name__)
16 type Status = dict[str, Any] |
None
20 """SwitchBot Cloud coordinator."""
26 self, hass: HomeAssistant, api: SwitchBotAPI, device: Device | Remote
28 """Initialize SwitchBot Cloud."""
33 update_interval=DEFAULT_SCAN_INTERVAL,
40 """Fetch data from API endpoint."""
44 _LOGGER.debug(
"Refreshing %s", self.
_device_id_device_id)
45 async
with timeout(10):
47 _LOGGER.debug(
"Refreshing %s with %s", self.
_device_id_device_id, status)
49 except CannotConnect
as err:
50 raise UpdateFailed(f
"Error communicating with API: {err}")
from err
None __init__(self, HomeAssistant hass, SwitchBotAPI api, Device|Remote device)
Status _async_update_data(self)
def get_status(hass, host, port)