mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-07-13 15:26:53 +00:00
* Update utilities in utils submodule. * Add base configuration modules. * Add server base configuration modules. * Add devices base configuration modules. * Add optimization base configuration modules. * Add utils base configuration modules. * Add prediction abstract and base classes plus tests. * Add PV forecast to prediction submodule. The PV forecast modules are adapted from the class_pvforecast module and replace it. * Add weather forecast to prediction submodule. The modules provide classes and methods to retrieve, manage, and process weather forecast data from various sources. Includes are structured representations of weather data and utilities for fetching forecasts for specific locations and time ranges. BrightSky and ClearOutside are currently supported. * Add electricity price forecast to prediction submodule. * Adapt fastapi server to base config and add fasthtml server. * Add ems to core submodule. * Adapt genetic to config. * Adapt visualize to config. * Adapt common test fixtures to config. * Add load forecast to prediction submodule. * Add core abstract and base classes. * Adapt single test optimization to config. * Adapt devices to config. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
60 lines
2.5 KiB
Python
60 lines
2.5 KiB
Python
"""Abstract and base classes for pvforecast predictions.
|
|
|
|
Notes:
|
|
- Ensure appropriate API keys or configurations are set up if required by external data sources.
|
|
"""
|
|
|
|
from abc import abstractmethod
|
|
from typing import List, Optional
|
|
|
|
from pydantic import Field
|
|
|
|
from akkudoktoreos.prediction.predictionabc import PredictionProvider, PredictionRecord
|
|
from akkudoktoreos.utils.logutil import get_logger
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
class PVForecastDataRecord(PredictionRecord):
|
|
"""Represents a pvforecast data record containing various pvforecast attributes at a specific datetime."""
|
|
|
|
pvforecast_dc_power: Optional[float] = Field(default=None, description="Total DC power (W)")
|
|
pvforecast_ac_power: Optional[float] = Field(default=None, description="Total AC power (W)")
|
|
|
|
|
|
class PVForecastProvider(PredictionProvider):
|
|
"""Abstract base class for pvforecast providers.
|
|
|
|
PVForecastProvider is a thread-safe singleton, ensuring only one instance of this class is created.
|
|
|
|
Configuration variables:
|
|
pvforecast_provider (str): Prediction provider for pvforecast.
|
|
|
|
Attributes:
|
|
prediction_hours (int, optional): The number of hours into the future for which predictions are generated.
|
|
prediction_historic_hours (int, optional): The number of past hours for which historical data is retained.
|
|
latitude (float, optional): The latitude in degrees, must be within -90 to 90.
|
|
longitude (float, optional): The longitude in degrees, must be within -180 to 180.
|
|
start_datetime (datetime, optional): The starting datetime for predictions (inlcusive), defaults to the current datetime if unspecified.
|
|
end_datetime (datetime, computed): The datetime representing the end of the prediction range (exclusive),
|
|
calculated based on `start_datetime` and `prediction_hours`.
|
|
keep_datetime (datetime, computed): The earliest datetime for retaining historical data (inclusive), calculated
|
|
based on `start_datetime` and `prediction_historic_hours`.
|
|
"""
|
|
|
|
# overload
|
|
records: List[PVForecastDataRecord] = Field(
|
|
default_factory=list, description="List of PVForecastDataRecord records"
|
|
)
|
|
|
|
@classmethod
|
|
@abstractmethod
|
|
def provider_id(cls) -> str:
|
|
return "PVForecastProvider"
|
|
|
|
def enabled(self) -> bool:
|
|
logger.debug(
|
|
f"PVForecastProvider ID {self.provider_id()} vs. config {self.config.pvforecast_provider}"
|
|
)
|
|
return self.provider_id() == self.config.pvforecast_provider
|