core/homeassistant/components/stookalert/__init__.py

29 lines
934 B
Python
Raw Normal View History

2021-10-08 09:34:22 +00:00
"""The Stookalert integration."""
from __future__ import annotations
import stookalert
from homeassistant.config_entries import ConfigEntry
2021-12-04 12:43:48 +00:00
from homeassistant.const import Platform
2021-10-08 09:34:22 +00:00
from homeassistant.core import HomeAssistant
from .const import CONF_PROVINCE, DOMAIN
2021-12-04 12:43:48 +00:00
PLATFORMS = [Platform.BINARY_SENSOR]
2021-10-08 09:34:22 +00:00
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Stookalert from a config entry."""
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = stookalert.stookalert(entry.data[CONF_PROVINCE])
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload Stookalert config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
del hass.data[DOMAIN][entry.entry_id]
return unload_ok