fix(strommix): per-field fallback to Energy-Charts when SMARD value missing
Deploy / verify (push) Successful in 46s
Deploy / deploy (push) Successful in 48s

The widget rendered "Keine gültigen Live-Werte" the moment SMARD's
load filter (id 410) lagged behind the production filters by even one
slot — the aggregator coalesced "filter unavailable" with "filter
returned 0" and the percent calculation refused to divide by zero.

Three changes:

1. SmardSnapshot.values now uses `number | null` so callers can tell
   "filter genuinely missing" apart from "filter reported zero" (e.g.
   solar at night, decommissioned nuclear).
2. Aggregator pulls Energy-Charts (CMS strommix_de) in parallel and
   uses it as a per-field fallback for any SMARD null. New
   `dataSource: "smard+energy-charts"` flag travels in the response so
   the attribution stays honest. Pure SMARD when everything resolves;
   pure Energy-Charts when SMARD is entirely down; the hybrid label
   for the common case where only load drops out.
3. Widget renders the production breakdown + context row + price row
   even when the percentage is unavailable, with a clear "Lastwert
   von SMARD gerade nicht verfügbar" hint instead of going blank.
This commit is contained in:
Peter Meier
2026-05-04 23:55:57 +02:00
parent 96cd9e9c57
commit 2d85681252
4 changed files with 95 additions and 35 deletions
+7 -4
View File
@@ -11,10 +11,13 @@ export type StrommixResponse = {
// the rest of the values. Cross-border + prices may have their own,
// earlier or later, timestamps.
measuredAtUnix: number | null;
/** Where production + load came from. `smard` is canonical (German
* grid feed); `energy-charts` is the fallback when SMARD is
* unreachable. */
dataSource: "smard" | "energy-charts";
/** Where production + load came from. `smard` = pure SMARD (canonical);
* `smard+energy-charts` = SMARD with Energy-Charts as per-field
* fallback for filters SMARD couldn't resolve at the snapshot's slot
* (typically the load filter when SMARD's pipeline lags more than
* the production filters); `energy-charts` = SMARD entirely
* unreachable, full fallback. */
dataSource: "smard" | "smard+energy-charts" | "energy-charts";
// Production (MW)
windOnshoreMw: number;
windOffshoreMw: number;