Fix: Energie-Dashboard Nodes größer (R=56), Labels aus API, Abrechnungsperiode konfig. (v1.7.1)
- SVG-Nodes: Radius 44 → 56, Icon 22 → 26px, Abstände neu berechnet - Segment-Pfade an neue Positionen angepasst (40px Abstand Kante→Kante) - period.monthly.label / yearly.label statt hardcoded "Diesen Monat" / "Dieses Jahr" - billing_day/billing_month: history.period_key(), /api/period-energy, Settings-UI Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+33
-5
@@ -88,6 +88,8 @@ def _defaults() -> Dict[str, Any]:
|
||||
"mqtt_pass": "",
|
||||
"price_import": 0.30,
|
||||
"price_export": 0.08,
|
||||
"billing_day": 1,
|
||||
"billing_month": 1,
|
||||
"inverters": [],
|
||||
}
|
||||
|
||||
@@ -118,6 +120,8 @@ def save_config():
|
||||
"mqtt_pass": State.mqtt_cfg.get("mqtt_pass", ""),
|
||||
"price_import": State.mqtt_cfg.get("price_import", 0.30),
|
||||
"price_export": State.mqtt_cfg.get("price_export", 0.08),
|
||||
"billing_day": State.mqtt_cfg.get("billing_day", 1),
|
||||
"billing_month": State.mqtt_cfg.get("billing_month", 1),
|
||||
"inverters": State.inverters_cfg,
|
||||
}
|
||||
with open(CONFIG_PATH, "w") as f:
|
||||
@@ -345,6 +349,9 @@ def api_save_config():
|
||||
for k in ("price_import", "price_export"):
|
||||
if k in data:
|
||||
State.mqtt_cfg[k] = float(data[k])
|
||||
for k in ("billing_day", "billing_month"):
|
||||
if k in data:
|
||||
State.mqtt_cfg[k] = int(data[k])
|
||||
save_config()
|
||||
threading.Thread(target=_restart_all, daemon=True).start()
|
||||
return jsonify({"ok": True})
|
||||
@@ -352,16 +359,37 @@ def api_save_config():
|
||||
|
||||
@app.get("/api/period-energy")
|
||||
def api_period_energy():
|
||||
import datetime
|
||||
agg = _compute_aggregates()
|
||||
price_import = float(State.mqtt_cfg.get("price_import", 0.30))
|
||||
price_export = float(State.mqtt_cfg.get("price_export", 0.08))
|
||||
price_import = float(State.mqtt_cfg.get("price_import", 0.30))
|
||||
price_export = float(State.mqtt_cfg.get("price_export", 0.08))
|
||||
billing_day = int(State.mqtt_cfg.get("billing_day", 1))
|
||||
billing_month = int(State.mqtt_cfg.get("billing_month", 1))
|
||||
|
||||
result = {"price_import": price_import, "price_export": price_export}
|
||||
result = {
|
||||
"price_import": price_import,
|
||||
"price_export": price_export,
|
||||
"billing_day": billing_day,
|
||||
"billing_month": billing_month,
|
||||
}
|
||||
|
||||
MONTHS_DE = ["","Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"]
|
||||
|
||||
for period_type in ("monthly", "yearly"):
|
||||
key = history.period_key(period_type)
|
||||
key = history.period_key(period_type, billing_day, billing_month)
|
||||
entry = {}
|
||||
for agg_id in ("grid_import_kwh", "grid_export_kwh", "total_energy_today"):
|
||||
|
||||
# Lesbare Beschriftung
|
||||
if period_type == "monthly":
|
||||
d = datetime.date.fromisoformat(key + "-01")
|
||||
entry["label"] = f"{MONTHS_DE[d.month]} {d.year}"
|
||||
else:
|
||||
d = datetime.date.fromisoformat(key)
|
||||
end = datetime.date(d.year + 1, billing_month, billing_day) if billing_month != 1 or billing_day != 1 \
|
||||
else datetime.date(d.year + 1, 1, 1)
|
||||
entry["label"] = f"{d.strftime('%d.%m.%Y')} – {(end - datetime.timedelta(days=1)).strftime('%d.%m.%Y')}"
|
||||
|
||||
for agg_id in ("grid_import_kwh", "grid_export_kwh"):
|
||||
cur = agg.get(agg_id)
|
||||
if cur is None:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user