Skip to content

AlphaEss: calculate currents from powers#3173

Merged
benderl merged 7 commits intoopenWB:masterfrom
ndrsnhs:alphaess-counter-currents
Apr 10, 2026
Merged

AlphaEss: calculate currents from powers#3173
benderl merged 7 commits intoopenWB:masterfrom
ndrsnhs:alphaess-counter-currents

Conversation

@ndrsnhs
Copy link
Copy Markdown
Contributor

@ndrsnhs ndrsnhs commented Mar 3, 2026

Der Faktor der Phasenströme wurde wegen Problemen im Lastmanagement (zu niedrige Ströme) angepasst. Die Anpassung führt aber bei anderen Anlagen zu Problemen (zu hohe Ströme).
AlphaEss Anlagen haben unterschiedliche Faktoren für die Ströme einzelner Phasen. Je nach Modell unterscheiden sich die Werte um den Faktor 10.
Eine Unterscheidung nach Firmware oder Modell ist aktuell nicht möglich. Workaround ist die Berechnung der Phasenströme aus der übermittelten Leistung einzelner Phasen.

Copy link
Copy Markdown
Contributor

@LKuemmel LKuemmel left a comment

Choose a reason for hiding this comment

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

Bitte in einem Kommentar festhalten, warum die Ströme entfernt wurden.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts AlphaESS counter phase-current reporting to avoid model-/firmware-dependent current scaling issues by deriving a per-phase scaling factor from the relationship between reported current, voltage, and per-phase power.

Changes:

  • Reworks AlphaESS counter update logic to rescale phase currents using per-phase power readings.
  • Introduces scale_currents() helper to choose an appropriate scaling factor per phase.
  • Removes PeakFilter usage from the AlphaESS counter component.
Comments suppressed due to low confidence (1)

packages/modules/devices/alpha_ess/alpha_ess/counter.py:36

  • The PeakFilter was removed from the counter component (import, initialization, and check_values(power, imported, exported) call). This also removes plausibility checks for power peaks and sudden imported/exported counter jumps, which can lead to storing implausible values (or losing warnings that other components still emit). If the intention is only to rescale phase currents, keep PeakFilter and continue calling it after reading power/imported/exported.
    def initialize(self) -> None:
        self.__tcp_client: modbus.ModbusTcpClient_ = self.kwargs['tcp_client']
        self.__device_config: AlphaEssConfiguration = self.kwargs['device_config']
        self.__modbus_id: int = self.kwargs['modbus_id']
        self.store = get_counter_value_store(self.component_config.id)
        self.fault_state = FaultState(ComponentInfo.from_component_config(self.component_config))

    def update(self):
        time.sleep(0.1)
        if self.__device_config.source == 0 and self.__device_config.version == 0:
            power, exported, imported = self.__tcp_client.read_holding_registers(

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ndrsnhs ndrsnhs requested a review from Copilot April 8, 2026 09:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

scaled_currents.append(0)
else:
factor = c * 230 / p
rounded_factor = min(factors, key=lambda z: abs(factor - z))
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

scale_currents() selects the nearest scaling factor via min(factors, key=...). In exact tie cases (e.g. computed factor exactly midway between 10 and 100), min(...) will pick the earlier entry in factors, which currently biases toward the smaller magnitude and can mis-scale currents by 10×. Consider making the selection deterministic for ties (e.g. prefer the larger magnitude) or switching to threshold-based rounding on abs(factor) so boundary cases don’t produce large errors.

Suggested change
rounded_factor = min(factors, key=lambda z: abs(factor - z))
rounded_factor = min(factors, key=lambda z: (abs(factor - z), -abs(z)))

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@benderl benderl added the enhancement New feature or request label Apr 10, 2026
@benderl benderl merged commit 58e4040 into openWB:master Apr 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants