Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0dbf0266a8 | |||
| 5942c18df6 | |||
| 58a33f966d |
@@ -1,5 +1,5 @@
|
||||
name: ShineBridge
|
||||
version: "1.8.9"
|
||||
version: "1.8.11"
|
||||
slug: shinebridge
|
||||
description: Growatt Wechselrichter lokal in Home Assistant — Modbus TCP via ShineLAN-X, MQTT Discovery, Web UI
|
||||
url: https://gitea.bitfire.work/retr0/shinebridge
|
||||
|
||||
+5
-20
@@ -180,25 +180,9 @@ def _compute_aggregates(allow_stale: bool = False) -> Dict[str, float]:
|
||||
# ── EMS Hilfsfunktionen ───────────────────────────────────────
|
||||
|
||||
def _get_pv_surplus() -> float:
|
||||
"""PV-Überschuss in Watt aus laufenden Geräten ermitteln.
|
||||
Goodwe: active_power negativ = Einspeisung (Überschuss).
|
||||
Growatt: power_to_grid positiv = Einspeisung.
|
||||
"""
|
||||
surplus = 0.0
|
||||
with State.lock:
|
||||
for inv_cfg in State.inverters_cfg:
|
||||
d = State.inv_data.get(inv_cfg["id"], {})
|
||||
if not d.get("modbus_ok") or not d.get("values"):
|
||||
continue
|
||||
v = d["values"]
|
||||
# Goodwe ET: active_power > 0 = Einspeisung, < 0 = Netzbezug
|
||||
# house_consumption = ppv + pbattery1 - active_power (Bibliotheks-Formel)
|
||||
if "active_power" in v:
|
||||
surplus += max(0.0, v["active_power"])
|
||||
# Growatt
|
||||
if "power_to_grid" in v:
|
||||
surplus += max(0.0, v["power_to_grid"])
|
||||
return surplus
|
||||
"""PV-Überschuss in Watt. Nutzt grid_power-Aggregat (negativ = Einspeisung)."""
|
||||
agg = _compute_aggregates(allow_stale=True)
|
||||
return max(0.0, -agg.get("grid_power", 0.0))
|
||||
|
||||
|
||||
# ── Poll Loop ─────────────────────────────────────────────────
|
||||
@@ -522,7 +506,8 @@ def api_get_surplus_devices():
|
||||
devices = State.surplus_devices_cfg
|
||||
z2m_base = State.z2m_base
|
||||
states = _surplus_ctrl.get_states() if _surplus_ctrl else {}
|
||||
return jsonify({"devices": devices, "z2m_base": z2m_base, "states": states})
|
||||
surplus_w = _get_pv_surplus()
|
||||
return jsonify({"devices": devices, "z2m_base": z2m_base, "states": states, "surplus_w": surplus_w})
|
||||
|
||||
@app.post("/api/surplus-devices")
|
||||
def api_save_surplus_devices():
|
||||
|
||||
@@ -1079,10 +1079,15 @@ function renderSurplusStatus(surplusData) {
|
||||
</div>`;
|
||||
}).join('');
|
||||
if (!rows) return '';
|
||||
const surplusW = surplusData.surplus_w ?? null;
|
||||
const surplusInfo = surplusW !== null
|
||||
? `<span style="font-size:11px;color:var(--text-dim);margin-left:auto">${surplusW >= 0 ? '+' : ''}${Math.round(surplusW)} W Überschuss</span>`
|
||||
: '';
|
||||
return `<div class="inv-section">
|
||||
<div class="inv-header">
|
||||
<div class="inv-title">Überschuss-Geräte</div>
|
||||
<div class="inv-badge ok">Z2M</div>
|
||||
${surplusInfo}
|
||||
</div>
|
||||
<div style="padding:0 2px">${rows}</div>
|
||||
</div>`;
|
||||
|
||||
Reference in New Issue
Block a user