Repository navigation
feat(plan-ui): stack price bars into spot + grid tariff + VAT - #191
Conversation
The flat price bar was opaque — users couldn't see why it lands at e.g. 128 öre/kWh. Now each bar is stacked into its three components so it's visually obvious where the kr/kWh goes and which part the planner can actually do something about. Backend (mpc.go): - Action gained SpotOre — the raw wholesale price (öre/kWh, ex grid tariff and VAT), mirroring Slot.SpotOre which the DP already reads for export cost. Surfaces per-slot so the UI doesn't have to back-derive the split. Frontend (web/plan.js + style.css + index.html): - Price bars render as three stacked segments: spot (bottom, tercile-coloured green/red), grid tariff (middle, neutral slate), VAT (top, lighter slate). Tercile colour is applied only to spot since that's the variable part the planner is timing decisions against — fixed portions stay quiet. - Tooltip adds a breakdown block showing spot öre + grid tariff öre + VAT öre for the hovered slot, numbers matching the segments one-for-one. Hover titles explain each component. - Legend splits "Cheap/Expensive" into "Spot (cheap)", "Spot (expensive)", "Grid tariff", "VAT" so users know what each colour in a stacked bar means. - Reads grid_tariff_ore_kwh + vat_percent from /api/config (already fetched for the fuse scale) so the split matches prices.Applier. - Falls back to a single flat bar when spot_ore isn't available (legacy price points from before the SpotOre surface, or a tariff engine with zero grid tariff + VAT). No backend tests change — SpotOre is already exercised end-to-end through the existing DP cost path; the new field just surfaces it. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75527b2f71
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Stack from zero upward. runningOre accumulates in öre/kWh and | ||
| // we re-project each segment's top edge through priceY so the | ||
| // stacked bar lines up pixel-perfect with the axis grid. | ||
| let runningOre = 0; |
There was a problem hiding this comment.
Start stacked bars from plotted baseline, not absolute zero
In the stacked-price renderer, runningOre is initialized to 0 even though the chart’s visible baseline is Math.max(0, priceMin) (see zero in the same block). When all prices are positive (the common case), priceY(0) is below the price band, so each segment is drawn too tall and can bleed into the mode/power areas, misrepresenting relative prices. Initialize the stack accumulator from the plotted baseline (or clip to the price panel) so stacked bars match the axis scale.
Useful? React with 👍 / 👎.
| let runningOre = 0; | ||
| const topY = priceY(priceVal); | ||
| for (const part of parts) { | ||
| if (part.ore <= 0) continue; |
There was a problem hiding this comment.
Preserve negative spot segments in stacked price bars
The stacked loop skips any component with part.ore <= 0, which drops negative spot prices entirely. In negative-price hours (which do occur on Nord Pool), the spot contribution is omitted while fixed components are still added, so the stack no longer matches the slot total and can invert the visual signal for cheap/negative periods. Handle negative components explicitly (draw below baseline) instead of filtering them out.
Useful? React with 👍 / 👎.
…#1811) Move the device-drivers pin from 5cc7bb1a to 219c462e (srcfl/device-drivers#190 and #191). Between the two pins only easee_cloud changed. An Easee Cloud charger given a 6 A order now starts at 7 A per phase when Core's cap_amps_per_phase (#1809) allows 7 A, which avoids Easee's roughly five-minute delay at 6 A, and steps down to 6 A once the charger reports charging or after 90 s. 1.3.8 adds two review fixes: no 7 A before the first poll, and a pause or stand-down cannot leave 7 A for the phaseMode re-assert. Signed-off-by: Fredrik Ahlgren <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Why
Users were asking "what do these price numbers mean?" The flat bars hide where the öre/kWh actually comes from — spot (what the planner can time against) vs grid tariff (fixed) vs VAT (fixed percentage). Making the split visible is pedagogical and makes the planner's behavior more legible ("the planner only cares about the green bit at the bottom").
What
Backend (
go/internal/mpc/mpc.go):ActiongainedSpotOre— raw wholesale price (öre/kWh, ex grid tariff and VAT), surfaced fromSlot.SpotOrethe DP already reads.Frontend (
web/plan.js,style.css,index.html):spot öre,grid tariff öre,VAT öre, one-for-one with the colored segments.grid_tariff_ore_kwh+vat_percentfrom/api/config(already fetched for the fuse scale) so the split matchesprices.Applierexactly.spot_oreisn't available.Test plan
go test ./internal/mpc/...— 94 tests pass🤖 Generated with Claude Code