Repository navigation
fix(history): keep working measurements when a device is offline - #1592
Conversation
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90817e4b73
ℹ️ 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".
| if opts.PVInvalidReason != "" { | ||
| p.Missing |= state.MissingPV | ||
| } |
There was a problem hiding this comment.
Treat configured but unmeasured PV as missing
When weather.pv_rated_w or PV arrays declare solar but no driver provides a PV flow, forecastMeasurementTopology sets HouseholdInvalidReason to configured_pv_without_measurement_source; it does not set PVInvalidReason. Because this condition checks only the latter and Known[DerPV] remains true when there is no flow, every live-meter tick is persisted with PV equal to a measured zero. The daily history then permanently reports 0 Wh rather than unknown solar generation, so this household topology needs to set MissingPV as well.
AGENTS.md reference: AGENTS.md:L22-L23
Useful? React with 👍 / 👎.
| if count > 0 { | ||
| sum /= float64(count) |
There was a problem hiding this comment.
Preserve capacity weighting for site SoC
On sites with multiple batteries of unequal capacity, this replaces the capacity-weighted avgSoC already computed by handleStatus with an unweighted mean of telemetry sources. For example, a 10 kWh battery at 20% and a 2 kWh battery at 80% changes from the existing 30% site value to 50%, making the dashboard and API report the wrong aggregate SoC. Keep the existing weighted value when all required SoCs are known, and only null it when qualification fails.
Useful? React with 👍 / 👎.
| if source.Flow.DerType == telemetry.DerBattery { | ||
| d["soc"] = source.SoC |
There was a problem hiding this comment.
Clear the battery SoC field consumed by clients
When a battery becomes stale or offline, source.SoC is nil, but the driver map already contains the last reading under bat_soc from handleStatus. Assigning nil to a new soc key leaves that stale bat_soc intact; existing UI paths read d.bat_soc, so driver cards can continue showing the old percentage even though power and site-level SoC are unknown. Update or clear bat_soc instead.
AGENTS.md reference: AGENTS.md:L22-L23
Useful? React with 👍 / 👎.
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c0fdaa5521
ℹ️ 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".
| pts.push({ x: tsToX(ts), y: valToY(sr.data[j]) }); | ||
| } | ||
| if (pts.length) segments.push(pts); | ||
| segments.forEach(function (pts) { |
There was a problem hiding this comment.
Keep live pulses on the latest segment only
When a series contains one or more null gaps, this loop adds the endpoint of every historical segment to liveTips; the later pulse renderer then gives all of those old endpoints a static halo and a fresh ripple on every new data push. This makes measurements immediately before an outage look live, so only cache the final segment's endpoint when it reaches the newest sample.
AGENTS.md reference: AGENTS.md:L22-L23
Useful? React with 👍 / 👎.
A fresh native install can show current meter readings while an offline battery prevents all dashboard history. The published v0.141.0-beta.1 reproduced this: meter samples kept writing, but the dashboard stayed empty and day/week totals read as zero.
Keep each working flow in chart and energy history. Mark missing power and state of charge as unknown, keep gaps in Live/day/week views, and flag incomplete measurements or an invalid household balance. Household load remains unknown until all inputs form a valid balance. Forecast learning and dispatch keep their existing strict checks.
Keep state schema 7 and put partial chart/energy rows and daily caches in separate additive tables, with missing-field evidence in the same transaction. Older Cores read only complete rows in the original tables and their cursor cannot bridge a partial interval after rollback. The newer Core reads both, including partial rows retained across the old return. The native schema/order release preflight passes. Quality survives averaging, retention, restart and full backup/restore. No launcher or schema-change guard is bypassed.
Validation:
make verifyand focused race tests pass on top of the merged timezone, EV departure and protocol PRs.bat_socfield. Finalmake verifyand focused race tests pass on c0fdaa5.This fixes the reproduced offline-device history defect. It does not establish the cause of the earlier storage deadlines or complete general migration qualification.