Repository navigation
Conversation
Maschga
marked this pull request as ready for review
December 2, 2026 18:53
Contributor
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="cmd/demo_history.go" line_range="15" />
<code_context>
+func seedDemoHistory(now time.Time) error {
+ return db.Instance.Transaction(func(tx *gorm.DB) error {
+ var count int64
+ if err := tx.Model(&session.Session{}).Count(&count).Error; err != nil || count != 0 {
+ return err
+ }
</code_context>
<issue_to_address>
**Concurrent demo starts fail seeding**
When two `--demo` instances seed the same database concurrently, both startup transactions pass the empty-history checks before either commits, then both attempt to create the same meter slots. The primary-key conflict (or a database write-lock error) aborts one transaction, and `runRoot` starts that instance in degraded mode instead of with demo history.
Serialize demo seeding across processes or handle a competing seed transaction by rechecking history and treating already-seeded data as success.
Also at `core/metrics/demo.go:14`.
</issue_to_address>
### Comment 2
<location path="core/metrics/demo.go" line_range="53" />
<code_context>
+ }
+ grid := home + charge + car - pv - discharge
+ for i, value := range [][2]float64{{pv, 0}, {home, 0}, {max(0, grid), max(0, -grid)}, {discharge, charge}, {car, 0}} {
+ history = append(history, meter{Meter: devices[i].Id, Timestamp: t.Unix(), Energy: value[0], ReturnEnergy: value[1], Recovered: slotMeasured})
+ }
+ }
</code_context>
<issue_to_address>
**Battery flows appear reversed**
When demo meter history is seeded and the energy view reads the battery rows, `SeedDemoHistory` stores `discharge` in `Energy` and `charge` in `ReturnEnergy`, but `sinkSlots` reads those fields as charge and discharge, respectively. The energy view therefore shows charging as battery output and discharging as battery input.
Store `charge` in `Energy` and `discharge` in `ReturnEnergy` for the battery rows.
</issue_to_address>
### Comment 3
<location path="core/metrics/demo.go" line_range="23" />
<code_context>
+ {Group: Home, Name: Home, Title: Home},
+ {Group: Grid, Name: "grid", Title: Grid},
+ {Group: Battery, Name: "battery", Title: "battery"},
+ {Group: Loadpoint, Name: "lp-1", Title: "Carport"},
+ }
+ for i := range devices {
</code_context>
<issue_to_address>
**Garage energy history is empty**
When a user views energy history for Garage after demo history is seeded, `SeedDemoHistory` creates and populates only the Carport loadpoint meter, while `seedDemoHistory` assigns alternating sessions to Garage; energy queries therefore return no Garage charging history despite the seeded Garage sessions.
Seed matching Garage loadpoint meter readings, or assign all synthetic sessions to Carport.
Also at `cmd/demo_history.go:48`.
</issue_to_address>
Member
|
Nice. It had that on my internal list for quite a while already. I'd even go a little further (more realistic data) and also add consumer and multiple pv's. We could also think about always using in memory sqlite when in --demo mode. No risk of interfering with real data. |
Member
|
I'll look into this and suggest an iteration. |
Collaborator
Author
|
Closing in favour of #36893 |
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.
Seed sample history when evcc starts with
--demoand neither charging sessions nor meter readings exist. This lets the app publisher’s screenshot workflow capture populated Sessions, Energy, and Battery views without waiting for the simulation to collect data.🤖 Generated with Hermes Agent
\cc @naltatis