mirror of
https://github.com/home-assistant/core.git
synced 2026-09-19 16:23:06 +01:00
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
"""The Yoto integration."""
|
|
|
|
from homeassistant.const import Platform
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.config_entry_oauth2_flow import (
|
|
OAuth2Session,
|
|
async_get_config_entry_implementation,
|
|
)
|
|
|
|
from .coordinator import YotoConfigEntry, YotoDataUpdateCoordinator
|
|
|
|
PLATFORMS: list[Platform] = [
|
|
Platform.BINARY_SENSOR,
|
|
Platform.MEDIA_PLAYER,
|
|
Platform.NUMBER,
|
|
Platform.SELECT,
|
|
Platform.SENSOR,
|
|
Platform.SWITCH,
|
|
Platform.TIME,
|
|
]
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: YotoConfigEntry) -> bool:
|
|
"""Set up Yoto from a config entry."""
|
|
implementation = await async_get_config_entry_implementation(hass, entry)
|
|
session = OAuth2Session(hass, entry, implementation)
|
|
|
|
await session.async_ensure_token_valid()
|
|
|
|
coordinator = YotoDataUpdateCoordinator(hass, entry, session)
|
|
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: YotoConfigEntry) -> bool:
|
|
"""Unload a Yoto config entry."""
|
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|