mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-04-19 08:55:15 +00:00
* All config now nested. - Use default config from model field default values. If providers should be enabled by default, non-empty default config file could be provided again. - Environment variable support with EOS_ prefix and __ between levels, e.g. EOS_SERVER__EOS_SERVER_PORT=8503 where all values are case insensitive. For more information see: https://docs.pydantic.dev/latest/concepts/pydantic_settings/#parsing-environment-variable-values - Use devices as registry for configured devices. DeviceBase as base class with for now just initializion support (in the future expand to operations during optimization). - Strip down ConfigEOS to the only configuration instance. Reload from file or reset to defaults is possible. * Fix multi-initialization of derived SingletonMixin classes.
62 lines
2.4 KiB
Python
62 lines
2.4 KiB
Python
"""Abstract and base classes for load 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.core.logging import get_logger
|
|
from akkudoktoreos.prediction.predictionabc import PredictionProvider, PredictionRecord
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
class LoadDataRecord(PredictionRecord):
|
|
"""Represents a load data record containing various load attributes at a specific datetime."""
|
|
|
|
load_mean: Optional[float] = Field(default=None, description="Predicted load mean value (W).")
|
|
load_std: Optional[float] = Field(
|
|
default=None, description="Predicted load standard deviation (W)."
|
|
)
|
|
load_mean_adjusted: Optional[float] = Field(
|
|
default=None, description="Predicted load mean value adjusted by load measurement (W)."
|
|
)
|
|
|
|
|
|
class LoadProvider(PredictionProvider):
|
|
"""Abstract base class for load providers.
|
|
|
|
LoadProvider is a thread-safe singleton, ensuring only one instance of this class is created.
|
|
|
|
Configuration variables:
|
|
load_provider (str): Prediction provider for load.
|
|
|
|
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, defaults to the current datetime if unspecified.
|
|
end_datetime (datetime, computed): The datetime representing the end of the prediction range,
|
|
calculated based on `start_datetime` and `prediction_hours`.
|
|
keep_datetime (datetime, computed): The earliest datetime for retaining historical data, calculated
|
|
based on `start_datetime` and `prediction_historic_hours`.
|
|
"""
|
|
|
|
# overload
|
|
records: List[LoadDataRecord] = Field(
|
|
default_factory=list, description="List of LoadDataRecord records"
|
|
)
|
|
|
|
@classmethod
|
|
@abstractmethod
|
|
def provider_id(cls) -> str:
|
|
return "LoadProvider"
|
|
|
|
def enabled(self) -> bool:
|
|
return self.provider_id() == self.config.load.load_provider
|