1 """The IMGW-PIB integration."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
8 from aiohttp
import ClientError
9 from imgw_pib
import ImgwPib
10 from imgw_pib.exceptions
import ApiError
18 from .const
import CONF_STATION_ID
19 from .coordinator
import ImgwPibDataUpdateCoordinator
21 PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]
23 _LOGGER = logging.getLogger(__name__)
25 type ImgwPibConfigEntry = ConfigEntry[ImgwPibData]
30 """Data for the IMGW-PIB integration."""
32 coordinator: ImgwPibDataUpdateCoordinator
36 """Set up IMGW-PIB from a config entry."""
37 station_id: str = entry.data[CONF_STATION_ID]
39 _LOGGER.debug(
"Using hydrological station ID: %s", station_id)
44 imgwpib = await ImgwPib.create(
45 client_session, hydrological_station_id=station_id
47 except (ClientError, TimeoutError, ApiError)
as err:
48 raise ConfigEntryNotReady
from err
51 await coordinator.async_config_entry_first_refresh()
55 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
61 """Unload a config entry."""
62 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_setup_entry(HomeAssistant hass, ImgwPibConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ImgwPibConfigEntry 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)