1 """DataUpdateCoordinator for the BSB-Lan integration."""
3 from dataclasses
import dataclass
4 from datetime
import timedelta
5 from random
import randint
7 from bsblan
import BSBLAN, BSBLANConnectionError, HotWaterState, Sensor, State
14 from .const
import DOMAIN, LOGGER, SCAN_INTERVAL
19 """BSBLan data stored in the Home Assistant data object."""
27 """The BSB-Lan update coordinator."""
29 config_entry: ConfigEntry
34 config_entry: ConfigEntry,
37 """Initialize the BSB-Lan coordinator."""
41 name=f
"{DOMAIN}_{config_entry.data[CONF_HOST]}",
47 """Get the update interval with a random offset.
49 Use the default scan interval and add a random number of seconds to avoid timeouts when
50 the BSB-Lan device is already/still busy retrieving data,
51 e.g. for MQTT or internal logging.
53 return SCAN_INTERVAL +
timedelta(seconds=randint(1, 8))
56 """Get state and sensor data from BSB-Lan device."""
59 await self.
clientclient.initialize()
62 sensor = await self.
clientclient.sensor()
63 dhw = await self.
clientclient.hot_water_state()
64 except BSBLANConnectionError
as err:
67 f
"Error while establishing connection with BSB-Lan device at {host}"
None __init__(self, HomeAssistant hass, ConfigEntry config_entry, BSBLAN client)
BSBLanCoordinatorData _async_update_data(self)
timedelta _get_update_interval(self)
None update_interval(self, timedelta|None value)
timedelta|None update_interval(self)
bool state(HomeAssistant hass, str|State|None entity, Any req_state, timedelta|None for_period=None, str|None attribute=None, TemplateVarsType variables=None)