Repository navigation
fix(history): keep the chart running when optional PV never reports - #1480
Conversation
Adding a Zap P1 meter stopped history_dashboard and history_site_energy for good. The Zap catalog lists pv, but PV reading is off unless read_pv is set. The forecast topology still expects a PV reading from it, and since #1089 the history point uses those same forecast options. The Zap never reports PV, so every tick wrote no history point, and the same config rebuilt the same block after each restart. History now uses its own options: the same flows, minus PV that config does not declare, and without the identity gate. PV that a source does report is still checked for freshness. Forecast learning is unchanged. Closes #1441 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> 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: 76643ea128
ℹ️ 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 !optional[flow] { | ||
| flows = append(flows, flow) |
There was a problem hiding this comment.
Keep optional PV invalid until its driver is live
When a catalog entry combines PV with another capability and the configuration does not explicitly declare PV, this removes the PV flow even if the driver is offline or has not completed its first poll. If that device really supplies PV, the telemetry scan has no reading with which to add it back, so the site-meter-only balance is accepted and history permanently records PV as zero and grid power as household load until the first PV sample arrives—potentially throughout an outage. Treat the missing optional flow as absent only after the live driver has established that it will not publish PV, so freshness failures do not become measured energy.
AGENTS.md reference: AGENTS.md:L22-L23
Useful? React with 👍 / 👎.
Thanks @segran2 for the detailed report. The exact timestamps, the cursor rows and the note that raw tables kept moving made this quick to find.
Problem
Adding a Zap P1 meter stopped
history_dashboardandhistory_site_energyfor good. Restarts did not help.meter,pvandbattery. PV reading is off unlessread_pvis set.forecastMeasurementTopology(go/cmd/ftw/forecast_measurements.go) still addssourceful-zap:pvto the expected flows whenread_pvis missing. It marks itoptional_pv_requires_measurement.buildHistoryPointchecks the balance with those forecast options. The Zap never reports PV, so the balance ismissing:sourceful-zap:pvon every tick. The tick then stores no history point.recordDashboardTxwriteslast=0and nothing else. That is the cursor state in the report. It is a symptom, not stuck state.The forecast identity gate (
unconfirmed_device_identity) blocks history the same way while any device identity is unconfirmed.Change
History gets its own options,
HistoryOptions:PV that a source does report is still checked, so a stale reading still stops history. Missing known flows (battery, dedicated PV, EV) still stop it too. Forecast learning keeps its strict options.
HistoryOptionsis not part of any revision, so this resets no learned model.After upgrade
No manual repair is needed. The next valid point sets
lastand writes a dashboard row. The gap since the freeze stays a gap. Until then, settingread_pv: falseon the Zap driver also unblocks history on the current release.Evidence
TestHistoryKeepsRunningWithOptionalPVAndUnconfirmedIdentitybuilds the reported site: Zap site meter, SMA PV, Pixii battery, one unconfirmed identity. It fails onmasterwithavailable=false, with or without the identity gap. It passes with this change. It also checks that an offline battery or a stale reported PV reading still stops history.go test ./cmd/ftw -count=1passes.make verifypasses.Closes #1441
🤖 Generated with Claude Code