1 """The ukraine_alarm component."""
3 from __future__
import annotations
5 from datetime
import timedelta
10 from aiohttp
import ClientSession
11 from uasiren.client
import Client
16 from .const
import ALERT_TYPES, DOMAIN
18 _LOGGER = logging.getLogger(__name__)
24 """Class to manage fetching Ukraine Alarm API."""
29 session: ClientSession,
36 super().
__init__(hass, _LOGGER, name=DOMAIN, update_interval=UPDATE_INTERVAL)
39 """Update data via library."""
42 except aiohttp.ClientError
as error:
43 raise UpdateFailed(f
"Error fetching alerts from API: {error}")
from error
45 current = {alert_type:
False for alert_type
in ALERT_TYPES}
46 for alert
in res[0][
"activeAlerts"]:
47 current[alert[
"type"]] =
True
dict[str, Any] _async_update_data(self)
None __init__(self, HomeAssistant hass, ClientSession session, str region_id)