Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The dwd_weather_warnings component."""
2 
3 from __future__ import annotations
4 
5 from homeassistant.core import HomeAssistant
6 from homeassistant.helpers import device_registry as dr
7 
8 from .const import DOMAIN, PLATFORMS
9 from .coordinator import DwdWeatherWarningsConfigEntry, DwdWeatherWarningsCoordinator
10 
11 
13  hass: HomeAssistant, entry: DwdWeatherWarningsConfigEntry
14 ) -> bool:
15  """Set up a config entry."""
16  device_registry = dr.async_get(hass)
17  if device_registry.async_get_device(identifiers={(DOMAIN, entry.entry_id)}):
18  device_registry.async_clear_config_entry(entry.entry_id)
19  coordinator = DwdWeatherWarningsCoordinator(hass)
20  await coordinator.async_config_entry_first_refresh()
21 
22  entry.runtime_data = coordinator
23  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
24 
25  return True
26 
27 
29  hass: HomeAssistant, entry: DwdWeatherWarningsConfigEntry
30 ) -> bool:
31  """Unload a config entry."""
32  return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_setup_entry(HomeAssistant hass, DwdWeatherWarningsConfigEntry entry)
Definition: __init__.py:14
bool async_unload_entry(HomeAssistant hass, DwdWeatherWarningsConfigEntry entry)
Definition: __init__.py:30