Skip to content

Fix race condition on soc values in web ui#4059

Merged
springfall2008 merged 1 commit into
mainfrom
fix/web_race
Jun 14, 2026
Merged

Fix race condition on soc values in web ui#4059
springfall2008 merged 1 commit into
mainfrom
fix/web_race

Conversation

@springfall2008

Copy link
Copy Markdown
Owner

Maybe root cause of: #4016

Copilot AI review requested due to automatic review settings June 14, 2026 08:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an SoC display inconsistency in the Web UI (suspected recurrence of issue #4016) by reducing the chance of readers observing partially-updated multi-inverter totals while fetch_inverter_data() is summing values.

Changes:

  • Initialize additional inverter-related aggregate fields in PredBat.reset() so they have safe defaults.
  • Refactor Execute.fetch_inverter_data() to accumulate inverter totals in locals and only publish to self.* after the loop completes.
  • Avoid restoring self.soc_kw in Output.calculate_yesterday() (prevents overwriting newer SoC values from other update paths).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
apps/predbat/predbat.py Adds default initialization for additional reserve/limit aggregate fields during reset.
apps/predbat/output.py Stops restoring self.soc_kw at the end of calculate_yesterday().
apps/predbat/execute.py Accumulates inverter totals in locals and publishes after the loop to reduce mid-sum races.

Comment thread apps/predbat/execute.py
@springfall2008 springfall2008 merged commit 074cd83 into main Jun 14, 2026
2 checks passed
@springfall2008 springfall2008 deleted the fix/web_race branch June 14, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants