Skip to content

Active bat control: update power_limit_mode - #3169

Merged
benderl merged 4 commits into
openWB:masterfrom
ndrsnhs:remove-power_limit_mode
Apr 9, 2026
Merged

benderl merged 4 commits into
openWB:masterfrom
ndrsnhs:remove-power_limit_mode

Conversation

@ndrsnhs

@ndrsnhs ndrsnhs commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Regelmodus no_limit existiert in der Form nicht mehr, kann aber ggfs. noch gesetzt sein

@LKuemmel

LKuemmel commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

@ndrsnhs Bitte ein Rebase machen.

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

Bitte auch die anderen alten Bezeichnungen migrieren. "no_limit" ist nur einer von dreien.

@benderl benderl added the bug Something isn't working label Apr 1, 2026
@ndrsnhs ndrsnhs closed this Apr 8, 2026
@ndrsnhs
ndrsnhs force-pushed the remove-power_limit_mode branch from cbd2b6d to ce0aaa4 Compare April 8, 2026 05:58
@ndrsnhs ndrsnhs reopened this Apr 8, 2026
@ndrsnhs
ndrsnhs requested review from LKuemmel and benderl April 8, 2026 06:11

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

This PR bumps the datastore version and adds a new datastore migration to normalize legacy openWB/bat/config/power_limit_mode values that may still be present (e.g. no_limit).

Changes:

  • Increase UpdateConfig.DATASTORE_VERSION from 119 to 120.
  • Add upgrade_datastore_120 to migrate openWB/bat/config/power_limit_mode to current mode values.
  • Append datastore version 120 after running the new migration.

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

Comment thread packages/helpermodules/update_config.py Resolved
Comment thread packages/helpermodules/update_config.py Resolved
Comment thread packages/helpermodules/update_config.py Resolved
Comment on lines +3053 to +3058
if mode == "no_limit" or mode == "limit_stop":
mode = "mode_no_discharge"
return {topic: mode}
else:
mode = "mode_discharge_home_consumption"
return {topic: mode}

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

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

This migration introduces new mapping behavior for openWB/bat/config/power_limit_mode, but there is no test covering the conversion (and especially that already-valid modes are left unchanged). Please add a pytest case similar to existing datastore upgrade tests to prevent regressions.

Suggested change
if mode == "no_limit" or mode == "limit_stop":
mode = "mode_no_discharge"
return {topic: mode}
else:
mode = "mode_discharge_home_consumption"
return {topic: mode}
legacy_mode_mapping = {
"no_limit": "mode_no_discharge",
"limit_stop": "mode_no_discharge",
"limit": "mode_discharge_home_consumption",
}
if mode in legacy_mode_mapping:
return {topic: legacy_mode_mapping[mode]}

Copilot uses AI. Check for mistakes.

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

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


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

Comment on lines +3049 to +3058
def upgrade_datastore_120(self) -> None:
def upgrade(topic: str, payload) -> Optional[dict]:
if re.search("^openWB/bat/config/power_limit_mode$", topic) is not None:
mode = decode_payload(payload)
if mode == "no_limit" or mode == "limit_stop":
mode = "mode_no_discharge"
return {topic: mode}
elif mode == "limit_home_consumption":
mode = "mode_discharge_home_consumption"
return {topic: mode}

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

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

For this new datastore migration (mapping legacy values like "no_limit"/"limit_stop"/"limit_home_consumption" to the current BatPowerLimitMode strings), please add a focused unit test (similar to existing upgrade_datastore_94 coverage in packages/helpermodules/update_config_test.py) to prevent regressions and to document the intended mapping behavior.

Copilot uses AI. Check for mistakes.
@benderl
benderl merged commit 72385b5 into openWB:master Apr 9, 2026
5 checks passed
ndrsnhs added a commit to ndrsnhs/core that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants