Skip to content

Fix/ess cluster power distribution v1 - #3946

Merged
sfeilmeier merged 2 commits into
OpenEMS:developfrom
Christoph-87:fix/ess-cluster-power-distribution-v1
Sep 8, 2026
Merged

sfeilmeier merged 2 commits into
OpenEMS:developfrom
Christoph-87:fix/ess-cluster-power-distribution-v1

Conversation

@Christoph-87

Copy link
Copy Markdown
Contributor

Summary

Controller.Symmetric.Balancing (and other controllers using the V1 power
distribution) silently fails when Ess.Cluster is used as ess.id. The
scheduler cycle logs repeated errors like:

Coefficient for [essCluster0,ALL,ACTIVE] was not found
Coefficient for [essCluster0,ALL,REACTIVE] was not found

Meanwhile ctrlBalancing0/State reports Ok — no setpoints are applied to
the underlying physical ESS components.

Root Cause

The V1 power distribution (Data.updateInverters()) had two related gaps
when a MetaEss wrapper (e.g. EssCluster) was present in the ESS list:

  1. Phantom Inverter: An Inverter entry was created for the MetaEss
    itself, even though it has no physical inverter and its applyPower()
    intentionally throws "should never be called".

  2. Missing member coefficients: Only the cluster's own ID was added to
    the Coefficients set. The member IDs (ess0, ess1, …) were never
    registered, so ConstraintUtil.createMetaEssConstraints() could not
    build the cluster = ess0 + ess1 constraint — causing the
    "Coefficient not found" error at runtime.

Note: The V2 power distribution (BALANCE strategy) already handles
MetaEss correctly via its Virtual/Actual entry pattern. This fix
brings V1 to the same level.

Fix

Two small changes in
io.openems.edge.ess.core/…/power/v1/Data.java (updateInverters()):

  • Skip MetaEss during Inverter creation — only physical ESS
    instances get an Inverter entry.
  • Expand MetaEss member IDs into the Coefficients set — member IDs
    are resolved via MetaEss.getEssIds() and added alongside the cluster ID.

No other changes are needed: ConstraintUtil.createMetaEssConstraints() and
Solver.applySolution() already handle MetaEss correctly once the
coefficients are in place.

Tests

Two new test cases added to DataTest:

Checklist

  • Existing tests pass (./gradlew :io.openems.edge.ess.core:test)
  • New regression tests added
  • No changes outside io.openems.edge.ess.core
  • V2 / BALANCE strategy behaviour unchanged

Closes #3752

…ution

When EssCluster is used as ess.id in a controller (e.g.
Controller.Symmetric.Balancing), the V1 power distribution solver failed
with "Coefficient for [essCluster0,ALL,ACTIVE] was not found" because:

1. Inverters were created for MetaEss wrappers that have no physical
   inverter, causing the solver to operate on a non-existent entry.
2. Member ESS IDs (ess0, ess1) were never registered in the Coefficients,
   so MetaEss constraints (cluster = ess0 + ess1) could not be built.

Fix: skip MetaEss instances during Inverter creation, and expand their
member IDs into the Coefficients set. The rest of the pipeline
(ConstraintUtil.createMetaEssConstraints, Solver.applySolution) already
handles MetaEss correctly and needs no changes.

Closes OpenEMS#3752
- testNoInverterForMetaEss: verifies that MetaEss wrappers do not get
  their own Inverter entry in the V1 power distribution
- testMemberCoefficientsRegisteredWhenOnlyClusterInEsss: verifies that
  member ESS IDs of a MetaEss are registered in Coefficients even when
  only the cluster itself is listed in esss (the core of issue OpenEMS#3752)
@codecov

codecov Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@              Coverage Diff               @@
##             develop    #3946       +/-   ##
==============================================
+ Coverage      27.79%   55.88%   +28.10%     
- Complexity         0    19348    +19348     
==============================================
  Files            318     3705     +3387     
  Lines           9502   173325   +163823     
  Branches        1596    14256    +12660     
==============================================
+ Hits            2640    96845    +94205     
- Misses          6727    72642    +65915     
- Partials         135     3838     +3703     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Christoph-87

Copy link
Copy Markdown
Contributor Author

Relation to issue #3500

Issue #3500 describes the Coefficient for [essCluster0,...] was not found error and attributes it to two root causes:

  1. A race condition during OSGi startup caused by the @Reference(cardinality = MANDATORY) pattern on Power in ESS implementations — proposed fix: change to OPTIONAL/DYNAMIC.
  2. Missing synchronization in Data.getConstraintsWithoutDisabledInverters().

This PR addresses a third, related root cause that is not covered by #3500: Data.updateInverters() was creating a phantom Inverter entry for MetaEss wrappers (e.g. EssCluster) and never registering the member IDs (ess0, ess1, …) in the coefficient set. As a result, createMetaEssConstraints() could not build the cluster = ess0 + ess1 constraint, which is the direct cause of the essCluster0 coefficient error in cluster setups.

This PR and #3500 are complementary and do not conflict — they touch different methods in Data.java. Both can be merged independently.

@pooran-c pooran-c 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.

Nice, MetaEss is no longer an Inverter entry.
"Coefficient not found issue" will be fixed in #3938

@pooran-c
pooran-c requested a review from sfeilmeier September 7, 2026 11:41
pooran-c added a commit to hvgollar/openems that referenced this pull request Sep 7, 2026
@sfeilmeier
sfeilmeier merged commit 6a35698 into OpenEMS:develop Sep 8, 2026
7 checks passed
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.

Controller.Symmetric.Balancing accepts Ess.Cluster but fails with missing power coefficients

3 participants