"""The Baby Tracker integration.""" from __future__ import annotations from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv from homeassistant.helpers.typing import ConfigType from .babytracker_api import BabyTrackerClient from .const import CONF_DEVICE_UUID, DEVICE_NAME, DOMAIN from .coordinator import BabyTrackerCoordinator from .services import async_setup_services PLATFORMS = [Platform.CALENDAR, Platform.SENSOR] CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN) async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async_setup_services(hass) return True async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: client = BabyTrackerClient( entry.data[CONF_EMAIL], entry.data[CONF_PASSWORD], device_uuid=entry.data[CONF_DEVICE_UUID], device_name=DEVICE_NAME, device_os_info=DEVICE_NAME, ) # A later login to a different account is then refused rather than mixed in. client.account_id = int(entry.unique_id) coordinator = BabyTrackerCoordinator(hass, entry, client) await coordinator.async_config_entry_first_refresh() entry.runtime_data = coordinator await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) return True async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)