Metrics: add ext/aux meters#29836
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The
extEnergyandauxEnergymaps are populated usingrefinBoot, butaddMeterEnergylooks up collectors bydev.Config().Name, which can diverge fromref; consider using the same key (reforConfig().Ref) consistently for both map population and lookup. - In
addMeterEnergy, the function assumesmetersandmmhave matching lengths when indexing byi; if this ever changes upstream, a bounds panic is possible, so it may be safer to guard on the minimum length or explicitly validate the sizes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `extEnergy` and `auxEnergy` maps are populated using `ref` in `Boot`, but `addMeterEnergy` looks up collectors by `dev.Config().Name`, which can diverge from `ref`; consider using the same key (`ref` or `Config().Ref`) consistently for both map population and lookup.
- In `addMeterEnergy`, the function assumes `meters` and `mm` have matching lengths when indexing by `i`; if this ever changes upstream, a bounds panic is possible, so it may be safer to guard on the minimum length or explicitly validate the sizes.
## Individual Comments
### Comment 1
<location path="core/site.go" line_range="739" />
<code_context>
+// addMeterEnergy persists per-meter energy (positive power = import).
+func (site *Site) addMeterEnergy(key string, meters []config.Device[api.Meter], collectors map[string]*metrics.Collector, mm []types.Measurement) {
+ for i, dev := range meters {
+ c, ok := collectors[dev.Config().Name]
+ if !ok {
+ continue
</code_context>
<issue_to_address>
**issue (bug_risk):** Collector map is keyed by meter ref, but lookup uses `Config().Name`, which may not match.
`extEnergy`/`auxEnergy` are populated as `site.extEnergy[ref] = me` / `site.auxEnergy[ref] = me`, with the maps documented as keyed by meter ref. Here, the lookup uses `collectors[dev.Config().Name]`. If `ref` ≠ `Config().Name`, the collector won’t be found and energy won’t be persisted. Please align the lookup key with the map key (e.g. use `ref` or whatever is used when populating the map).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
6 tasks
andig
reviewed
May 12, 2026
andig
reviewed
May 12, 2026
Member
Author
|
Collected values look fine. |
andig
reviewed
May 12, 2026
andig
reviewed
May 12, 2026
Member
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: andig <184815+andig@users.noreply.github.com>
auto-merge was automatically disabled
May 15, 2026 14:44
Head branch was pushed to by a user without write access
Contributor
Merge conflicts are resolved in 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:
|
Drop separate site.pvEnergy map and site.fcstEnergy field; route PV and solar forecast collectors through the shared site.collectors map. Also formats NewSite() struct literal to satisfy gofmt/gci (fixes Lint and Clean CI failures). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refs #29144
Adds per-meter metrics.Collector for ext and aux meters, mirroring the grid/battery/pv pattern.
Todo