Add LoadManager#3636
Draft
AlexanderHa98 wants to merge 6 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new “LoadManager” integration that ingests import-limit data via MQTT as an IO device and applies it as an additional limiting step in the charging loadmanagement pipeline.
Changes:
- Introduces a new MQTT-based IO device module for LoadManager analog inputs (max power/current/timestamp).
- Adds a new controllable-consumers action (
DimmingLoadManager) and wires it into loadmanagement limiting. - Extends MQTT set-topic validation to include the new loadmanager topic.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/modules/io_devices/load_manager/config.py | Defines LoadManager IO device config and analog input mapping. |
| packages/modules/io_devices/load_manager/api.py | Subscribes to internal MQTT topics and populates IoState analog inputs for the LoadManager. |
| packages/modules/io_devices/load_manager/init.py | Module package initializer for the new IO device. |
| packages/modules/io_actions/controllable_consumers/load_manager/config.py | Adds configuration/setup types for the new controllable-consumers LoadManager action. |
| packages/modules/io_actions/controllable_consumers/load_manager/api.py | Implements DimmingLoadManager action that provides remaining import power for loadmanagement. |
| packages/helpermodules/setdata.py | Validates the new openWB/set/mqtt/loadmanager/... topic so it is forwarded to internal MQTT. |
| packages/control/loadmanagement.py | Adds a new _limit_loadmanager limiting step in get_available_currents. |
| packages/control/io_device.py | Registers the new IO action type and exposes it via IoActions.dimming_load_manager(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+191
to
+198
| dimming_power_left, limit = data.data.io_actions.dimming_load_manager({"type": "cp", "id": cp.num}) | ||
| if dimming_power_left is not None: | ||
| if sum(available_currents)*230 > dimming_power_left: | ||
| phases = 3-available_currents.count(0) | ||
| overload_per_phase = (sum(available_currents) - dimming_power_left/230)/phases | ||
| available_currents = [c - overload_per_phase if c > 0 else 0 for c in available_currents] | ||
| log.debug(f"Reduzierung der Ströme durch die Dimmung: {available_currents}A") | ||
| return available_currents, limit |
Comment on lines
+36
to
+42
| def setup(self) -> None: | ||
| if check_fault_state_io_device(self.config.configuration.io_device): | ||
| self.import_power_left = self.config.configuration.fixed_import_power | ||
| else: | ||
| max_power = data.data.io_states[f"io_states{self.config.configuration.io_device}" | ||
| ].data.get.analog_input[AnalogInputMapping.MAX_POWER.name] | ||
| self.import_power_left = max_power |
| return Path(__file__).resolve().parents[2]/"ramdisk" | ||
|
|
||
| def loadmanager_topic(self, msg: mqtt.MQTTMessage): | ||
| """ Handler für die LoadMananger-Topics |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment on lines
+33
to
+41
| self.name = name | ||
| self.type = type | ||
| self.id = id | ||
| self.configuration = configuration or LoadManagerConfiguration() | ||
| if input is None: | ||
| input = init_input() | ||
| if output is None: | ||
| output = init_output() | ||
| super().__init__(name, type, id, configuration or LoadManagerConfiguration(), input=input, output=output) |
| broker = BrokerClient("subscribeMqttLoadmanager", | ||
| on_connect, on_message) | ||
|
|
||
| return ConfigurableIo(config=config, component_reader=read, component_writer=lambda: None, initializer=initializer) |
| return Path(__file__).resolve().parents[2]/"ramdisk" | ||
|
|
||
| def loadmanager_topic(self, msg: mqtt.MQTTMessage): | ||
| """ Handler für die LoadMananger-Topics |
Comment on lines
+192
to
+198
| if dimming_power_left is not None: | ||
| if sum(available_currents)*230 > dimming_power_left: | ||
| phases = 3-available_currents.count(0) | ||
| overload_per_phase = (sum(available_currents) - dimming_power_left/230)/phases | ||
| available_currents = [c - overload_per_phase if c > 0 else 0 for c in available_currents] | ||
| log.debug(f"Reduzierung der Ströme durch die Dimmung: {available_currents}A") | ||
| return available_currents, limit |
Comment on lines
+188
to
+198
| def _limit_loadmanager(self, | ||
| available_currents: List[float], | ||
| cp: Chargepoint) -> Tuple[List[float], LoadmanagementLimit]: | ||
| dimming_power_left, limit = data.data.io_actions.dimming_load_manager({"type": "cp", "id": cp.num}) | ||
| if dimming_power_left is not None: | ||
| if sum(available_currents)*230 > dimming_power_left: | ||
| phases = 3-available_currents.count(0) | ||
| overload_per_phase = (sum(available_currents) - dimming_power_left/230)/phases | ||
| available_currents = [c - overload_per_phase if c > 0 else 0 for c in available_currents] | ||
| log.debug(f"Reduzierung der Ströme durch die Dimmung: {available_currents}A") | ||
| return available_currents, limit |
…8/core into feature_LoadManager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.