-
Notifications
You must be signed in to change notification settings - Fork 111
generator_systems: configure another output io device as input device #3228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -57,7 +57,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class UpdateConfig: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DATASTORE_VERSION = 113 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DATASTORE_VERSION = 114 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| valid_topic = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "^openWB/bat/config/bat_control_permitted$", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -2958,3 +2958,16 @@ def upgrade(topic: str, payload) -> None: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self._loop_all_received_topics(upgrade) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self._append_datastore_version(113) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def upgrade_datastore_114(self) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def upgrade(topic: str, payload) -> Optional[dict]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if re.search("openWB/io/action/[0-9]+/config", topic) is not None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config = decode_payload(payload) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (config["configuration"]["passthrough_enabled"] is True and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config["configuration"].get("io_device_output") is None): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config["configuration"]["io_device_output"] = config["configuration"].get("io_device") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config["configuration"]["io_device_output"] = None | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return {topic: config} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+2964
to
+2971
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if re.search("openWB/io/action/[0-9]+/config", topic) is not None: | |
| config = decode_payload(payload) | |
| if (config["configuration"]["passthrough_enabled"] is True and | |
| config["configuration"].get("io_device_output") is None): | |
| config["configuration"]["io_device_output"] = config["configuration"].get("io_device") | |
| else: | |
| config["configuration"]["io_device_output"] = None | |
| return {topic: config} | |
| if re.search(r"^openWB/io/action/[0-9]+/config$", topic) is not None: | |
| config = decode_payload(payload) | |
| # Only apply this migration to stepwise_control IO actions that are expected | |
| # to have a passthrough_enabled flag in their configuration. | |
| if config.get("type") == "stepwise_control": | |
| configuration = config.get("configuration") or {} | |
| passthrough_enabled = configuration.get("passthrough_enabled") | |
| if passthrough_enabled is True and configuration.get("io_device_output") is None: | |
| configuration["io_device_output"] = configuration.get("io_device") | |
| else: | |
| configuration["io_device_output"] = None | |
| config["configuration"] = configuration | |
| return {topic: config} |
Copilot
AI
Mar 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are existing unit tests for datastore migrations (packages/helpermodules/update_config_test.py covers e.g. upgrade_datastore_94). Adding upgrade_datastore_114 introduces new migration behavior (and edge cases like existing io_device_output / non-stepwise configs) but no corresponding test. Please add a focused test that asserts the migration only touches stepwise_control actions and that it preserves an existing io_device_output value.
| if re.search("openWB/io/action/[0-9]+/config", topic) is not None: | |
| config = decode_payload(payload) | |
| if (config["configuration"]["passthrough_enabled"] is True and | |
| config["configuration"].get("io_device_output") is None): | |
| config["configuration"]["io_device_output"] = config["configuration"].get("io_device") | |
| else: | |
| config["configuration"]["io_device_output"] = None | |
| return {topic: config} | |
| if re.search(r"^openWB/io/action/[0-9]+/config$", topic) is not None: | |
| config = decode_payload(payload) | |
| # Only adjust stepwise_control actions and do not overwrite an existing io_device_output | |
| if config.get("type") != "stepwise_control": | |
| return None | |
| configuration = config.get("configuration", {}) | |
| # Preserve existing io_device_output values | |
| if configuration.get("io_device_output") is not None: | |
| return None | |
| # For passthrough-enabled stepwise_control actions with no io_device_output set, | |
| # default io_device_output to the existing io_device value | |
| if configuration.get("passthrough_enabled") is True: | |
| configuration["io_device_output"] = configuration.get("io_device") | |
| config["configuration"] = configuration | |
| return {topic: config} | |
| return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upgrade_datastore_114overwrites an already configuredio_device_output: whenpassthrough_enabledis true butio_device_outputis already set, the currentelsebranch resets it toNone. This will silently drop the user’s new output-device selection. Adjust the logic to only set a default when the key is missing/None, and otherwise preserve the existing value (and only clear it when passthrough is disabled, if that’s intended).