mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-07-24 10:48:11 +00:00
feat: rename remaining German API fields and deprecate legacy endpoints (#1164)
Some checks failed
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
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
Close stale pull requests/issues / Find Stale issues and PRs (push) Has been cancelled
Some checks failed
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
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
Close stale pull requests/issues / Find Stale issues and PRs (push) Has been cancelled
Complete the English API translation started in #675: - rename input fields pv_akku to pv_battery and eauto to ev, and the solution fields eautocharge_hours_float to ev_charge_hours_float and eauto_obj to ev_obj; the German names are still accepted on input via validation aliases and re-emitted in responses as deprecated computed fields, same pattern as #675 - mark the legacy endpoints /strompreis, /gesamtlast and /gesamtlast_simple as deprecated in the OpenAPI schema - use amount instead of a euro reference in the battery LCOS log message Co-authored-by: Tobias Welz <tobias.wizneteu@gmail.com>
This commit is contained in:
@@ -179,7 +179,7 @@ async def prepare_optimization_real_parameters() -> GeneticOptimizationParameter
|
||||
"pv_forecast_wh": pv_forecast,
|
||||
"electricity_price_per_wh": electricity_price_per_wh,
|
||||
},
|
||||
"pv_akku": {
|
||||
"pv_battery": {
|
||||
"device_id": "battery 1",
|
||||
"capacity_wh": 26400,
|
||||
"initial_soc_percentage": 15,
|
||||
@@ -190,7 +190,7 @@ async def prepare_optimization_real_parameters() -> GeneticOptimizationParameter
|
||||
"max_power_wh": 10000,
|
||||
"battery_id": "battery 1",
|
||||
},
|
||||
"eauto": {
|
||||
"ev": {
|
||||
"device_id": "electric vehicle 1",
|
||||
"min_soc_percentage": 50,
|
||||
"capacity_wh": 60000,
|
||||
@@ -375,7 +375,7 @@ def prepare_optimization_parameters() -> GeneticOptimizationParameters:
|
||||
"pv_forecast_wh": pv_forecast,
|
||||
"electricity_price_per_wh": electricity_price_per_wh,
|
||||
},
|
||||
"pv_akku": {
|
||||
"pv_battery": {
|
||||
"device_id": "battery 1",
|
||||
"capacity_wh": 26400,
|
||||
"initial_soc_percentage": 15,
|
||||
@@ -386,7 +386,7 @@ def prepare_optimization_parameters() -> GeneticOptimizationParameters:
|
||||
"max_power_wh": 10000,
|
||||
"battery_id": "battery 1",
|
||||
},
|
||||
"eauto": {
|
||||
"ev": {
|
||||
"device_id": "electric vehicle 1",
|
||||
"min_soc_percentage": 50,
|
||||
"capacity_wh": 60000,
|
||||
|
||||
@@ -126,3 +126,45 @@ if __name__ == "__main__":
|
||||
test_genetic_params_english_output()
|
||||
test_simulation_result_translations()
|
||||
print("\n✅✅✅ All translation tests passed! ✅✅✅")
|
||||
|
||||
def test_optimization_parameters_device_translations():
|
||||
"""Test that German device field names are accepted and re-emitted."""
|
||||
from akkudoktoreos.optimization.genetic.geneticparams import (
|
||||
GeneticOptimizationParameters,
|
||||
)
|
||||
|
||||
ems_de = {
|
||||
"pv_prognose_wh": [100.0, 200.0],
|
||||
"strompreis_euro_pro_wh": [0.0003, 0.0003],
|
||||
"einspeiseverguetung_euro_pro_wh": 0.00007,
|
||||
"preis_euro_pro_wh_akku": 0.0001,
|
||||
"gesamtlast": [500.0, 600.0],
|
||||
}
|
||||
params = GeneticOptimizationParameters(
|
||||
ems=ems_de,
|
||||
pv_akku={"device_id": "battery1", "capacity_wh": 8000},
|
||||
inverter=None,
|
||||
eauto={"device_id": "ev1", "capacity_wh": 60000},
|
||||
)
|
||||
# English attributes are populated from the German input names
|
||||
assert params.pv_battery is not None
|
||||
assert params.pv_battery.capacity_wh == 8000
|
||||
assert params.ev is not None
|
||||
assert params.ev.capacity_wh == 60000
|
||||
|
||||
# English input names work as well
|
||||
params_en = GeneticOptimizationParameters(
|
||||
ems=ems_de,
|
||||
pv_battery={"device_id": "battery1", "capacity_wh": 8000},
|
||||
inverter=None,
|
||||
ev={"device_id": "ev1", "capacity_wh": 60000},
|
||||
)
|
||||
assert params_en.pv_battery is not None
|
||||
assert params_en.ev is not None
|
||||
|
||||
# Both names are present in the output (backward compatibility)
|
||||
dumped = params.model_dump()
|
||||
for name in ("pv_battery", "pv_akku", "ev", "eauto"):
|
||||
assert name in dumped, f"{name} missing in output"
|
||||
assert dumped["pv_akku"] == dumped["pv_battery"]
|
||||
assert dumped["eauto"] == dumped["ev"]
|
||||
|
||||
Reference in New Issue
Block a user