Skip to content

Qcells active battery control#3244

Open
Xoffroad wants to merge 3 commits intoopenWB:feature_bat_controlfrom
Xoffroad:qcells-active-battery-control
Open

Qcells active battery control#3244
Xoffroad wants to merge 3 commits intoopenWB:feature_bat_controlfrom
Xoffroad:qcells-active-battery-control

Conversation

@Xoffroad
Copy link

adding active battery control for qcells and new field for overload security

@LKuemmel LKuemmel requested a review from ndrsnhs March 26, 2026 08:35
@Xoffroad
Copy link
Author

Neues Feld entfernt und auf die Nutzung von max_charge_power und max_discharge_power umgebaut.

Copy link
Contributor

@seaspotter seaspotter left a comment

Choose a reason for hiding this comment

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

Mir sei nochmal der Kommentar erlaubt, dass du damit ja im Prinzip jetzt keine zusätzliche Sicherheitsebene einbaust sondern die bereits vorhandene und funktionierende duplizierst und damit ist sie eigentlich unnötig.
Denn schon in der Regelung in ttps://github.com/openWB/core/blob/f3983a443e8f331c1399aeb428f189872185f2ef/packages/control/bat_all.py ist ja sichergestellt das zum einen wenn keine Max Lade-Entladeleistung definiert ist, eine Warnung kommt und zudem das der übergebene power_limit Wert ans Batteriemodul niemals über der Lade- oder der Entladeleistung liegt. Meines Erachtens ist das damit unötig.
In anderen Modulen hat sich zudem power_value etabliert, clamped als Wert ist nicht wirklich sprechend.

if max_discharge <= 0:
log.warning("Maximale Entladeleistung ist nicht konfiguriert (0W). "
"Bitte unter Ladeeinstellungen > Speichersteuerung konfigurieren.")
clamped = int(min(abs(power_limit), max_discharge))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
clamped = int(min(abs(power_limit), max_discharge))
power_value = int(power_limit) * -1

Comment on lines +98 to +100
if max_discharge <= 0:
log.warning("Maximale Entladeleistung ist nicht konfiguriert (0W). "
"Bitte unter Ladeeinstellungen > Speichersteuerung konfigurieren.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if max_discharge <= 0:
log.warning("Maximale Entladeleistung ist nicht konfiguriert (0W). "
"Bitte unter Ladeeinstellungen > Speichersteuerung konfigurieren.")

log.warning("Maximale Entladeleistung ist nicht konfiguriert (0W). "
"Bitte unter Ladeeinstellungen > Speichersteuerung konfigurieren.")
clamped = int(min(abs(power_limit), max_discharge))
log.debug(f"Aktive Batteriesteuerung. Batterie wird mit {clamped} W entladen")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
log.debug(f"Aktive Batteriesteuerung. Batterie wird mit {clamped} W entladen")
log.debug(f"Aktive Batteriesteuerung. Batterie wird mit {power_value} W entladen")

if self.last_mode != 'discharge':
self.last_mode = 'discharge'
# Solax Mode 8: positiver Push Power Wert = Entladung
self._write_mode8(push_power=clamped, unit=unit)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self._write_mode8(push_power=clamped, unit=unit)
self._write_mode8(power_value, unit=unit)

# Solax Mode 8: positiver Push Power Wert = Entladung
self._write_mode8(push_power=clamped, unit=unit)

def _write_mode8(self, push_power: int, unit: int) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def _write_mode8(self, push_power: int, unit: int) -> None:
def _write_mode8(self, power_value: int, unit: int) -> None:

elif power_limit == 0:
log.debug("Aktive Batteriesteuerung. Batterie wird gestoppt (kein Entladen)")
if self.last_mode != 'stop':
self._write_mode8(push_power=0, unit=unit)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self._write_mode8(push_power=0, unit=unit)
self._write_mode8(power_value=0, unit=unit)

import logging
from typing import TypedDict, Any, Optional

from control import data
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
from control import data

Comment on lines +69 to +71
bat_get = data.data.bat_data[f"bat{self.component_config.id}"].data.get
max_charge = bat_get.max_charge_power
max_discharge = bat_get.max_discharge_power
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bat_get = data.data.bat_data[f"bat{self.component_config.id}"].data.get
max_charge = bat_get.max_charge_power
max_discharge = bat_get.max_discharge_power

Comment on lines +72 to +73
log.debug(f"QCells set_power_limit: power_limit={power_limit}, "
f"max_charge={max_charge}W, max_discharge={max_discharge}W, last_mode={self.last_mode}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
log.debug(f"QCells set_power_limit: power_limit={power_limit}, "
f"max_charge={max_charge}W, max_discharge={max_discharge}W, last_mode={self.last_mode}")
log.debug(f"QCells set_power_limit: power_limit={power_limit}, "
f"last_mode={self.last_mode}")

log.warning("Maximale Ladeleistung ist nicht konfiguriert (0W). "
"Bitte unter Ladeeinstellungen > Speichersteuerung konfigurieren.")
clamped = int(min(power_limit, max_charge))
log.debug(f"Aktive Batteriesteuerung. Batterie wird mit {clamped} W geladen")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
log.debug(f"Aktive Batteriesteuerung. Batterie wird mit {clamped} W geladen")
log.debug(f"Aktive Batteriesteuerung. Batterie wird mit {power_value} W geladen")

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