1 """The Schlage integration."""
3 from __future__
import annotations
5 from pycognito.exceptions
import WarrantException
13 from .const
import DOMAIN
14 from .coordinator
import SchlageDataUpdateCoordinator
16 PLATFORMS: list[Platform] = [
17 Platform.BINARY_SENSOR,
26 """Set up Schlage from a config entry."""
27 username = entry.data[CONF_USERNAME]
28 password = entry.data[CONF_PASSWORD]
30 auth = await hass.async_add_executor_job(pyschlage.Auth, username, password)
31 except WarrantException
as ex:
32 raise ConfigEntryAuthFailed
from ex
35 hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
36 await coordinator.async_config_entry_first_refresh()
37 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
42 """Unload a config entry."""
43 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
44 hass.data[DOMAIN].pop(entry.entry_id)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)