1 """The BleBox devices integration."""
5 from blebox_uniapi.box
import Box
6 from blebox_uniapi.error
import Error
7 from blebox_uniapi.session
import ApiHost
20 from .const
import DEFAULT_SETUP_TIMEOUT
21 from .helpers
import get_maybe_authenticated_session
23 type BleBoxConfigEntry = ConfigEntry[Box]
25 _LOGGER = logging.getLogger(__name__)
28 Platform.BINARY_SENSOR,
41 """Set up BleBox devices from a config entry."""
42 host = entry.data[CONF_HOST]
43 port = entry.data[CONF_PORT]
45 username = entry.data.get(CONF_USERNAME)
46 password = entry.data.get(CONF_PASSWORD)
48 timeout = DEFAULT_SETUP_TIMEOUT
52 api_host = ApiHost(host, port, timeout, websession, hass.loop)
55 product = await Box.async_from_host(api_host)
57 _LOGGER.error(
"Identify failed at %s:%d (%s)", api_host.host, api_host.port, ex)
58 raise ConfigEntryNotReady
from ex
60 entry.runtime_data = product
62 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
68 """Unload a config entry."""
69 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
aiohttp.ClientSession get_maybe_authenticated_session(HomeAssistant hass, str|None password, str|None username)
bool async_unload_entry(HomeAssistant hass, BleBoxConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, BleBoxConfigEntry entry)