Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/helpermodules/update_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

class UpdateConfig:

DATASTORE_VERSION = 119
DATASTORE_VERSION = 120

valid_topic = [
"^openWB/bat/config/bat_control_permitted$",
Expand Down Expand Up @@ -3045,3 +3045,16 @@ def upgrade(topic: str, payload) -> None:
return {component_topic: config_payload}
self._loop_all_received_topics(upgrade)
self._append_datastore_version(119)

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}
Comment on lines +3053 to +3058
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.
Comment on lines +3049 to +3058
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.
self._loop_all_received_topics(upgrade)
self._append_datastore_version(120)
Loading