Skip to content

Active bat control: update power_limit_mode#3169

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

Active bat control: update power_limit_mode#3169
benderl merged 4 commits intoopenWB:masterfrom
ndrsnhs:remove-power_limit_mode

Conversation

@ndrsnhs
Copy link
Copy Markdown
Contributor

@ndrsnhs ndrsnhs commented Mar 2, 2026

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

@LKuemmel
Copy link
Copy Markdown
Contributor

LKuemmel commented Mar 3, 2026

@ndrsnhs Bitte ein Rebase machen.

Copy link
Copy Markdown
Contributor

@benderl benderl left a comment

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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 Outdated
Comment thread packages/helpermodules/update_config.py Outdated
Comment thread packages/helpermodules/update_config.py Outdated
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}
Copy link

Copilot AI Apr 8, 2026

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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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}
Copy link

Copilot AI Apr 8, 2026

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
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