Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The SimpleFIN integration."""
2 
3 from __future__ import annotations
4 
5 from simplefin4py import SimpleFin
6 
7 from homeassistant.config_entries import ConfigEntry
8 from homeassistant.const import Platform
9 from homeassistant.core import HomeAssistant
10 
11 from .const import CONF_ACCESS_URL
12 from .coordinator import SimpleFinDataUpdateCoordinator
13 
14 PLATFORMS: list[str] = [
15  Platform.BINARY_SENSOR,
16  Platform.SENSOR,
17 ]
18 
19 
20 type SimpleFinConfigEntry = ConfigEntry[SimpleFinDataUpdateCoordinator]
21 
22 
23 async def async_setup_entry(hass: HomeAssistant, entry: SimpleFinConfigEntry) -> bool:
24  """Set up from a config entry."""
25  access_url = entry.data[CONF_ACCESS_URL]
26  sf_client = SimpleFin(access_url)
27  sf_coordinator = SimpleFinDataUpdateCoordinator(hass, sf_client)
28  await sf_coordinator.async_config_entry_first_refresh()
29  entry.runtime_data = sf_coordinator
30  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
31  return True
32 
33 
34 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
35  """Unload a config entry."""
36  return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_setup_entry(HomeAssistant hass, SimpleFinConfigEntry entry)
Definition: __init__.py:23
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:34