fix(strommix): SMARD as primary source — accuracy parity with audit
Deploy / verify (push) Successful in 45s
Deploy / deploy (push) Successful in 49s

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.
This commit is contained in:
Peter Meier
2026-05-04 23:47:52 +02:00
parent f4e4abd978
commit 96cd9e9c57
5 changed files with 290 additions and 62 deletions
@@ -250,6 +250,36 @@
{/if}
</div>
<!-- Production breakdown: aufklappbar damit user die Summe nachvollziehen
kann. Werte sind aufeinander abgestimmt (gleicher SMARD-15-min-Slot). -->
{#if live}
<details class="mt-3 text-xs">
<summary class="cursor-pointer text-neutral-600 hover:text-neutral-900">
Wert prüfen — alle Komponenten anzeigen
</summary>
<div class="mt-2 grid grid-cols-2 gap-x-4 gap-y-1 rounded-md border border-neutral-200 bg-neutral-50 px-3 py-2 tabular-nums sm:grid-cols-3">
<div class="text-neutral-500">Wind onshore</div><div>{fmtMw(live.windOnshoreMw)}</div>
<div class="text-neutral-500">Wind offshore</div><div>{fmtMw(live.windOffshoreMw)}</div>
<div class="text-neutral-500">Photovoltaik</div><div>{fmtMw(live.solarMw)}</div>
<div class="text-neutral-500">Braunkohle</div><div>{fmtMw(live.ligniteMw)}</div>
<div class="text-neutral-500">Steinkohle</div><div>{fmtMw(live.hardCoalMw)}</div>
<div class="text-neutral-500">Erdgas</div><div>{fmtMw(live.gasMw)}</div>
<div class="text-neutral-500">Kernkraft</div><div>{fmtMw(live.nuclearMw)}</div>
<div class="text-neutral-500">Biomasse</div><div>{fmtMw(live.biomassMw)}</div>
<div class="text-neutral-500">Wasserkraft</div><div>{fmtMw(live.hydroMw)}</div>
<div class="text-neutral-500 font-semibold">Last</div><div class="font-semibold">{fmtMw(live.loadMw)}</div>
</div>
<p class="mt-1 text-[11px] text-neutral-500">
Quelle: {live.dataSource === "smard"
? "smard.de (Bundesnetzagentur)"
: "energy-charts.info (ENTSO-E + SMARD)"}
— 15-Min-Auflösung, Stand:&nbsp;{fmtTime(live.measuredAtUnix)}&nbsp;Uhr.
Konventionell = Braunkohle + Steinkohle + Erdgas + Kernkraft (Pumpspeicher,
Sonstige Konventionelle und Wasserkraft sind separat ausgewiesen).
</p>
</details>
{/if}
<!-- Footer: disclaimer + explanation link + stale flag -->
{#if disclaimerHtml || explanationHref || isStale}
<footer class="mt-3 text-xs text-neutral-600 flex flex-wrap items-start gap-x-4 gap-y-1">