Feature: Eigenversorgungs-Ersparnis in Perioden-Karten (v1.8.2)

- bat_discharge_total + bat_charge_total werden jetzt als Perioden-Starts getrackt
- savings_kwh = Batterie-Entladung der Periode (→ Haus + Auto)
- savings_eur = savings_kwh × effektiver Importpreis (Festpreis oder Börsendurchschnitt)
- Neue Karte "Eigenversorgung" (lila) neben Netzbezug/Einspeisung
- Preis-Refaktor: eff_price für Import, Export, Ersparnis aus einer Berechnung

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
retr0
2026-04-29 08:38:56 +02:00
parent ec26782765
commit 3762abd632
3 changed files with 32 additions and 20 deletions
+12 -5
View File
@@ -604,19 +604,26 @@ function renderEnergy(inverters, aggregates, period, spotData) {
</div>`;
}
function sectionCards(title, data, col) {
function sectionCards(title, data) {
const impSub = data.spot_avg_ct != null
? `Ø ${data.spot_avg_ct.toFixed(1)} + ${(data.spot_markup_ct||0).toFixed(1)} ct/kWh`
: '';
const imp = periodCard('Netzbezug', data.grid_import_kwh, data.import_cost, C.imp, impSub);
const exp = periodCard('Einspeisung', data.grid_export_kwh, data.export_revenue, C.exp, '');
if (!imp && !exp) return '';
const sav = data.savings_kwh != null
? `<div class="kwh-card" style="border-top:3px solid ${C.bat}">
<div class="kv" style="color:${C.bat}">${fKwh(data.savings_kwh)}</div>
${data.savings_eur != null ? `<div style="font-size:11px;font-weight:600;color:${C.bat};opacity:.8;margin:2px 0">${fEur(data.savings_eur)} gespart</div>` : ''}
<div class="kl">Eigenversorgung<br><span style="opacity:.6">Batterie → Haus &amp; Auto</span></div>
</div>`
: '';
if (!imp && !exp && !sav) return '';
return `<div style="margin-bottom:8px;font-size:10px;font-weight:700;letter-spacing:.08em;color:${C.dim};text-transform:uppercase">${title}</div>
<div class="energy-kwh" style="margin-bottom:16px">${imp}${exp}</div>`;
<div class="energy-kwh" style="margin-bottom:16px">${imp}${exp}${sav}</div>`;
}
const cards = sectionCards(mon.label || 'Diesen Monat', mon, C.imp) +
sectionCards(yr.label || 'Dieses Jahr', yr, C.imp);
const cards = sectionCards(mon.label || 'Diesen Monat', mon) +
sectionCards(yr.label || 'Dieses Jahr', yr);
const spotHtml = (period.spot_chart !== false) ? renderSpotChart(spotData) : '';