Skip to content

Apply battery config/max_power to the control data - #4371

Merged
LKuemmel merged 2 commits into
openWB:masterfrom
seaspotter:fix-bat-max-power-config
Nov 23, 2026
Merged

LKuemmel merged 2 commits into
openWB:masterfrom
seaspotter:fix-bat-max-power-config

Conversation

@seaspotter

@seaspotter seaspotter commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Die "Maximale Leistung des Speichers" (openWB/bat/<id>/config/max_power) wurde im subdata nicht ausgewertet: Es gab nur einen Zweig für …/bat/<id>/config (ohne Unterthema), max_power blieb immer 0. Damit war die Plausibilitätsprüfung (PeakFilter) für Speicher nie aktiv und fehlerhafte Zählerwerte gelangten in die Logs (siehe #4370). Beim Wechselrichter funktioniert das (…/pv/<id>/config/…).

Summary by Sourcery

Ensure battery max_power configuration is validated and reflected in control data.

Bug Fixes:

  • Apply battery-specific max_power values to control data so PeakFilter plausibility checks can operate correctly.
  • Validate battery max_power updates as non-negative numeric values, while allowing zero to disable the check.

Tests:

  • Add coverage for battery max_power validation and propagation.

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/helpermodules/subdata.py" line_range="632" />
<code_context>
                     if re.search("/bat/[0-9]+/config$", msg.topic) is not None:
                         self.set_json_payload(var["bat"+index].data, msg)
+                    elif re.search("/bat/[0-9]+/config/", msg.topic) is not None:
+                        self.set_json_payload_class(var["bat"+index].data.config, msg)
                     elif re.search("/bat/[0-9]+/get/", msg.topic) is not None:
                         self.set_json_payload_class(var["bat"+index].data.get, msg)
</code_context>
<issue_to_address>
**Malformed limits break battery filtering**

When a retained `openWB/bat/<id>/config/max_power` payload is a string or null, or an anonymous MQTT client publishes a string to `openWB/set/bat/<id>/config/max_power`, `set_json_payload_class` stores the decoded value without type validation, so `PeakFilter.check_values` compares a string or null with zero and raises `TypeError` or lets invalid battery readings reach control data.

Validate or coerce `max_power` to a number before storing it.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread packages/helpermodules/subdata.py Resolved
@LKuemmel
LKuemmel merged commit 69268fc into openWB:master Nov 23, 2026
2 checks passed
@seaspotter
seaspotter deleted the fix-bat-max-power-config branch November 23, 2026 08:13
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