Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The gogogate2 component."""
2 
3 from homeassistant.config_entries import ConfigEntry
4 from homeassistant.const import CONF_DEVICE, Platform
5 from homeassistant.core import HomeAssistant
6 
7 from .common import get_data_update_coordinator
8 from .const import DEVICE_TYPE_GOGOGATE2
9 
10 PLATFORMS = [Platform.COVER, Platform.SENSOR]
11 
12 
13 async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
14  """Do setup of Gogogate2."""
15 
16  # Update the config entry.
17  config_updates = {}
18  if CONF_DEVICE not in entry.data:
19  config_updates = {
20  **entry.data,
21  CONF_DEVICE: DEVICE_TYPE_GOGOGATE2,
22  }
23 
24  if config_updates:
25  hass.config_entries.async_update_entry(entry, data=config_updates)
26 
27  data_update_coordinator = get_data_update_coordinator(hass, entry)
28  await data_update_coordinator.async_config_entry_first_refresh()
29 
30  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
31 
32  return True
33 
34 
35 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
36  """Unload Gogogate2 config entry."""
37  return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
DeviceDataUpdateCoordinator get_data_update_coordinator(HomeAssistant hass, ConfigEntry config_entry)
Definition: common.py:46
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:35
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:13