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