mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-07-31 14:16:11 +00:00
feat: add dvhubonline feed-in tariff provider (#1193)
Bump Version / Bump Version Workflow (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (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
Bump Version / Bump Version Workflow (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (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
Fetches GET /api/prices?start&end&zone (15-min slots, EUR/MWh) and stores the raw market price as feed_in_tariff_wh (EUR/Wh) — no import charges/VAT. Slots beyond the day-ahead horizon are left to the consumer's forward-fill (FeedInTariffImport behaviour). 5 unit tests + opt-in live smoke (EOS_DVHUB_ONLINE_LIVE=1, passing). Signed-off-by: Christin <info@bikinibottom.capital> Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
"""Tests for the dvhub.online feed-in tariff provider."""
|
||||
|
||||
import os
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from akkudoktoreos.prediction.feedintariffdvhubonline import (
|
||||
FeedInTariffDvhubOnline,
|
||||
FeedInTariffDvhubOnlineCommonSettings,
|
||||
)
|
||||
|
||||
SAMPLE = {
|
||||
"data": [
|
||||
{"ts": "2026-07-19T12:00:00.000Z", "price": 42.5}, # EUR/MWh
|
||||
{"ts": "2026-07-19T12:15:00.000Z", "price": -5.69}, # negative slot
|
||||
{"ts": "bogus", "price": 10.0}, # malformed -> skipped
|
||||
{"ts": "2026-07-19T12:30:00.000Z", "price": "x"}, # malformed -> skipped
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def provider(config_eos):
|
||||
config_eos.merge_settings_from_dict(
|
||||
{"feedintariff": {"provider": "FeedInTariffDvhubOnline"}}
|
||||
)
|
||||
return FeedInTariffDvhubOnline()
|
||||
|
||||
|
||||
class TestFeedInTariffDvhubOnline:
|
||||
def test_provider_id_registered(self, provider, config_eos):
|
||||
assert provider.provider_id() == "FeedInTariffDvhubOnline"
|
||||
assert provider.enabled()
|
||||
assert "FeedInTariffDvhubOnline" in config_eos.feedintariff.providers
|
||||
|
||||
def test_parse_data_eur_mwh_to_eur_wh(self, provider):
|
||||
series = provider._parse_data(SAMPLE)
|
||||
assert len(series) == 2 # malformed entries skipped
|
||||
assert series.iloc[0] == pytest.approx(42.5 / 1_000_000)
|
||||
assert series.iloc[1] == pytest.approx(-5.69 / 1_000_000) # negatives kept
|
||||
|
||||
def test_default_settings(self, provider):
|
||||
settings = provider._provider_settings()
|
||||
assert settings.base_url == "https://dvhub.online"
|
||||
assert settings.zone == "DE-LU"
|
||||
|
||||
def test_request_shape_guard(self, provider):
|
||||
response = MagicMock()
|
||||
response.raise_for_status.return_value = None
|
||||
response.json.return_value = {"unexpected": True}
|
||||
with patch(
|
||||
"akkudoktoreos.prediction.feedintariffdvhubonline.requests.get",
|
||||
return_value=response,
|
||||
):
|
||||
with pytest.raises(ValueError, match="response shape"):
|
||||
provider._request_forecast(
|
||||
start_date="2026-07-19", end_date="2026-07-21", force_update=True
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
os.environ.get("EOS_DVHUB_ONLINE_LIVE") != "1",
|
||||
reason="live API smoke — set EOS_DVHUB_ONLINE_LIVE=1 to run",
|
||||
)
|
||||
def test_live_api_smoke(provider):
|
||||
data = provider._request_forecast(
|
||||
start_date="2026-07-19", end_date="2026-07-20", force_update=True
|
||||
)
|
||||
series = provider._parse_data(data)
|
||||
assert not series.empty
|
||||
+21
-18
@@ -8,6 +8,7 @@ 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.feedintariffdvhubonline import FeedInTariffDvhubOnline
|
||||
from akkudoktoreos.prediction.feedintariffenergycharts import FeedInTariffEnergyCharts
|
||||
from akkudoktoreos.prediction.feedintarifffixed import FeedInTariffFixed
|
||||
from akkudoktoreos.prediction.feedintariffimport import FeedInTariffImport
|
||||
@@ -50,6 +51,7 @@ def forecast_providers():
|
||||
ElecPriceImport(),
|
||||
ElecPriceTibber(),
|
||||
FeedInTariffAkkudoktor(),
|
||||
FeedInTariffDvhubOnline(),
|
||||
FeedInTariffEnergyCharts(),
|
||||
FeedInTariffFixed(),
|
||||
FeedInTariffImport(),
|
||||
@@ -106,24 +108,25 @@ def test_provider_sequence(prediction):
|
||||
assert isinstance(prediction.providers[3], ElecPriceImport)
|
||||
assert isinstance(prediction.providers[4], ElecPriceTibber)
|
||||
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], FeedInTariffTibber)
|
||||
assert isinstance(prediction.providers[10], LoadAkkudoktor)
|
||||
assert isinstance(prediction.providers[11], LoadAkkudoktorAdjusted)
|
||||
assert isinstance(prediction.providers[12], LoadVrm)
|
||||
assert isinstance(prediction.providers[13], LoadImport)
|
||||
assert isinstance(prediction.providers[14], PVForecastAkkudoktor)
|
||||
assert isinstance(prediction.providers[15], PVForecastVrm)
|
||||
assert isinstance(prediction.providers[16], PVForecastPVNode)
|
||||
assert isinstance(prediction.providers[17], PVForecastForecastSolar)
|
||||
assert isinstance(prediction.providers[18], PVForecastSolcast)
|
||||
assert isinstance(prediction.providers[19], PVForecastImport)
|
||||
assert isinstance(prediction.providers[20], WeatherBrightSky)
|
||||
assert isinstance(prediction.providers[21], WeatherClearOutside)
|
||||
assert isinstance(prediction.providers[22], WeatherOpenMeteo)
|
||||
assert isinstance(prediction.providers[23], WeatherImport)
|
||||
assert isinstance(prediction.providers[6], FeedInTariffDvhubOnline)
|
||||
assert isinstance(prediction.providers[7], FeedInTariffEnergyCharts)
|
||||
assert isinstance(prediction.providers[8], FeedInTariffFixed)
|
||||
assert isinstance(prediction.providers[9], FeedInTariffImport)
|
||||
assert isinstance(prediction.providers[10], FeedInTariffTibber)
|
||||
assert isinstance(prediction.providers[11], LoadAkkudoktor)
|
||||
assert isinstance(prediction.providers[12], LoadAkkudoktorAdjusted)
|
||||
assert isinstance(prediction.providers[13], LoadVrm)
|
||||
assert isinstance(prediction.providers[14], LoadImport)
|
||||
assert isinstance(prediction.providers[15], PVForecastAkkudoktor)
|
||||
assert isinstance(prediction.providers[16], PVForecastVrm)
|
||||
assert isinstance(prediction.providers[17], PVForecastPVNode)
|
||||
assert isinstance(prediction.providers[18], PVForecastForecastSolar)
|
||||
assert isinstance(prediction.providers[19], PVForecastSolcast)
|
||||
assert isinstance(prediction.providers[20], PVForecastImport)
|
||||
assert isinstance(prediction.providers[21], WeatherBrightSky)
|
||||
assert isinstance(prediction.providers[22], WeatherClearOutside)
|
||||
assert isinstance(prediction.providers[23], WeatherOpenMeteo)
|
||||
assert isinstance(prediction.providers[24], WeatherImport)
|
||||
|
||||
|
||||
def test_provider_by_id(prediction, forecast_providers):
|
||||
|
||||
@@ -130,6 +130,10 @@
|
||||
"import_file_path": null,
|
||||
"import_json": null
|
||||
},
|
||||
"dvhubonline": {
|
||||
"base_url": "https://dvhub.online",
|
||||
"zone": "DE-LU"
|
||||
},
|
||||
"energycharts": {
|
||||
"bidding_zone": "DE-LU"
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
| Name | Environment Variable | Type | Read-Only | Default | Description |
|
||||
| ---- | -------------------- | ---- | --------- | ------- | ----------- |
|
||||
| dvhubonline | `EOS_FEEDINTARIFF__DVHUBONLINE` | `FeedInTariffDvhubOnlineCommonSettings` | `rw` | `required` | DvhubOnline feed in tariff provider settings. |
|
||||
| energycharts | `EOS_FEEDINTARIFF__ENERGYCHARTS` | `FeedInTariffEnergyChartsCommonSettings` | `rw` | `required` | EnergyCharts feed in tariff provider settings. |
|
||||
| feedintarifffixed | `EOS_FEEDINTARIFF__FEEDINTARIFFFIXED` | `FeedInTariffFixedCommonSettings` | `rw` | `required` | Fixed feed in tariff provider settings. |
|
||||
| feedintariffimport | `EOS_FEEDINTARIFF__FEEDINTARIFFIMPORT` | `FeedInTariffImportCommonSettings` | `rw` | `required` | Feed in tarif import provider settings. |
|
||||
@@ -31,6 +32,10 @@
|
||||
"import_file_path": null,
|
||||
"import_json": null
|
||||
},
|
||||
"dvhubonline": {
|
||||
"base_url": "https://dvhub.online",
|
||||
"zone": "DE-LU"
|
||||
},
|
||||
"energycharts": {
|
||||
"bidding_zone": "DE-LU"
|
||||
}
|
||||
@@ -55,11 +60,16 @@
|
||||
"import_file_path": null,
|
||||
"import_json": null
|
||||
},
|
||||
"dvhubonline": {
|
||||
"base_url": "https://dvhub.online",
|
||||
"zone": "DE-LU"
|
||||
},
|
||||
"energycharts": {
|
||||
"bidding_zone": "DE-LU"
|
||||
},
|
||||
"providers": [
|
||||
"FeedInTariffAkkudoktor",
|
||||
"FeedInTariffDvhubOnline",
|
||||
"FeedInTariffEnergyCharts",
|
||||
"FeedInTariffFixed",
|
||||
"FeedInTariffImport",
|
||||
@@ -158,3 +168,34 @@
|
||||
}
|
||||
```
|
||||
<!-- pyml enable line-length -->
|
||||
|
||||
### Common settings for the dvhub.online feed-in tariff provider
|
||||
|
||||
<!-- pyml disable line-length -->
|
||||
:::{table} feedintariff::dvhubonline
|
||||
:widths: 10 10 5 5 30
|
||||
:align: left
|
||||
|
||||
| Name | Type | Read-Only | Default | Description |
|
||||
| ---- | ---- | --------- | ------- | ----------- |
|
||||
| base_url | `str` | `rw` | `https://dvhub.online` | Base URL of the dvhub.online price API. |
|
||||
| zone | `str` | `rw` | `DE-LU` | Bidding zone passed to the dvhub.online price API. |
|
||||
:::
|
||||
<!-- pyml enable line-length -->
|
||||
|
||||
<!-- pyml disable no-emphasis-as-heading -->
|
||||
**Example Input/Output**
|
||||
<!-- pyml enable no-emphasis-as-heading -->
|
||||
|
||||
<!-- pyml disable line-length -->
|
||||
```json
|
||||
{
|
||||
"feedintariff": {
|
||||
"dvhubonline": {
|
||||
"base_url": "https://dvhub.online",
|
||||
"zone": "DE-LU"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
<!-- pyml enable line-length -->
|
||||
|
||||
Reference in New Issue
Block a user