Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The Derivative integration."""
2 
3 from __future__ import annotations
4 
5 from homeassistant.config_entries import ConfigEntry
6 from homeassistant.const import CONF_SOURCE, Platform
7 from homeassistant.core import HomeAssistant
9  async_remove_stale_devices_links_keep_entity_device,
10 )
11 
12 
13 async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
14  """Set up Derivative from a config entry."""
15 
17  hass, entry.entry_id, entry.options[CONF_SOURCE]
18  )
19 
20  await hass.config_entries.async_forward_entry_setups(entry, (Platform.SENSOR,))
21  entry.async_on_unload(entry.add_update_listener(config_entry_update_listener))
22  return True
23 
24 
25 async def config_entry_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
26  """Update listener, called when the config entry options are changed."""
27  await hass.config_entries.async_reload(entry.entry_id)
28 
29 
30 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
31  """Unload a config entry."""
32  return await hass.config_entries.async_unload_platforms(entry, (Platform.SENSOR,))
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:30
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:13
None config_entry_update_listener(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:25
None async_remove_stale_devices_links_keep_entity_device(HomeAssistant hass, str entry_id, str source_entity_id_or_uuid)
Definition: device.py:66