From 96cd9e9c572f08484ed2b3a516741499b81e16e8 Mon Sep 17 00:00:00 2001 From: Peter Meier Date: Mon, 4 May 2026 23:47:52 +0200 Subject: [PATCH] =?UTF-8?q?fix(strommix):=20SMARD=20as=20primary=20source?= =?UTF-8?q?=20=E2=80=94=20accuracy=20parity=20with=20audit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Audit at 22:15 MESZ flagged the conventional sum (lignite + hard coal + gas + nuclear) as 19.1 GW in the widget vs 15.65 GW in reality. The breakdown showed the gap was Energy-Charts' `Fossil gas` (6.9 GW) which bundles natural gas + GuD + similar, while SMARD's `Erdgas` filter 4069 (3.8 GW) tracks just natural gas the way the widget label implies. SMARD is the canonical German grid feed; switching the primary source resolves the discrepancy directly. - New `lib/smard.ts` fetches the 11 relevant filter IDs in parallel: conventional (1223/4070/4069/1224), wind (4067/1225), solar (1226), hydro (1228), biomass (4066), other-conventional + pumped storage (1227/4071, surfaced separately), load (410). Two-step protocol (index.json → archive.json) handled inside; output is MW (MWh × 4) aligned to one common slot timestamp so every value on screen comes from the same point in time. - Aggregator route uses SMARD for production + load, Energy-Charts only for cross-border saldo + day-ahead prices (where SMARD has no convenient single-call endpoint). `dataSource: "smard" | "energy-charts"` flag travels in the response so the widget can attribute the numbers and fall back gracefully when SMARD is down. - StrommixBlock gets a "Werte prüfen" disclosure that lists every component (wind onshore + offshore, solar, the four conventional buckets, biomass, hydro, load) with its MW value and the slot timestamp + data source. Fact-check users can verify the addition themselves now without asking. Verified live: SMARD @ 21:00 UTC = lignite 8484 + hard coal 3480 + gas 3811 + nuclear 0 = 15.78 GW conventional. Matches the user's ground-truth 15.65 GW within sampling noise. --- .../components/blocks/StrommixBlock.svelte | 30 +++ src/lib/iconify-mdi-subset.generated.json | 6 + src/lib/smard.ts | 191 ++++++++++++++++++ src/lib/strommix.ts | 4 + src/routes/api/strommix/+server.ts | 121 ++++++----- 5 files changed, 290 insertions(+), 62 deletions(-) create mode 100644 src/lib/smard.ts diff --git a/src/lib/components/blocks/StrommixBlock.svelte b/src/lib/components/blocks/StrommixBlock.svelte index efc0435..72ca55d 100644 --- a/src/lib/components/blocks/StrommixBlock.svelte +++ b/src/lib/components/blocks/StrommixBlock.svelte @@ -250,6 +250,36 @@ {/if} + + {#if live} +
+ + Wert prüfen — alle Komponenten anzeigen + +
+
Wind onshore
{fmtMw(live.windOnshoreMw)}
+
Wind offshore
{fmtMw(live.windOffshoreMw)}
+
Photovoltaik
{fmtMw(live.solarMw)}
+
Braunkohle
{fmtMw(live.ligniteMw)}
+
Steinkohle
{fmtMw(live.hardCoalMw)}
+
Erdgas
{fmtMw(live.gasMw)}
+
Kernkraft
{fmtMw(live.nuclearMw)}
+
Biomasse
{fmtMw(live.biomassMw)}
+
Wasserkraft
{fmtMw(live.hydroMw)}
+
Last
{fmtMw(live.loadMw)}
+
+

+ Quelle: {live.dataSource === "smard" + ? "smard.de (Bundesnetzagentur)" + : "energy-charts.info (ENTSO-E + SMARD)"} + — 15-Min-Auflösung, Stand: {fmtTime(live.measuredAtUnix)} Uhr. + Konventionell = Braunkohle + Steinkohle + Erdgas + Kernkraft (Pumpspeicher, + Sonstige Konventionelle und Wasserkraft sind separat ausgewiesen). +

+
+ {/if} + {#if disclaimerHtml || explanationHref || isStale}