Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The Stookalert integration."""
2 
3 from __future__ import annotations
4 
5 import stookalert
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_PROVINCE, DOMAIN
12 
13 PLATFORMS = [Platform.BINARY_SENSOR]
14 
15 
16 async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
17  """Set up Stookalert from a config entry."""
18  hass.data.setdefault(DOMAIN, {})
19  hass.data[DOMAIN][entry.entry_id] = stookalert.stookalert(entry.data[CONF_PROVINCE])
20  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
21  return True
22 
23 
24 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
25  """Unload Stookalert config entry."""
26  unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
27  if unload_ok:
28  del hass.data[DOMAIN][entry.entry_id]
29  return unload_ok
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:24
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:16