Skip to content

Say why a savings figure is partial - #2160

Open
frahlg wants to merge 1 commit into
masterfrom
savings-partial-cause
Open

frahlg wants to merge 1 commit into
masterfrom
savings-partial-cause

Conversation

@frahlg

@frahlg frahlg commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Why

Since #2144 (v0.175.0-beta.1) Core counts saved_ore only over the time it knew Home use, and sends that time's bill as compared_actual_cost_ore. actual_cost_ore stays the full bill. So a figure can be partial for two reasons: prices were missing, or Home use was unknown.

The Overview savings card only knew the first. It wrote "Partial price data" for every partial figure, and marked a figure only by whole days with prices. A week where a charger reported no power for days got no mark at all (before: +148, no *).

What changes

  • A figure gets its * when less than 95 % of its time was compared (priced_coverage_pct < 0.95).
  • The note under the figures names the cause: "Home use unknown at times", "Prices missing at times", or "Home use unknown and prices missing at times".
  • Hover gives the share: "The box knew Home use for 67% of the time.", "The box had prices for 50% of the time." or "Home use and prices known 60% of the time."
  • The bill beside the saving, in the headline and the day hover, is compared_actual_cost_ore. An older box sends only actual_cost_ore, which the card still reads. Bill + saving = the no-solar figure again.

The rule, the same in all three clients:

  • Home use is the cause when history_coverage_pct < 0.95.
  • Prices are a cause too when history − priced ≥ 0.05, or when Home use is not the cause.
  • A box without history_coverage_pct reads as before.

About 1 % of each day on the home box is unpriced, where intervals cross a price slot. A 1 % threshold would blame prices wrongly; 5 % does not.

Paired PRs

The box comes first. The clients use the same rule and the iPhone's words:

  • srcfl/ftw-webapp#159 — the web app
  • srcfl/ftw-app#265 — iPhone and Android

None depends on another to build or test.

Evidence

  • cd web && npm test: 1089 pass, with new tests in savings-periods.test.mjs for each cause, the 5 % rule and an older box.
  • make verify: pass.
  • Browser: this branch's web/ and master's, both served against the home box's live API through a read-only proxy.

Before, master, real data from 3 Dec. The week had Home use for 67 % of its time and shows no mark:

before

After, same data:

after

After, the Overview tile at phone width:

after, phone width

After, with a fixture that has both causes:

after, both causes

Hover titles checked in the browser: "Last 7 days: +148 SEK saved. The box knew Home use for 67% of the time."

Not merged; Fredrik decides.

🤖 Generated with Claude Code

Since #2144 a saving counts only time with known Home use. The Overview
card marked a period partial only for whole days without prices, so a day
when a charger reported no power showed no mark at all.

A period is now partial when less than 95 % of its time was compared, as
in the apps. The note names the cause: Home use unknown, prices missing,
or both. A price gap must reach 5 % to be named, because about 1 % of a
day goes unpriced where an interval straddles a price slot. The bill beside
the saving is compared_actual_cost_ore, the bill over the same time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T18:34:49.391977Z da9a7f4 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@miravoss26 miravoss26 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Overview savings card now says why a figure is partial (unknown Home use, missing prices or both) and shows the bill over the compared time.

  • Logic and tests match the description. Older boxes without expected_ms or compared_actual_cost_ore fall back as before.
  • Minor, web/components/savings-periods.js (summarize): with the 95 % threshold, a month with one no_prices day in 30 is now marked complete, although that day is left out of savedMinor. The old code marked it with *. Fine if intended.
  • Security screen: nothing found. The new text is set through textContent, title and aria-label.

Safe to merge from my read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants