Fix: Eigenverbrauch = PV_gesamt − Einspeisung statt nur Batterie-Entladung (v1.8.3)
Vollständige Formel: total_energy_total - grid_export_kwh deckt Direktverbrauch (PV→Haus) + Batterie-Umweg (PV→Bat→Haus) ab. Fallback auf bat_discharge_total wenn kein PV-Zähler verfügbar. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
name: ShineBridge
|
||||
version: "1.8.2"
|
||||
version: "1.8.3"
|
||||
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
|
||||
|
||||
+12
-4
@@ -408,7 +408,8 @@ def api_period_energy():
|
||||
pd_start_ts = datetime.datetime.combine(pd, datetime.time.min).timestamp()
|
||||
|
||||
for agg_id in ("grid_import_kwh", "grid_export_kwh",
|
||||
"bat_discharge_total", "bat_charge_total"):
|
||||
"bat_discharge_total", "bat_charge_total",
|
||||
"total_energy_total"):
|
||||
cur = agg.get(agg_id)
|
||||
if cur is None:
|
||||
continue
|
||||
@@ -432,9 +433,16 @@ def api_period_energy():
|
||||
if "grid_export_kwh" in entry:
|
||||
entry["export_revenue"] = round(entry["grid_export_kwh"] * price_export, 2)
|
||||
|
||||
# Eigenverbrauch-Ersparnis: Batterie-Entladung (→ Haus + Auto) zu Importpreis
|
||||
bat_dch = entry.get("bat_discharge_total")
|
||||
if bat_dch is not None:
|
||||
# Eigenverbrauch-Ersparnis: PV_gesamt − Einspeisung = alles was selbst verbraucht wurde
|
||||
# (Direktverbrauch + Batterie-Umweg). Fällt PV nicht verfügbar: nur Batterie-Entladung.
|
||||
pv_total = entry.get("total_energy_total")
|
||||
grid_exp = entry.get("grid_export_kwh")
|
||||
bat_dch = entry.get("bat_discharge_total")
|
||||
if pv_total is not None and grid_exp is not None:
|
||||
savings = round(max(0.0, pv_total - grid_exp), 2)
|
||||
entry["savings_kwh"] = savings
|
||||
entry["savings_eur"] = round(savings * eff_price, 2)
|
||||
elif bat_dch is not None:
|
||||
entry["savings_kwh"] = bat_dch
|
||||
entry["savings_eur"] = round(bat_dch * eff_price, 2)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user