mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-07-24 10:48:11 +00:00
feat: add Akkudoktor feed-in provider (#1187)
Some checks are pending
Bump Version / Bump Version Workflow (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
docker-build / platform-excludes (push) Waiting to run
docker-build / build (push) Blocked by required conditions
docker-build / merge (push) Blocked by required conditions
pre-commit / pre-commit (push) Waiting to run
Run Pytest on Pull Request / test (push) Waiting to run
Some checks are pending
Bump Version / Bump Version Workflow (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
docker-build / platform-excludes (push) Waiting to run
docker-build / build (push) Blocked by required conditions
docker-build / merge (push) Blocked by required conditions
pre-commit / pre-commit (push) Waiting to run
Run Pytest on Pull Request / test (push) Waiting to run
The `FeedInTariffAkkudoktor` provider uses raw day-ahead market prices from `https://api.akkudoktor.net/prices` as `feed_in_tariff_wh`. It does not add electricity import charges or VAT. Published prices are extended to the configured prediction horizon with the same seasonal ETS or median fallback used by the Akkudoktor electricity-price provider. The Akkudoktor endpoint currently forwards hourly market prices from aWATTar. With a 15-minute optimization interval, EOS holds each hourly price constant for its four quarter-hour slots. This keeps the slot grid consistent but does not create genuine quarter-hour market prices. Signed-off-by: Andreas Schmitz <akkudoktor.net> Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ from unittest.mock import Mock, patch
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
|
||||
from akkudoktoreos.core.cache import CacheFileStore
|
||||
from akkudoktoreos.prediction.elecprice import ElecPriceCommonSettings
|
||||
|
||||
100
tests/test_feedintariffakkudoktor.py
Normal file
100
tests/test_feedintariffakkudoktor.py
Normal file
@@ -0,0 +1,100 @@
|
||||
import asyncio
|
||||
import json
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
|
||||
from akkudoktoreos.core.coreabc import get_ems
|
||||
from akkudoktoreos.prediction.elecpriceakkudoktor import AkkudoktorElecPrice
|
||||
from akkudoktoreos.prediction.feedintariffakkudoktor import FeedInTariffAkkudoktor
|
||||
from akkudoktoreos.utils.datetimeutil import to_datetime, to_duration
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def provider(config_eos):
|
||||
config_eos.merge_settings_from_dict(
|
||||
{
|
||||
"elecprice": {"charges_kwh": 0.30},
|
||||
"feedintariff": {"provider": "FeedInTariffAkkudoktor"},
|
||||
}
|
||||
)
|
||||
value = FeedInTariffAkkudoktor()
|
||||
value.highest_orig_datetime = None
|
||||
value.records.clear()
|
||||
assert value.enabled()
|
||||
return value
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def response_data():
|
||||
return {
|
||||
"meta": {
|
||||
"start_timestamp": "1733871600",
|
||||
"end_timestamp": "1733958000",
|
||||
"start": "2024-12-11T00:00:00+01:00",
|
||||
"end": "2024-12-12T00:00:00+01:00",
|
||||
},
|
||||
"values": [
|
||||
{
|
||||
"start_timestamp": 1733871600,
|
||||
"end_timestamp": 1733875200,
|
||||
"start": "2024-12-11T00:00:00+01:00",
|
||||
"end": "2024-12-11T01:00:00+01:00",
|
||||
"marketprice": 100.0,
|
||||
"unit": "Eur/MWh",
|
||||
"marketpriceEurocentPerKWh": 10.0,
|
||||
},
|
||||
{
|
||||
"start_timestamp": 1733875200,
|
||||
"end_timestamp": 1733878800,
|
||||
"start": "2024-12-11T01:00:00+01:00",
|
||||
"end": "2024-12-11T02:00:00+01:00",
|
||||
"marketprice": 200.0,
|
||||
"unit": "Eur/MWh",
|
||||
"marketpriceEurocentPerKWh": 20.0,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
class TestFeedInTariffAkkudokor:
|
||||
|
||||
def test_provider_is_available(self, config_eos):
|
||||
assert "FeedInTariffAkkudoktor" in config_eos.feedintariff.providers
|
||||
|
||||
def test_parse_data_uses_raw_market_price_without_import_charges(self, provider, response_data):
|
||||
data = AkkudoktorElecPrice.model_validate(response_data)
|
||||
series = provider._parse_data(data)
|
||||
assert series.iloc[0] == pytest.approx(0.0001)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_hourly_prices_are_held_constant_on_quarter_hour_grid(self, provider, response_data):
|
||||
data = AkkudoktorElecPrice.model_validate(response_data)
|
||||
await provider.key_from_series("feed_in_tariff_wh", provider._parse_data(data))
|
||||
start = to_datetime("2024-12-11 00:00:00", in_timezone="Europe/Berlin")
|
||||
|
||||
values = await provider.key_to_array(
|
||||
key="feed_in_tariff_wh",
|
||||
start_datetime=start,
|
||||
end_datetime=start + to_duration("2 hours"),
|
||||
interval=to_duration("15 minutes"),
|
||||
fill_method="ffill",
|
||||
)
|
||||
|
||||
assert values.tolist() == pytest.approx([0.0001] * 4 + [0.0002] * 4)
|
||||
|
||||
@patch("requests.get")
|
||||
def test_request_uses_akkudoktor_prices_endpoint(self, mock_get, provider, response_data):
|
||||
response = Mock()
|
||||
response.content = json.dumps(response_data)
|
||||
response.raise_for_status = Mock()
|
||||
mock_get.return_value = response
|
||||
get_ems().set_start_datetime(to_datetime("2024-12-11 00:00:00", in_timezone="Europe/Berlin"))
|
||||
|
||||
provider._request_forecast(force_update=True)
|
||||
|
||||
url = mock_get.call_args[0][0]
|
||||
assert url.startswith("https://api.akkudoktor.net/prices?")
|
||||
assert "tz=Europe/Berlin" in url
|
||||
assert mock_get.call_args.kwargs["timeout"] == (5, 20)
|
||||
@@ -7,6 +7,7 @@ from akkudoktoreos.prediction.elecpriceenergycharts import ElecPriceEnergyCharts
|
||||
from akkudoktoreos.prediction.elecpricefixed import ElecPriceFixed
|
||||
from akkudoktoreos.prediction.elecpriceimport import ElecPriceImport
|
||||
from akkudoktoreos.prediction.elecpricetibber import ElecPriceTibber
|
||||
from akkudoktoreos.prediction.feedintariffakkudoktor import FeedInTariffAkkudoktor
|
||||
from akkudoktoreos.prediction.feedintariffenergycharts import FeedInTariffEnergyCharts
|
||||
from akkudoktoreos.prediction.feedintarifffixed import FeedInTariffFixed
|
||||
from akkudoktoreos.prediction.feedintariffimport import FeedInTariffImport
|
||||
@@ -47,6 +48,7 @@ def forecast_providers():
|
||||
ElecPriceFixed(),
|
||||
ElecPriceImport(),
|
||||
ElecPriceTibber(),
|
||||
FeedInTariffAkkudoktor(),
|
||||
FeedInTariffEnergyCharts(),
|
||||
FeedInTariffFixed(),
|
||||
FeedInTariffImport(),
|
||||
@@ -101,23 +103,24 @@ def test_provider_sequence(prediction):
|
||||
assert isinstance(prediction.providers[2], ElecPriceFixed)
|
||||
assert isinstance(prediction.providers[3], ElecPriceImport)
|
||||
assert isinstance(prediction.providers[4], ElecPriceTibber)
|
||||
assert isinstance(prediction.providers[5], FeedInTariffEnergyCharts)
|
||||
assert isinstance(prediction.providers[6], FeedInTariffFixed)
|
||||
assert isinstance(prediction.providers[7], FeedInTariffImport)
|
||||
assert isinstance(prediction.providers[8], LoadAkkudoktor)
|
||||
assert isinstance(prediction.providers[9], LoadAkkudoktorAdjusted)
|
||||
assert isinstance(prediction.providers[10], LoadVrm)
|
||||
assert isinstance(prediction.providers[11], LoadImport)
|
||||
assert isinstance(prediction.providers[12], PVForecastAkkudoktor)
|
||||
assert isinstance(prediction.providers[13], PVForecastVrm)
|
||||
assert isinstance(prediction.providers[14], PVForecastPVNode)
|
||||
assert isinstance(prediction.providers[15], PVForecastForecastSolar)
|
||||
assert isinstance(prediction.providers[16], PVForecastSolcast)
|
||||
assert isinstance(prediction.providers[17], PVForecastImport)
|
||||
assert isinstance(prediction.providers[18], WeatherBrightSky)
|
||||
assert isinstance(prediction.providers[19], WeatherClearOutside)
|
||||
assert isinstance(prediction.providers[20], WeatherOpenMeteo)
|
||||
assert isinstance(prediction.providers[21], WeatherImport)
|
||||
assert isinstance(prediction.providers[5], FeedInTariffAkkudoktor)
|
||||
assert isinstance(prediction.providers[6], FeedInTariffEnergyCharts)
|
||||
assert isinstance(prediction.providers[7], FeedInTariffFixed)
|
||||
assert isinstance(prediction.providers[8], FeedInTariffImport)
|
||||
assert isinstance(prediction.providers[9], LoadAkkudoktor)
|
||||
assert isinstance(prediction.providers[10], LoadAkkudoktorAdjusted)
|
||||
assert isinstance(prediction.providers[11], LoadVrm)
|
||||
assert isinstance(prediction.providers[12], LoadImport)
|
||||
assert isinstance(prediction.providers[13], PVForecastAkkudoktor)
|
||||
assert isinstance(prediction.providers[14], PVForecastVrm)
|
||||
assert isinstance(prediction.providers[15], PVForecastPVNode)
|
||||
assert isinstance(prediction.providers[16], PVForecastForecastSolar)
|
||||
assert isinstance(prediction.providers[17], PVForecastSolcast)
|
||||
assert isinstance(prediction.providers[18], PVForecastImport)
|
||||
assert isinstance(prediction.providers[19], WeatherBrightSky)
|
||||
assert isinstance(prediction.providers[20], WeatherClearOutside)
|
||||
assert isinstance(prediction.providers[21], WeatherOpenMeteo)
|
||||
assert isinstance(prediction.providers[22], WeatherImport)
|
||||
|
||||
|
||||
def test_provider_by_id(prediction, forecast_providers):
|
||||
@@ -135,6 +138,7 @@ def test_prediction_repr(prediction):
|
||||
assert "ElecPriceFixed" in result
|
||||
assert "ElecPriceImport" in result
|
||||
assert "ElecPriceTibber" in result
|
||||
assert "FeedInTariffAkkudoktor" in result
|
||||
assert "FeedInTariffEnergyCharts" in result
|
||||
assert "FeedInTariffFixed" in result
|
||||
assert "FeedInTariffImport" in result
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
"bidding_zone": "DE-LU"
|
||||
},
|
||||
"providers": [
|
||||
"FeedInTariffAkkudoktor",
|
||||
"FeedInTariffEnergyCharts",
|
||||
"FeedInTariffFixed",
|
||||
"FeedInTariffImport"
|
||||
|
||||
Reference in New Issue
Block a user