1 """DataUpdateCoordinator for the Nord Pool integration."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from datetime
import datetime, timedelta
7 from typing
import TYPE_CHECKING
9 from pynordpool
import (
13 NordPoolEmptyResponseError,
15 NordPoolResponseError,
25 from .const
import CONF_AREAS, DOMAIN, LOGGER
28 from .
import NordPoolConfigEntry
32 """A Nord Pool Data Update Coordinator."""
34 config_entry: NordPoolConfigEntry
36 def __init__(self, hass: HomeAssistant, config_entry: NordPoolConfigEntry) ->
None:
37 """Initialize the Nord Pool coordinator."""
41 config_entry=config_entry,
45 self.
unsubunsub: Callable[[],
None] |
None =
None
48 """Compute next time an update should occur."""
49 next_hour = dt_util.utcnow() +
timedelta(hours=1)
57 LOGGER.debug(
"Next update at %s", next_run)
61 """Cancel any scheduled call, and ignore new runs."""
68 """Fetch data from Nord Pool."""
73 data = await self.
clientclient.async_get_delivery_period(
75 Currency(self.
config_entryconfig_entry.data[CONF_CURRENCY]),
78 except NordPoolEmptyResponseError
as error:
79 LOGGER.debug(
"Empty response error: %s", error)
82 except NordPoolResponseError
as error:
83 LOGGER.debug(
"Response error: %s", error)
86 except NordPoolError
as error:
87 LOGGER.debug(
"Connection error: %s", error)
None __init__(self, HomeAssistant hass, NordPoolConfigEntry config_entry)
None async_shutdown(self)
datetime get_next_interval(self, datetime now)
None fetch_data(self, datetime now)
None async_set_updated_data(self, _DataT data)
None async_set_update_error(self, Exception err)
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)
datetime_sys datetime(Any value)
CALLBACK_TYPE async_track_point_in_utc_time(HomeAssistant hass, HassJob[[datetime], Coroutine[Any, Any, None]|None]|Callable[[datetime], Coroutine[Any, Any, None]|None] action, datetime point_in_time)