Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The iotawatt integration."""
2 
3 from homeassistant.config_entries import ConfigEntry
4 from homeassistant.const import Platform
5 from homeassistant.core import HomeAssistant
6 
7 from .const import DOMAIN
8 from .coordinator import IotawattUpdater
9 
10 PLATFORMS = [Platform.SENSOR]
11 
12 
13 async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
14  """Set up iotawatt from a config entry."""
15  coordinator = IotawattUpdater(hass, entry)
16  await coordinator.async_config_entry_first_refresh()
17  hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
18  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
19  return True
20 
21 
22 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
23  """Unload a config entry."""
24  if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
25  hass.data[DOMAIN].pop(entry.entry_id)
26  return unload_ok
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:22
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:13