1 """DataUpdateCoordinator for the Forecast.Solar integration."""
3 from __future__
import annotations
5 from datetime
import timedelta
7 from forecast_solar
import Estimate, ForecastSolar, ForecastSolarConnectionError
28 """The Forecast.Solar Data Update Coordinator."""
30 config_entry: ConfigEntry
32 def __init__(self, hass: HomeAssistant, entry: ConfigEntry) ->
None:
33 """Initialize the Forecast.Solar coordinator."""
38 api_key = entry.options.get(CONF_API_KEY)
or None
41 inverter_size := entry.options.get(CONF_INVERTER_SIZE)
42 )
is not None and inverter_size > 0:
43 inverter_size = inverter_size / 1000
48 latitude=entry.data[CONF_LATITUDE],
49 longitude=entry.data[CONF_LONGITUDE],
50 declination=entry.options[CONF_DECLINATION],
51 azimuth=(entry.options[CONF_AZIMUTH] - 180),
52 kwp=(entry.options[CONF_MODULES_POWER] / 1000),
53 damping_morning=entry.options.get(CONF_DAMPING_MORNING, 0.0),
54 damping_evening=entry.options.get(CONF_DAMPING_EVENING, 0.0),
55 inverter=inverter_size,
61 if api_key
is not None:
64 super().
__init__(hass, LOGGER, name=DOMAIN, update_interval=update_interval)
67 """Fetch Forecast.Solar estimates."""
69 return await self.
forecastforecast.estimate()
70 except ForecastSolarConnectionError
as error:
Estimate _async_update_data(self)
None __init__(self, HomeAssistant hass, ConfigEntry 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)