feat(blocks): live_strommix widget for energy-charts data
Editor-controlled live-strommix card that surfaces what share of
electricity demand is currently covered by weather-dependent
renewables (Wind+Solar / Load), plus the conventional generation that
fills the gap, the cross-border saldo, and the day-ahead price (DE/FR
side-by-side). Status bucket + label + argument come from the CMS so
editors can iterate copy without a deploy.
- LiveStrommixBlockData type next to the other block-types.
- New `/api/strommix` aggregator route bundles four CMS external
collections (strommix_de, crossborder_de, price_de, price_fr) into a
single payload, computes the renewable + conventional sums and the
cross-border saldo (Σ flow_xx_gw, sign convention: + = export from
DE), surfaces stale-on-error flags from the CMS response headers.
Cache-control 5min so a single node only hits energy-charts once
per window.
- StrommixBlock.svelte renders the card: percentage, bucket label,
bucket argument (markdown), context row (conventional + saldo with
↑/↓ arrow), price row with optional FR comparison + negative-price
badge, footer with disclaimer + "Wie wird das berechnet?" link +
stale-data hint when the CMS served fallback. Re-polls every 5min
client-side; bucket thresholds + labels + arguments come from the
block instance so multiple placements can carry different copy.
- ContentRows.svelte dispatcher branch on `_type === "live_strommix"`.
Wired against `cms_content/_types/core/live_strommix.json5` (added in
the rustycms repo today). content_layout.row{1,2,3}Content already
allow the new block-type via the same commit on the CMS side.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Shared types for the Strommix-Live-Widget.
|
||||
*
|
||||
* The aggregator route at `/api/strommix` builds this payload from the
|
||||
* four CMS external collections; the `StrommixBlock.svelte` component
|
||||
* consumes it.
|
||||
*/
|
||||
|
||||
export type StrommixResponse = {
|
||||
measuredAtUnix: number | null;
|
||||
// Production (MW)
|
||||
windOnshoreMw: number;
|
||||
windOffshoreMw: number;
|
||||
solarMw: number;
|
||||
biomassMw: number;
|
||||
hydroMw: number;
|
||||
ligniteMw: number;
|
||||
hardCoalMw: number;
|
||||
gasMw: number;
|
||||
nuclearMw: number;
|
||||
// Aggregates (MW)
|
||||
loadMw: number;
|
||||
weatherRenewableMw: number;
|
||||
conventionalMw: number;
|
||||
// Cross-border (GW; positive = net export from DE, negative = import)
|
||||
netFlowGw: number;
|
||||
flowsByCountry: Record<string, number>;
|
||||
// Prices (EUR/MWh; null if upstream unavailable)
|
||||
priceDeEurMwh: number | null;
|
||||
priceFrEurMwh: number | null;
|
||||
// Stale flags surfaced from the CMS' `x-rustycms-external-stale` header
|
||||
staleStrommix: boolean;
|
||||
staleCrossborder: boolean;
|
||||
stalePrice: boolean;
|
||||
};
|
||||
Reference in New Issue
Block a user