Skip to content

power limit is int, format bat power limit str - #3276

Merged
benderl merged 3 commits into
openWB:masterfrom
LKuemmel:format_bat_str
Apr 9, 2026
Merged

benderl merged 3 commits into
openWB:masterfrom
LKuemmel:format_bat_str

Conversation

@LKuemmel

@LKuemmel LKuemmel commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

set_power_limit erwartet im Type Hint ein int.
Kommentar zu #3275
Formatierung: https://forum.openwb.de/viewtopic.php?p=141878#p141878

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.

Pull request overview

Adjusts battery power-limit typing and user-facing status text to align with the set_power_limit interface expecting integer watt values (context: #3275).

Changes:

  • Change Bat.Set.power_limit type hint from float to int.
  • Cast computed per-battery power_limit to int before publishing/dispatching.
  • Format battery state_str messages using kW with rounding for charge/discharge.

Reviewed changes

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

File Description
packages/control/bat.py Updates per-battery set/power_limit type hint to integer.
packages/control/bat_all.py Ensures distributed power_limit values are integers and improves state_str formatting.

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

Comment thread packages/control/bat.py
Comment on lines 42 to 45
@dataclass
class Set:
power_limit: float = field(default=None, metadata={"topic": "set/power_limit"})
power_limit: int = field(default=None, metadata={"topic": "set/power_limit"})

Copilot AI Apr 9, 2026

Copy link

Choose a reason for hiding this comment

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

power_limit is annotated as int but the field default is None, so the type should be Optional[int] (and import Optional) to match actual runtime values and the AbstractBat.set_power_limit(self, power_limit: Optional[int]) contract.

Copilot uses AI. Check for mistakes.
@benderl
benderl merged commit ebbb481 into openWB:master Apr 9, 2026
1 check passed
LKuemmel added a commit that referenced this pull request Apr 10, 2026
* power limit is int, format bat power limit str

* type hint

---------

Co-authored-by: benderl <[email protected]>
ndrsnhs pushed a commit to ndrsnhs/core that referenced this pull request Aug 24, 2026
* power limit is int, format bat power limit str

* type hint

---------

Co-authored-by: benderl <[email protected]>
@LKuemmel
LKuemmel deleted the format_bat_str branch September 14, 2026 10:27
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.

3 participants