Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The Adax integration."""
2 
3 from __future__ import annotations
4 
5 from homeassistant.config_entries import ConfigEntry
6 from homeassistant.const import Platform
7 from homeassistant.core import HomeAssistant
8 
9 PLATFORMS = [Platform.CLIMATE]
10 
11 
12 async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
13  """Set up Adax from a config entry."""
14  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
15  return True
16 
17 
18 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
19  """Unload a config entry."""
20  return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
21 
22 
23 async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
24  """Migrate old entry."""
25  # convert title and unique_id to string
26  if config_entry.version == 1:
27  if isinstance(config_entry.unique_id, int):
28  hass.config_entries.async_update_entry( # type: ignore[unreachable]
29  config_entry,
30  unique_id=str(config_entry.unique_id),
31  title=str(config_entry.title),
32  )
33 
34  return True
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:18
bool async_migrate_entry(HomeAssistant hass, ConfigEntry config_entry)
Definition: __init__.py:23
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:12