diff --git a/server/data_model.py b/server/data_model.py index 4064670..134f112 100644 --- a/server/data_model.py +++ b/server/data_model.py @@ -393,18 +393,17 @@ def apply_procedural(record: dict) -> dict: """ proc: dict = {} - range_at_soc = _get(record, "electric_drive", "range", "value") - soc = _get(record, "electric_drive", "battery", "soc", "value") + range_at_soc = _get(record, "sensor", "electric_range", "value") + soc = _get(record, "sensor", "battery_level", "value") if range_at_soc is not None and soc: proc["range_at_100"] = _phys(round(100 * float(range_at_soc) / float(soc), 1), "km") # ── add computed fields here ────────────────────────────────────────── - # Use _get(record, "domain", "statusObject", "field", "value") to - # safely read any nested value. Always use {"value": ..., "unit": ...} - # format so the GUI picks up the field automatically. + # Use _get(record, "sensor"|"binary_sensor"|..., "attr_name", "value") + # Always use {"value": ..., "unit": ...} format so the GUI picks it up. # # Example — usable energy estimated from SOC and battery capacity: - # soc = _get(record, "electric_drive", "battery", "soc", "value") + # soc = _get(record, "sensor", "battery_level", "value") # if soc is not None: # proc["energy_stored"] = {"value": round(soc / 100 * 77.0, 1), "unit": "kWh"} # ─────────────────────────────────────────────────────────────────────