1 """The mütesync integration."""
3 from __future__
import annotations
16 from .const
import DOMAIN, UPDATE_INTERVAL_IN_MEETING, UPDATE_INTERVAL_NOT_IN_MEETING
18 PLATFORMS = [Platform.BINARY_SENSOR]
22 """Set up mütesync from a config entry."""
23 client = mutesync.PyMutesync(
29 async
def update_data():
30 """Update the data."""
31 async
with asyncio.timeout(2.5):
32 state = await client.get_state()
34 if state[
"muted"]
is None or state[
"in_meeting"]
is None:
35 raise update_coordinator.UpdateFailed(
"Got invalid response")
37 if state[
"in_meeting"]:
38 coordinator.update_interval = UPDATE_INTERVAL_IN_MEETING
40 coordinator.update_interval = UPDATE_INTERVAL_NOT_IN_MEETING
44 coordinator = hass.data.setdefault(DOMAIN, {})[entry.entry_id] = (
45 update_coordinator.DataUpdateCoordinator(
47 logging.getLogger(__name__),
50 update_interval=UPDATE_INTERVAL_NOT_IN_MEETING,
51 update_method=update_data,
54 await coordinator.async_config_entry_first_refresh()
56 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
62 """Unload a config entry."""
63 unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
65 hass.data[DOMAIN].pop(entry.entry_id)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)