mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-09-13 07:21:16 +00:00
Fix config and prediction revamp. (#259)
Extend single_test_optimization.py to be able to use real world data from new prediction classes. - .venv/bin/python single_test_optimization.py --real_world --verbose Can also be run with profiling "--profile". Add single_test_prediction.py to fetch predictions from remote prediction providers - .venv/bin/python single_test_prediction.py --verbose --provider-id PVForecastAkkudoktor | more - .venv/bin/python single_test_prediction.py --verbose --provider-id LoadAkkudoktor | more - .venv/bin/python single_test_prediction.py --verbose --provider-id ElecPriceAkkudoktor | more - .venv/bin/python single_test_prediction.py --verbose --provider-id BrightSky | more - .venv/bin/python single_test_prediction.py --verbose --provider-id ClearOutside | more Can also be run with profiling "--profile". single_test_optimization.py is an example on how to retrieve prediction data for optimization and use it to set up the optimization parameters. Changes: - load: Only one load provider at a time (vs. 5 before) Bug fixes: - prediction: only use providers that are enabled to retrieve or set data. - prediction: fix pre pendulum format strings - dataabc: Prevent error when resampling data with no datasets. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -25,7 +25,7 @@ ems_eos = get_ems()
|
||||
@pytest.fixture
|
||||
def elecprice_provider(monkeypatch):
|
||||
"""Fixture to create a ElecPriceProvider instance."""
|
||||
monkeypatch.setenv("elecprice_provider", "Akkudoktor")
|
||||
monkeypatch.setenv("elecprice_provider", "ElecPriceAkkudoktor")
|
||||
return ElecPriceAkkudoktor()
|
||||
|
||||
|
||||
|
@@ -19,8 +19,8 @@ ems_eos = get_ems()
|
||||
def load_provider(monkeypatch):
|
||||
"""Fixture to create a LoadAkkudoktor instance."""
|
||||
settings = {
|
||||
"load0_provider": "LoadAkkudoktor",
|
||||
"load0_name": "Akkudoktor Profile",
|
||||
"load_provider": "LoadAkkudoktor",
|
||||
"load_name": "Akkudoktor Profile",
|
||||
"loadakkudoktor_year_energy": "1000",
|
||||
}
|
||||
config_eos.merge_settings_from_dict(settings)
|
||||
|
@@ -2,7 +2,6 @@ import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from akkudoktoreos.config.config import get_config
|
||||
from akkudoktoreos.core.ems import get_ems
|
||||
from akkudoktoreos.prediction.elecpriceakkudoktor import ElecPriceAkkudoktor
|
||||
from akkudoktoreos.prediction.elecpriceimport import ElecPriceImport
|
||||
from akkudoktoreos.prediction.loadakkudoktor import LoadAkkudoktor
|
||||
@@ -17,7 +16,6 @@ from akkudoktoreos.prediction.pvforecastimport import PVForecastImport
|
||||
from akkudoktoreos.prediction.weatherbrightsky import WeatherBrightSky
|
||||
from akkudoktoreos.prediction.weatherclearoutside import WeatherClearOutside
|
||||
from akkudoktoreos.prediction.weatherimport import WeatherImport
|
||||
from akkudoktoreos.utils.datetimeutil import compare_datetimes, to_datetime
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -28,28 +26,10 @@ def sample_settings(reset_config):
|
||||
"prediction_historic_hours": 24,
|
||||
"latitude": 52.52,
|
||||
"longitude": 13.405,
|
||||
"pvforecast_provider": "PVForecastAkkudoktor",
|
||||
"pvforecast0_peakpower": 5.0,
|
||||
"pvforecast0_surface_azimuth": -10,
|
||||
"pvforecast0_surface_tilt": 7,
|
||||
"pvforecast0_userhorizon": [20, 27, 22, 20],
|
||||
"pvforecast0_inverter_paco": 10000,
|
||||
"pvforecast1_peakpower": 4.8,
|
||||
"pvforecast1_surface_azimuth": -90,
|
||||
"pvforecast1_surface_tilt": 7,
|
||||
"pvforecast1_userhorizon": [30, 30, 30, 50],
|
||||
"pvforecast1_inverter_paco": 10000,
|
||||
"pvforecast2_peakpower": 1.4,
|
||||
"pvforecast2_surface_azimuth": -40,
|
||||
"pvforecast2_surface_tilt": 60,
|
||||
"pvforecast2_userhorizon": [60, 30, 0, 30],
|
||||
"pvforecast2_inverter_paco": 2000,
|
||||
"pvforecast3_peakpower": 1.6,
|
||||
"pvforecast3_surface_azimuth": 5,
|
||||
"pvforecast3_surface_tilt": 45,
|
||||
"pvforecast3_userhorizon": [45, 25, 30, 60],
|
||||
"pvforecast3_inverter_paco": 1400,
|
||||
"pvforecast4_peakpower": None,
|
||||
"weather_provider": None,
|
||||
"pvforecast_provider": None,
|
||||
"load_provider": None,
|
||||
"elecprice_provider": None,
|
||||
}
|
||||
|
||||
# Merge settings to config
|
||||
@@ -176,23 +156,6 @@ def test_provider_sequence(prediction):
|
||||
assert isinstance(prediction.providers[8], WeatherImport)
|
||||
|
||||
|
||||
def test_update_calls_providers(sample_settings, prediction):
|
||||
"""Test that the update method calls the update method for each provider in sequence."""
|
||||
# Mark the `update_datetime` method for each provider
|
||||
old_datetime = to_datetime("1970-01-01 00:00:00")
|
||||
for provider in prediction.providers:
|
||||
provider.update_datetime = old_datetime
|
||||
|
||||
ems_eos = get_ems()
|
||||
ems_eos.set_start_datetime(to_datetime())
|
||||
prediction.update_data()
|
||||
|
||||
# Verify each provider's `update` method was called
|
||||
for provider in prediction.providers:
|
||||
if provider.enabled():
|
||||
assert compare_datetimes(provider.update_datetime, old_datetime).gt
|
||||
|
||||
|
||||
def test_provider_by_id(prediction, forecast_providers):
|
||||
"""Test that provider_by_id method returns the correct provider."""
|
||||
for provider in forecast_providers:
|
||||
|
18
tests/testdata/EOS.config.json
vendored
18
tests/testdata/EOS.config.json
vendored
@@ -9,21 +9,9 @@
|
||||
"elecprice_provider": null,
|
||||
"elecpriceimport_file_path": null,
|
||||
"latitude": null,
|
||||
"load0_import_file_path": null,
|
||||
"load0_name": null,
|
||||
"load0_provider": null,
|
||||
"load1_import_file_path": null,
|
||||
"load1_name": null,
|
||||
"load1_provider": null,
|
||||
"load2_import_file_path": null,
|
||||
"load2_name": null,
|
||||
"load2_provider": null,
|
||||
"load3_import_file_path": null,
|
||||
"load3_name": null,
|
||||
"load3_provider": null,
|
||||
"load4_import_file_path": null,
|
||||
"load4_name": null,
|
||||
"load4_provider": null,
|
||||
"load_import_file_path": null,
|
||||
"load_name": null,
|
||||
"load_provider": null,
|
||||
"loadakkudoktor_year_energy": null,
|
||||
"longitude": null,
|
||||
"optimization_ev_available_charge_rates_percent": [],
|
||||
|
Reference in New Issue
Block a user