1 """The GIOS component."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
15 from .const
import CONF_STATION_ID, DOMAIN
16 from .coordinator
import GiosDataUpdateCoordinator
18 _LOGGER = logging.getLogger(__name__)
20 PLATFORMS = [Platform.SENSOR]
22 type GiosConfigEntry = ConfigEntry[GiosData]
27 """Data for GIOS integration."""
29 coordinator: GiosDataUpdateCoordinator
33 """Set up GIOS as config entry."""
34 station_id: int = entry.data[CONF_STATION_ID]
35 _LOGGER.debug(
"Using station_id: %d", station_id)
38 if isinstance(entry.unique_id, int):
39 hass.config_entries.async_update_entry(entry, unique_id=
str(station_id))
42 device_registry = dr.async_get(hass)
43 old_ids = (DOMAIN, station_id)
44 device_entry = device_registry.async_get_device(identifiers={old_ids})
45 if device_entry
and entry.entry_id
in device_entry.config_entries:
46 new_ids = (DOMAIN,
str(station_id))
47 device_registry.async_update_device(device_entry.id, new_identifiers={new_ids})
52 await coordinator.async_config_entry_first_refresh()
54 entry.runtime_data =
GiosData(coordinator)
56 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
59 ent_reg = er.async_get(hass)
60 unique_id =
str(coordinator.gios.station_id)
61 if entity_id := ent_reg.async_get_entity_id(
62 AIR_QUALITY_PLATFORM, DOMAIN, unique_id
64 _LOGGER.debug(
"Removing deprecated air_quality entity %s", entity_id)
65 ent_reg.async_remove(entity_id)
71 """Unload a config entry."""
72 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_unload_entry(HomeAssistant hass, GiosConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, GiosConfigEntry entry)
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)