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

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:
7tobias
2026-07-21 04:22:50 -04:00
committed by GitHub
parent 641873d867
commit 8d72177671
10 changed files with 215 additions and 101 deletions

View File

@@ -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"]