feat: add fixed electricity prediction with time window support (#930)
Some checks failed
Bump Version / Bump Version Workflow (push) Has been cancelled
docker-build / platform-excludes (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
Close stale pull requests/issues / Find Stale issues and PRs (push) Has been cancelled

Add a fixed electricity prediction that supports prices per time window.
The time windows may flexible be defined by day or date.

The prediction documentation is updated to also cover the ElecPriceFixed
provider.

The feature includes several changes that are not directly related to the
electricity price prediction implementation but are necessary to keep
EOS running properly and to test and document the changes.

* feat: add value time windows

    Add time windows with an associated float value.

* feat: harden eos measurements endpoints error detection and reporting

    Cover more errors that may be raised during endpoint access. Report the
    errors including trace information to ease debugging.

* feat: extend server configuration to cover all arguments

    Make the argument controlled options also available in server configuration.

* fix: eos config configuration by cli arguments

    Move the command line argument handling to config eos so that it is
    excuted whenever eos config is rebuild or reset.

* chore: extend measurement endpoint system test

* chore: refactor time windows

    Move time windows to configabc as they are only used in configurations.
    Also move all tests to test_configabc.

* chore: provide config update errors in eosdash with summarized error text

    If there is an update error provide the error text as a summary. On click
    provide the full error text.

* chore: force eosdash ip address and port in makefile dev run

    Ensure eosdash ip address and port are correctly set for development runs.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
Bobby Noelte
2026-03-11 17:18:45 +01:00
committed by GitHub
parent 850d6b7c74
commit cf477d91a3
35 changed files with 3778 additions and 1491 deletions

View File

@@ -32,6 +32,7 @@ from akkudoktoreos.core.decorators import classproperty
from akkudoktoreos.core.emsettings import (
EnergyManagementCommonSettings,
)
from akkudoktoreos.core.logabc import LOGGING_LEVELS
from akkudoktoreos.core.logsettings import LoggingCommonSettings
from akkudoktoreos.core.pydantic import PydanticModelNestedValueMixin, merge_models
from akkudoktoreos.core.version import __version__
@@ -44,6 +45,7 @@ from akkudoktoreos.prediction.load import LoadCommonSettings
from akkudoktoreos.prediction.prediction import PredictionCommonSettings
from akkudoktoreos.prediction.pvforecast import PVForecastCommonSettings
from akkudoktoreos.prediction.weather import WeatherCommonSettings
from akkudoktoreos.server.rest.cli import cli_argument_parser
from akkudoktoreos.server.server import ServerCommonSettings
from akkudoktoreos.utils.datetimeutil import to_datetime, to_timezone
from akkudoktoreos.utils.utils import UtilsCommonSettings
@@ -421,6 +423,62 @@ class ConfigEOS(SingletonMixin, SettingsEOSDefaults):
- It ensures that a fallback to a default configuration file is always possible.
"""
def lazy_config_cli_settings() -> dict:
"""CLI settings.
This function runs at **instance creation**, not class definition. Ensures if ConfigEOS
is recreated this function is run.
"""
args, args_unknown = cli_argument_parser().parse_known_args() # defaults to sys.ARGV
# Initialize nested settings dictionary
settings: dict[str, Any] = {}
# Helper function to set nested dictionary values
def set_nested(dict_obj: dict[str, Any], path: str, value: Any) -> None:
"""Set a value in a nested dictionary using dot notation path."""
parts = path.split(".")
current = dict_obj
for part in parts[:-1]:
if part not in current:
current[part] = {}
current = current[part]
current[parts[-1]] = value
# Server host
if args.host is not None:
set_nested(settings, "server.host", args.host)
logger.debug(f"CLI arg: server.host set to {args.host}")
# Server port
if args.port is not None:
set_nested(settings, "server.port", args.port)
logger.debug(f"CLI arg: server.port set to {args.port}")
# Server startup_eosdash
if args.startup_eosdash is not None:
set_nested(settings, "server.startup_eosdash", args.startup_eosdash)
logger.debug(f"CLI arg: server.startup_eosdash set to {args.startup_eosdash}")
# Logging level (skip if "none" as that means don't change)
if args.log_level is not None and args.log_level.lower() != "none":
log_level = args.log_level.upper()
if log_level in LOGGING_LEVELS:
set_nested(settings, "logging.console_level", log_level)
logger.debug(f"CLI arg: logging.console_level set to {log_level}")
else:
logger.warning(f"Invalid log level '{args.log_level}' ignored")
if args.run_as_user is not None:
set_nested(settings, "server.run_as_user", args.run_as_user)
logger.debug(f"CLI arg: server.run_as_user set to {args.run_as_user}")
if args.reload is not None:
set_nested(settings, "server.reload", args.reload)
logger.debug(f"CLI arg: server.reload set to {args.reload}")
return settings
def lazy_config_file_settings() -> dict:
"""Config file settings.
@@ -561,7 +619,8 @@ class ConfigEOS(SingletonMixin, SettingsEOSDefaults):
# The settings are all lazyly evaluated at instance creation time to allow for
# runtime configuration.
setting_sources = [
lazy_config_file_settings, # Prio high
lazy_config_cli_settings, # Prio high
lazy_config_file_settings,
lazy_init_settings,
lazy_env_settings,
lazy_dotenv_settings,