Skip to content

Victron bat control mode 1 - #3850

Merged
LKuemmel merged 20 commits into
openWB:masterfrom
ndrsnhs:victron-bat-control-mode
Oct 12, 2026
Merged

LKuemmel merged 20 commits into
openWB:masterfrom
ndrsnhs:victron-bat-control-mode

Conversation

@ndrsnhs

@ndrsnhs ndrsnhs commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Victron erwartet in allen Modi die Übergabe des Grid Setpoints.
In dieser Implementierung wird dafür Mode 1 genutzt.
Mode 2 deaktiviert die Phasensaldierung und ist daher nicht nutzbar.
Mode 3 setzt die Register entgegen der Dokumentation nach 10-14 Sekunden zurück

Die für die Berechnung nötigen zusätzlichen Daten werden als dataclass übergeben. Die Entscheidung welche Werte und wie diese genutzt werden/ die Berechnung verbleibt damit in der Komponente.

Für die Entladesperre wird weiterhin Mode 2 genutzt. Bei kompletter Sperre des Speichers spielt die fehlende Saldierung keine Rolle. Die Register haben eine längere Lebensdauer als in Mode 3

@ndrsnhs
ndrsnhs marked this pull request as ready for review August 25, 2026 07:54
@ndrsnhs
ndrsnhs requested a review from LKuemmel August 25, 2026 07:54

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.

🟡 Changes recommended

The dispatch can pass SetPoint objects to unupdated battery implementations, and Victron’s unconditional register read can interrupt control writes.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Extends battery control with EVU power data and Victron ESS Mode 1 grid-setpoint handling.

Changes:

  • Adds and propagates the SetPoint dataclass.
  • Migrates battery adapters and MQTT/configuration handling.
  • Updates Victron charge/discharge control.
File summaries
File Summary
packages/modules/devices/victron/victron/bat.py Implements Victron Mode 1 grid-setpoint control.
packages/modules/devices/varta/varta/bat_modbus.py Migrates battery control input.
packages/modules/devices/sungrow/sungrow_sh/bat.py Migrates battery control input.
packages/modules/devices/sungrow/sungrow_ihm/bat.py Migrates battery control input.
packages/modules/devices/sonnen/sonnenbatterie/bat.py Migrates battery control input.
packages/modules/devices/solis/solis/bat.py Migrates battery control input.
packages/modules/devices/solax/solax/bat.py Migrates battery control input.
packages/modules/devices/solaredge/solaredge/bat.py Migrates battery control input.
packages/modules/devices/sma/sma_sunny_island/bat.py Migrates battery control input.
packages/modules/devices/sma/sma_sunny_boy/bat.py Migrates battery control input.
packages/modules/devices/sigenergy/sigenergy/bat.py Migrates battery control input.
packages/modules/devices/qcells/qcells/bat.py Migrates battery control input.
packages/modules/devices/marstek/venus_c_e/bat.py Migrates battery control input.
packages/modules/devices/kostal/kostal_plenticore/bat.py Migrates battery control input.
packages/modules/devices/good_we/good_we/bat.py Migrates battery control input.
packages/modules/devices/generic/mqtt/bat.py Migrates MQTT battery control input.
packages/modules/devices/batterx/batterx/bat.py Migrates battery control input.
packages/modules/devices/anker/solarbank/bat.py Migrates battery control input.
packages/modules/devices/alpha_ess/alpha_ess/bat.py Migrates battery control input.
packages/modules/common/configurable_device.py Passes setpoint data through the fault wrapper.
packages/helpermodules/update_config.py Registers the EVU power topic.
packages/helpermodules/setdata.py Validates EVU power input.
packages/helpermodules/mosquitto_dynsec/missing_role_topics_test.py Updates internal topic permissions tests.
packages/control/process.py Passes complete battery setpoints to devices.
packages/control/bat.py Adds the EVU power setpoint field.
packages/control/bat_all.py Populates EVU power for battery control.
Review details

Suppressed comments (1)

packages/modules/devices/victron/victron/bat.py:64

  • This read is performed even for None and 0 setpoints, although bat_power is only used in the charge/discharge branches. Besides adding a Modbus request every control cycle, a read failure can prevent the following self-regulation/stop writes and leave the previous Victron mode active. Read register 842 only when calculating an active grid setpoint (or use the cached value for that calculation).
        bat_power = self.__tcp_client.read_holding_registers(842, ModbusDataType.INT_16, unit=modbus_id)
  • Files reviewed: 26/26 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

Comment thread packages/control/process.py Outdated

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.

Copilot review overview

🟡 Changes recommended

The new SetPoint contract is not reflected in the AbstractBat interface and remaining sample implementations.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity

Open (2)

Comment thread packages/modules/common/configurable_device.py Outdated

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.

Copilot review overview

🟡 Changes recommended

The AbstractBat contract migration leaves the repository’s documented sample implementations on the old scalar API.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 2 Medium severity

Open (3)

Comment thread packages/modules/common/abstract_device.py

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.

Comment thread docs/samples/sample_modbus/sample_modbus/bat.py
Comment thread packages/control/process.py Outdated
Comment thread packages/modules/devices/victron/victron/bat.py

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.

Comment thread packages/modules/devices/victron/victron/bat.py Outdated

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.

Copilot review overview

🟡 Changes recommended

A critical circular import and additional contract and Victron control issues remain unresolved.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (2)

Comment thread packages/modules/common/abstract_device.py

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.

Copilot review overview

🟡 Changes recommended

A critical Sungrow register collision and a moderate Victron read-path issue remain unresolved; EVU handoff coverage is also requested.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread packages/modules/devices/sungrow/sungrow_ihm/bat.py Outdated

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.

Copilot review overview

🔵 Needs a closer look

Resolve the three moderate findings and add the requested EVU-power regression assertion.

Review effort: Lite
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Read bat_power only during active control

packages/​modules/​devices/​victron/​victron/​bat.py:64

This read is performed before the no-control and stop branches, even though those paths do not use bat_power. A transient failure reading register 842 will therefore prevent the reset/stop writes from being sent (and adds an unnecessary Modbus round trip on every such call). Move the read into the nonzero active-control path so self-regulation and the discharge lock remain operable when the power-status register cannot be read.

@LKuemmel LKuemmel 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.

Passt soweit, SunEnergyXT fehlt noch von den neuen Modulen.

@ndrsnhs
ndrsnhs requested a review from LKuemmel October 12, 2026 07:13
@LKuemmel
LKuemmel merged commit 4a4f8cd into openWB:master Oct 12, 2026
1 check 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.

Victron Bat control with only 1 phase no phase compensation

3 participants