1 """The Nina integration."""
3 from __future__
import annotations
18 from .coordinator
import NINADataUpdateCoordinator
20 PLATFORMS: list[str] = [Platform.BINARY_SENSOR]
24 """Set up platform from a ConfigEntry."""
26 regions: dict[str, str] = entry.data[CONF_REGIONS]
28 if CONF_HEADLINE_FILTER
not in entry.data:
29 filter_regex = NO_MATCH_REGEX
31 if entry.data[CONF_FILTER_CORONA]:
32 filter_regex =
".*corona.*"
34 new_data = {**entry.data, CONF_HEADLINE_FILTER: filter_regex}
35 new_data.pop(CONF_FILTER_CORONA,
None)
36 hass.config_entries.async_update_entry(entry, data=new_data)
38 if CONF_AREA_FILTER
not in entry.data:
39 new_data = {**entry.data, CONF_AREA_FILTER: ALL_MATCH_REGEX}
40 hass.config_entries.async_update_entry(entry, data=new_data)
45 entry.data[CONF_HEADLINE_FILTER],
46 entry.data[CONF_AREA_FILTER],
49 await coordinator.async_config_entry_first_refresh()
51 entry.async_on_unload(entry.add_update_listener(_async_update_listener))
53 hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
55 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
61 """Unload a config entry."""
62 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
66 """Handle options update."""
67 await hass.config_entries.async_reload(entry.entry_id)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
None _async_update_listener(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)