mirror of
https://github.com/home-assistant/core.git
synced 2026-05-30 12:14:20 +01:00
d766aae436
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: frenck <195327+frenck@users.noreply.github.com>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""The Yardian integration."""
|
|
|
|
from pyyardian import AsyncYardianClient
|
|
|
|
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST, Platform
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|
|
|
from .coordinator import YardianConfigEntry, YardianUpdateCoordinator
|
|
|
|
PLATFORMS: list[Platform] = [
|
|
Platform.BINARY_SENSOR,
|
|
Platform.SENSOR,
|
|
Platform.SWITCH,
|
|
]
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: YardianConfigEntry) -> bool:
|
|
"""Set up Yardian from a config entry."""
|
|
|
|
host = entry.data[CONF_HOST]
|
|
access_token = entry.data[CONF_ACCESS_TOKEN]
|
|
|
|
controller = AsyncYardianClient(async_get_clientsession(hass), host, access_token)
|
|
coordinator = YardianUpdateCoordinator(hass, entry, controller)
|
|
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: YardianConfigEntry) -> bool:
|
|
"""Unload a config entry."""
|
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|