Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The Garages Amsterdam integration."""
2 
3 from __future__ import annotations
4 
5 from odp_amsterdam import ODPAmsterdam
6 
7 from homeassistant.config_entries import ConfigEntry
8 from homeassistant.const import Platform
9 from homeassistant.core import HomeAssistant
10 from homeassistant.helpers.aiohttp_client import async_get_clientsession
11 
12 from .coordinator import GaragesAmsterdamDataUpdateCoordinator
13 
14 PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]
15 
16 type GaragesAmsterdamConfigEntry = ConfigEntry[GaragesAmsterdamDataUpdateCoordinator]
17 
18 
20  hass: HomeAssistant, entry: GaragesAmsterdamConfigEntry
21 ) -> bool:
22  """Set up Garages Amsterdam from a config entry."""
23  client = ODPAmsterdam(session=async_get_clientsession(hass))
24  coordinator = GaragesAmsterdamDataUpdateCoordinator(hass, client)
25 
26  await coordinator.async_config_entry_first_refresh()
27 
28  entry.runtime_data = coordinator
29 
30  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
31  return True
32 
33 
35  hass: HomeAssistant, entry: GaragesAmsterdamConfigEntry
36 ) -> bool:
37  """Unload Garages Amsterdam config entry."""
38  return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_setup_entry(HomeAssistant hass, GaragesAmsterdamConfigEntry entry)
Definition: __init__.py:21
bool async_unload_entry(HomeAssistant hass, GaragesAmsterdamConfigEntry entry)
Definition: __init__.py:36
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)