1 """The loqed integration."""
3 from __future__
import annotations
9 from loqedAPI
import loqed
17 from .const
import DOMAIN
18 from .coordinator
import LoqedDataCoordinator
20 PLATFORMS: list[str] = [Platform.LOCK, Platform.SENSOR]
23 _LOGGER = logging.getLogger(__name__)
27 """Set up loqed from a config entry."""
29 host = entry.data[
"bridge_ip"]
30 apiclient = loqed.APIClient(websession, f
"http://{host}")
31 api = loqed.LoqedAPI(apiclient)
34 lock = await api.async_get_lock(
35 entry.data[
"lock_key_key"],
36 entry.data[
"bridge_key"],
37 int(entry.data[
"lock_key_local_id"]),
39 r"LOQED-([a-f0-9]+)\.local",
r"\1", entry.data[
"bridge_mdns_hostname"]
48 await coordinator.ensure_webhooks()
50 await coordinator.async_config_entry_first_refresh()
52 hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
54 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
59 """Unload a config entry."""
60 coordinator: LoqedDataCoordinator = hass.data[DOMAIN][entry.entry_id]
62 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
63 hass.data[DOMAIN].pop(entry.entry_id)
65 await coordinator.remove_webhooks()
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)