1 """The Bang & Olufsen integration."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
7 from aiohttp.client_exceptions
import (
12 from mozart_api.exceptions
import ApiException
13 from mozart_api.mozart_client
import MozartClient
22 from .const
import DOMAIN
23 from .websocket
import BangOlufsenWebsocket
28 """Dataclass for API client and WebSocket client."""
30 websocket: BangOlufsenWebsocket
34 type BangOlufsenConfigEntry = ConfigEntry[BangOlufsenData]
36 PLATFORMS = [Platform.MEDIA_PLAYER]
40 """Set up from a config entry."""
43 assert entry.unique_id
46 device_registry = dr.async_get(hass)
47 device_registry.async_get_or_create(
48 config_entry_id=entry.entry_id,
49 identifiers={(DOMAIN, entry.unique_id)},
51 model=entry.data[CONF_MODEL],
58 await client.check_device_connection(
True)
66 await client.close_api_client()
75 await client.connect_notifications(remote_control=
True, reconnect=
True)
77 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
83 hass: HomeAssistant, entry: BangOlufsenConfigEntry
85 """Unload a config entry."""
87 entry.runtime_data.client.disconnect_notifications()
88 await entry.runtime_data.client.close_api_client()
90 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_unload_entry(HomeAssistant hass, BangOlufsenConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, BangOlufsenConfigEntry entry)
ssl.SSLContext get_default_context()