Skip to content

Add LoadManager#3636

Draft
AlexanderHa98 wants to merge 6 commits into
openWB:masterfrom
AlexanderHa98:feature_LoadManager
Draft

Add LoadManager#3636
AlexanderHa98 wants to merge 6 commits into
openWB:masterfrom
AlexanderHa98:feature_LoadManager

Conversation

@AlexanderHa98

Copy link
Copy Markdown
Contributor

No description provided.

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

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 thread packages/control/io_device.py Outdated
Comment thread packages/control/loadmanagement.py Outdated
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
Comment thread packages/helpermodules/setdata.py Outdated
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>

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 7 out of 8 changed files in this pull request and generated 5 comments.

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)
Comment thread packages/helpermodules/setdata.py Outdated
return Path(__file__).resolve().parents[2]/"ramdisk"

def loadmanager_topic(self, msg: mqtt.MQTTMessage):
""" Handler für die LoadMananger-Topics
Comment thread packages/control/loadmanagement.py Outdated
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants