Files
git 264a7dd42f
Validate / syntax (push) Canceled after 0s
Initial Up Banking Home Assistant integration
2026-09-27 17:36:54 +10:00

32 lines
1.2 KiB
Python

"""Up Banking integration setup."""
from __future__ import annotations
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .api import UpApi
from .const import CONF_TOKEN, DOMAIN, PLATFORMS
from .coordinator import UpCoordinator
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
coordinator = UpCoordinator(hass, entry, UpApi(async_get_clientsession(hass), entry.data[CONF_TOKEN]))
await coordinator.async_load()
await coordinator.async_config_entry_first_refresh()
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
entry.async_on_unload(entry.add_update_listener(_async_update_listener))
return True
async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
await hass.config_entries.async_reload(entry.entry_id)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
unloaded = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unloaded:
hass.data[DOMAIN].pop(entry.entry_id, None)
return unloaded