1 """The IntelliFire integration."""
3 from __future__
import annotations
8 from pyflume
import FlumeAuth, FlumeData, FlumeDeviceList
15 DEVICE_CONNECTION_SCAN_INTERVAL,
18 NOTIFICATION_SCAN_INTERVAL,
23 """Data update coordinator for an individual flume device."""
25 def __init__(self, hass: HomeAssistant, flume_device: FlumeData) ->
None:
26 """Initialize the Coordinator."""
31 update_interval=DEVICE_SCAN_INTERVAL,
37 """Get the latest data from the Flume."""
39 await self.
hasshass.async_add_executor_job(self.
flume_deviceflume_device.update_force)
40 except Exception
as ex:
41 raise UpdateFailed(f
"Error communicating with flume API: {ex}")
from ex
43 "Flume Device Data Update values=%s query_payload=%s",
50 """Date update coordinator to read connected status from Devices endpoint."""
52 def __init__(self, hass: HomeAssistant, flume_devices: FlumeDeviceList) ->
None:
53 """Initialize the Coordinator."""
58 update_interval=DEVICE_CONNECTION_SCAN_INTERVAL,
62 self.
connectedconnected: dict[str, bool] = {}
65 """Update device connectivity.."""
67 device[
"id"]: device[
"connected"]
70 _LOGGER.debug(
"Connectivity %s", self.
connectedconnected)
73 """Update the device list."""
76 except Exception
as ex:
77 raise UpdateFailed(f
"Error communicating with flume API: {ex}")
from ex
81 """Data update coordinator for flume notifications."""
83 def __init__(self, hass: HomeAssistant, auth: FlumeAuth) ->
None:
84 """Initialize the Coordinator."""
89 update_interval=NOTIFICATION_SCAN_INTERVAL,
96 """Query flume for notification list."""
101 self.
authauth, read=
None
103 _LOGGER.debug(
"Notifications %s", self.
notificationsnotifications)
105 active_notifications_by_device: dict[str, set[str]] = {}
109 not notification.get(
"device_id")
110 or not notification.get(
"extra")
111 or "event_rule_name" not in notification[
"extra"]
114 device_id = notification[
"device_id"]
115 rule = notification[
"extra"][
"event_rule_name"]
116 active_notifications_by_device.setdefault(device_id, set()).
add(rule)
122 _LOGGER.debug(
"Updating Flume Notification")
125 except Exception
as ex:
126 raise UpdateFailed(f
"Error communicating with flume API: {ex}")
from ex
None _async_update_data(self)
None __init__(self, HomeAssistant hass, FlumeDeviceList flume_devices)
None _update_connectivity(self)
None _async_update_data(self)
None __init__(self, HomeAssistant hass, FlumeData flume_device)
None _async_update_data(self)
None __init__(self, HomeAssistant hass, FlumeAuth auth)
active_notifications_by_device
bool add(self, _T matcher)