Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """A sensor that monitors trends in other components."""
2 
3 from __future__ import annotations
4 
5 from homeassistant.config_entries import ConfigEntry
6 from homeassistant.const import CONF_ENTITY_ID, Platform
7 from homeassistant.core import HomeAssistant
9  async_remove_stale_devices_links_keep_entity_device,
10 )
11 
12 PLATFORMS = [Platform.BINARY_SENSOR]
13 
14 
15 async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
16  """Set up Trend from a config entry."""
17 
19  hass,
20  entry.entry_id,
21  entry.options[CONF_ENTITY_ID],
22  )
23 
24  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
25  entry.async_on_unload(entry.add_update_listener(config_entry_update_listener))
26 
27  return True
28 
29 
30 async def config_entry_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
31  """Handle an Trend options update."""
32  await hass.config_entries.async_reload(entry.entry_id)
33 
34 
35 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
36  """Unload a config entry."""
37  return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
None config_entry_update_listener(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:30
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:35
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:15
None async_remove_stale_devices_links_keep_entity_device(HomeAssistant hass, str entry_id, str source_entity_id_or_uuid)
Definition: device.py:66