async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Rituals Perfume Genie from a config entry.""" session = async_get_clientsession(hass) account = Account(EMPTY_CREDENTIALS, EMPTY_CREDENTIALS, session) account.data = {ACCOUNT_HASH: entry.data.get(ACCOUNT_HASH)} try: account_devices = await account.get_devices() except aiohttp.ClientError as err: raise ConfigEntryNotReady from err hass.data.setdefault(DOMAIN, {})[entry.entry_id] = { COORDINATORS: {}, DEVICES: {}, } for device in account_devices: hublot = device.hub_data[HUBLOT] coordinator = RitualsDataUpdateCoordinator(hass, device) await coordinator.async_refresh() hass.data[DOMAIN][entry.entry_id][DEVICES][hublot] = device hass.data[DOMAIN][entry.entry_id][COORDINATORS][hublot] = coordinator hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Rituals Perfume Genie from a config entry.""" session = async_get_clientsession(hass) account = Account(EMPTY_CREDENTIALS, EMPTY_CREDENTIALS, session) account.data = {ACCOUNT_HASH: entry.data.get(ACCOUNT_HASH)} try: await account.get_devices() except ClientConnectorError as ex: raise ConfigEntryNotReady from ex hass.data.setdefault(DOMAIN, {})[entry.entry_id] = account for component in PLATFORMS: hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, component)) return True