Skip to content

Keep battery pool metric cache and resend 0 W after failed commands - #1469

Merged
shsms merged 4 commits into
frequenz-floss:v1.x.xfrom
shsms:pool-cache-and-zero-retry
Oct 9, 2026
Merged

shsms merged 4 commits into
frequenz-floss:v1.x.xfrom
shsms:pool-cache-and-zero-retry

Conversation

@shsms

@shsms shsms commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Two battery-control bugs: the battery pool could briefly report no power bounds when batteries rejoined the working set, which made the power manager zero the target power, and a 0 W request after a failed one could be skipped as a repeat.

Changes

  • SendOnUpdate no longer drops cached metrics when a battery leaves the working set. A battery that comes back counts at once instead of after its next sample. Freshness is already handled by the metric fetchers' 2 s timeout and the status trackers. Pinned by test_power_bounds_when_working_batteries_swap.
  • BatteryManager forgets the last set power of an inverter whose request failed or timed out, so the next request is sent even if it is 0 W. The failed request may have been applied. Pinned by test_resend_0w_after_failure.
  • Test-only: start_streaming_power_bounds is extracted from run_power_bounds_test so the new test can give one battery different inverter bounds.
  • Both fixes have Bug Fixes entries in RELEASE_NOTES.md.

@shsms
shsms requested a review from a team as a code owner October 8, 2026 12:50
@shsms
shsms requested review from florian-wagner-frequenz and removed request for a team October 8, 2026 12:50
@github-actions github-actions Bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:data-pipeline Affects the data pipeline part:microgrid Affects the interactions with the microgrid labels Oct 8, 2026
shsms added 4 commits October 8, 2026 15:11
Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Used in the following commit, which needs the same setup with different
inverter bounds for each battery.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Dropping the cached data meant a battery rejoining the working set was
ignored until its next sample, so the power bounds could briefly vanish
and the power manager forced the target to zero. The metric fetchers
already clear stale data, and the status trackers stop using batteries
with stale data.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
A command that failed or timed out may still have been applied. When the
last successful command was 0 W, a following 0 W command was skipped as
a repeat, so the battery could keep running the failed command's power.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
@shsms
shsms force-pushed the pool-cache-and-zero-retry branch from 52b11ad to 89e3673 Compare October 8, 2026 13:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The release-notes update unintentionally removes existing summary and upgrade documentation.

1 open finding
What changed in this PR

Fixes battery-pool control behavior around cached bounds and failed inverter commands.

Changes:

  • Preserve cached metrics when batteries leave the working set.
  • Resend 0 W after failed or timed-out inverter commands.
  • Add regression tests and release notes.
File Description
src/​.../​_methods.py Retains cached battery metrics.
src/​.../​_battery_manager.py Clears failed inverter command state.
tests/​.../​test_battery_pool.py Tests working-battery swaps.
tests/​.../​test_battery_pool_control_methods.py Tests 0 W resend behavior.
RELEASE_NOTES.md Documents fixes but removes unrelated release guidance.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread RELEASE_NOTES.md
@shsms
shsms added this pull request to the merge queue Oct 9, 2026
Merged via the queue into frequenz-floss:v1.x.x with commit 3277e16 Oct 9, 2026
9 checks passed
@shsms
shsms deleted the pool-cache-and-zero-retry branch October 9, 2026 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:data-pipeline Affects the data pipeline part:docs Affects the documentation part:microgrid Affects the interactions with the microgrid part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

Development

Successfully merging this pull request may close these issues.

3 participants