feat: match the verified on-site poller payload
The on-site agent found that the DC (P052/P054/P05A/P05C) and energy (P063) registers are static/frozen and ac_power_total_w is now computed V*I, so the backend and dashboard have to cope with those fields being absent. - Feeding/Standby from status_code (FEEDING_STATUS_CODES, default 7 and 8: INV1's OEM board uses 7). Online but not feeding = Standby; a standby inverter while peers produce is still caught by the underperformance check. Missing error_code stays "no fault". - Daily energy falls back to AC power integrated between readings, flagged estimated (≈ in the UI); out-of-order (spooled) readings recompute the day. Existing databases get the column and a rebuild on startup. - Totals are null instead of 0 when there's no energy data; lifetime shows "not available yet". Parameters the poller doesn't send are hidden on the detail page, DC lines only drawn when DC data exists. - Timestamps more than 5 min in the future are stored at receive time and counted in clamped_future — the example payload carried local Athens time labelled +00:00. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+14
-2
@@ -69,6 +69,9 @@ def summary(conn: sqlite3.Connection) -> dict:
|
||||
spec = specific(inv) if online else None
|
||||
relative = round(spec / median, 3) if spec is not None and median else None
|
||||
|
||||
code = r.get("status_code") if r else None
|
||||
feeding = None if code is None else code in s.feeding_status_codes
|
||||
|
||||
if not online:
|
||||
since = f"for {_minutes(r['age_seconds'])}" if r else "yet"
|
||||
if not datalogger_online:
|
||||
@@ -115,25 +118,34 @@ def summary(conn: sqlite3.Connection) -> dict:
|
||||
})
|
||||
if state == "ok" and issues:
|
||||
state = "warning"
|
||||
elif state == "ok" and feeding is False:
|
||||
# Awake but not feeding (low light, or a state not decoded yet)
|
||||
state = "standby"
|
||||
|
||||
statuses.append({
|
||||
"inverter": inv,
|
||||
"health": {
|
||||
"online": online,
|
||||
"feeding": feeding if online else None,
|
||||
"state": state,
|
||||
"issues": issues,
|
||||
"avg_power_w": round(averages[inv["id"]]["ac_power_w"]) if online and averages.get(inv["id"], {}).get("ac_power_w") is not None else None,
|
||||
"relative_output": relative,
|
||||
},
|
||||
"energy_today": energy_today.get(inv["id"], {"wh": None, "estimated": False}),
|
||||
"latest": r,
|
||||
})
|
||||
|
||||
today_values = [e["wh"] for e in energy_today.values() if e["wh"] is not None]
|
||||
lifetime_values = [r["total_energy_wh"] for r in latest.values() if r.get("total_energy_wh") is not None]
|
||||
totals = {
|
||||
"ac_power_w": sum((latest[i["id"]].get("ac_power_total_w") or 0) for i in inverters if is_online(i["id"])),
|
||||
"daily_energy_wh": sum(energy_today.values()),
|
||||
"total_energy_wh": sum((r.get("total_energy_wh") or 0) for r in latest.values()),
|
||||
"daily_energy_wh": sum(today_values) if today_values else None,
|
||||
"daily_energy_estimated": any(e["estimated"] for e in energy_today.values() if e["wh"] is not None),
|
||||
"total_energy_wh": sum(lifetime_values) if lifetime_values else None,
|
||||
"inverter_count": len(inverters),
|
||||
"online_count": sum(1 for i in inverters if is_online(i["id"])),
|
||||
"feeding_count": sum(1 for st in statuses if st["health"]["feeding"]),
|
||||
"problem_count": sum(1 for st in statuses if st["health"]["state"] in ("fault", "warning", "offline")),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user