Fix: Finanzen-Tab bleibt bei 'Lade...' hängen (v1.8.21)
fEur/fKwh waren lokale Funktionen in renderEnergy() — loadFinance() konnte sie nicht aufrufen (ReferenceError außerhalb des Scopes). Beide Funktionen in den globalen Scope verschoben, lokale Kopien entfernt. loadFinance() Rendering-Block in try/catch gewrappt. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
name: ShineBridge
|
||||
version: "1.8.20"
|
||||
version: "1.8.21"
|
||||
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
|
||||
|
||||
@@ -713,6 +713,15 @@ function renderSpotChart(spotData) {
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function fEur(v) {
|
||||
if (v == null) return null;
|
||||
return v >= 100 ? v.toFixed(0) + ' €' : v.toFixed(2) + ' €';
|
||||
}
|
||||
function fKwh(v) {
|
||||
if (v == null) return null;
|
||||
return (v >= 100 ? v.toFixed(0) : v.toFixed(1)) + ' kWh';
|
||||
}
|
||||
|
||||
function renderEnergy(inverters, aggregates, period, spotData) {
|
||||
const el = document.getElementById("energy-content");
|
||||
if (!aggregates || !Object.keys(aggregates).length) {
|
||||
@@ -848,15 +857,6 @@ function renderEnergy(inverters, aggregates, period, spotData) {
|
||||
const pi = period.price_import || 0.30;
|
||||
const pe = period.price_export || 0.08;
|
||||
|
||||
function fEur(v) {
|
||||
if (v == null) return null;
|
||||
return v >= 100 ? v.toFixed(0) + ' €' : v.toFixed(2) + ' €';
|
||||
}
|
||||
function fKwh(v) {
|
||||
if (v == null) return null;
|
||||
return (v >= 100 ? v.toFixed(0) : v.toFixed(1)) + ' kWh';
|
||||
}
|
||||
|
||||
function periodCard(label, kwh, cost, col, sub) {
|
||||
if (kwh == null) return '';
|
||||
return `<div class="kwh-card" style="border-top:3px solid ${col}">
|
||||
@@ -937,6 +937,7 @@ async function loadFinance() {
|
||||
try { data = await fetchJSON(api("api/finance")); }
|
||||
catch(e) { el.innerHTML = '<div class="no-data">Fehler beim Laden</div>'; return; }
|
||||
|
||||
try {
|
||||
const { days, fixed_total_eur, spot_total_eur, savings_eur, period_start, spot_days, total_days } = data;
|
||||
|
||||
if (!days || days.length === 0) {
|
||||
@@ -1033,6 +1034,7 @@ async function loadFinance() {
|
||||
</div>`;
|
||||
|
||||
el.innerHTML = empfehlung + cards + chart;
|
||||
} catch(e) { el.innerHTML = '<div class="no-data">Fehler beim Laden</div>'; console.error('loadFinance:', e); }
|
||||
}
|
||||
|
||||
// ── Live Data ─────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user