PV: track energy metrics and apply forecast scaling to optimizer#29784
Conversation
bafadd5 to
cd87cd4
Compare
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
updatePvMeters, the error logpersist pv %d energyonly includes the index; consider including the PV meter name (name) to make diagnosing persistence issues easier. solarScaleis now called both fromsolarDetailsand the optimizer, which will duplicate thesolar forecast: ...DEBUG logs each cycle; consider either centralizing the call or making logging conditional to avoid noisy duplicate entries.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `updatePvMeters`, the error log `persist pv %d energy` only includes the index; consider including the PV meter name (`name`) to make diagnosing persistence issues easier.
- `solarScale` is now called both from `solarDetails` and the optimizer, which will duplicate the `solar forecast: ...` DEBUG logs each cycle; consider either centralizing the call or making logging conditional to avoid noisy duplicate entries.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
b2ff268 to
ec633bd
Compare
- Add per-PV metrics.Collector (group=pv) so each PV meter's production surfaces in the History UI like grid/home/battery/loadpoints. - Extract solarScale() helper from solarDetails so the scale is reusable. - Optimizer applies the solarScale factor to the solar forecast input rather than feeding raw forecast rates, making the optimization react to consistent under-/over-production. - Re-enable the experimental adjusted-solar-forecast toggle in the Forecast view (issue #29165 was addressed in resetSolarForecastMetrics).
ec633bd to
efa07aa
Compare
- Add new metrics collector group "forecast" alongside pv/grid/battery/home
- Replace fcstEnergy *Accumulator with a *metrics.Collector that buckets
forecast energy into 15-min slots and persists to the metrics DB
- Drop the per-PV-meter pvProduction accumulator map (the existing
pv energy collector already records production)
- Compute solarScale() by querying QueryImportEnergy("day") for both
the "pv" and "forecast" groups so the ratio comes from durable data,
not in-memory accumulators
- Remove the daily-reset bookkeeping (resetSolarAccumulatorsIfNewDay,
SolarAccDay/SolarAccForecast/SolarAccYield settings) — the day window
now falls out of the metrics query (BeginningOfDay → now)
- solarScale now returns (float64, bool); update site_optimizer caller
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6c34558 to
434a7ef
Compare
|
@copilot resolve the merge conflicts in this pull request |
Merge conflicts are resolved. I merged the remote PR branch and Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
2f38765 to
972df73
Compare
|
@premultiply is PV production import (implemented here) or export? Looking at the other PR discussions I think we might need to swap here. Can you formulate a rule/rules that we can use in documentation? or even better a simple markdown table for all device types we have (battery charge = import, ...). |
|
@naltatis see #29788 (comment): production is export. |
This comment was marked as resolved.
This comment was marked as resolved.
|
Definition: energy direction is from device to energy grid.
Current "legacy" energy mapping is marked in bold. This is also our internal positive power direction (most important / "main usage"). |
This comment was marked as resolved.
This comment was marked as resolved.
|
@premultiply just to be clear: self-consumption == self-consumption of the device (like standby power), right? |
|
Yes. This may or may not included in the measurement of the device. Depends on the device and internal setup itself. |
|
So battery and pv will have the opposite sign as "normal" (e.g. in log)? |
|
I've added designator for positive power in table above- still doesn't feel consistent. |
|
Table represented as diagram. We're still not clear regarding the metrics table how we want to use import/export and how that aligns with the current device power signs: ---
Energy flow
---
flowchart
loadpoint(Loadpoint)
site((Site))
grid(Grid)
pv(PV)
battery(Battery)
grid -- Consumption
(+ import/energy) --> site
site -- Feed-in
(- export/return energy) --> grid
pv -- Production
(+ export/energy) --> site
site -- Charge
(- import/return energy) --> battery
battery -- Discharge
(+ export/energy) --> site
site -- Consumption
(+ import/energy) --> loadpoint
|
|
Just a thought: |
|
Long story short: we're dumping the import/export concept and settle on energy/return energy. |
Summary
Three related changes around PV energy and the solar forecast scale factor:
Per-PV
metrics.Collector(core/site.go)pvCollectors map[string]*metrics.Collectorkeyed by meter ref, grouppvpvEnergyaccumulator inBoot()updatePvMetersviaAddEnergy(&mm[i].Energy if >0, nil, mm[i].Power)mirroring the grid/battery patternsReusable
solarScale()helper (core/site_tariffs.go)produced/forecastedratio calc out ofsolarDetailsso the optimizer can call it without re-running the side effects (AddImportEnergy, settings persist).fcst > 0,produced+fcst > 0.5 kWh) — no behavior change in the publishedsolarDetails.Scale.Optimizer applies the scale (
core/site_optimizer.go)solarScale()when available, so the optimizer reflects consistent under-/over-production rather than the bare forecast.Re-expose the adjusted-forecast toggle in the UI (
assets/js/views/Forecast.vue)&& falseguard was added in Forecast UI: real data adjust (-100 %) #29165 (forecast metrics could go inconsistent on restart).resetSolarForecastMetrics, so the experimental toggle is unblocked.Test plan
go build ./...cleangofmt -lclean on touched Go filesgo vet ./core/...cleango test ./core/... -count=1npm run lint(eslint, vue-tsc, i18n) cleanmeterstable under grouppvsolar.scaleis published andForecastview exposes the adjust toggle in experimental modesolar forecast: ... scale ...)