Skip to content

add dataclass object for set_power_limit, DAC - #3855

Merged
LKuemmel merged 3 commits into
openWB:feature_consumer_modulesfrom
LKuemmel:consumer_modules_dev
Aug 26, 2026
Merged

LKuemmel merged 3 commits into
openWB:feature_consumer_modulesfrom
LKuemmel:consumer_modules_dev

Conversation

@LKuemmel

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

This PR updates the consumer “set power limit” hook to accept an additional dataclass payload (SetLimitData) and applies that new signature across several consumer implementations, enabling DAC consumers to scale output based on configured max_power.

Changes:

  • Extend consumer set_power_limit callbacks to accept a SetLimitData parameter.
  • Update multiple consumer modules (and the sample consumer) to the new callback signature and imports.
  • Implement DAC power limit scaling using data.max_power and ModbusDataType.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/modules/consumers/solarfocus/vampair/consumer.py Update set_power_limit signature to include SetLimitData.
packages/modules/consumers/ratiotherm/ratiotherm/consumer.py Rename/adjust limit setter to new set_power_limit(..., data) signature.
packages/modules/consumers/ovum/ovum/consumer.py Update tunable limit setter signature to accept SetLimitData.
packages/modules/consumers/my_pv/elwa_e/consumer.py Update set_power_limit signature and wiring in ConfigurableConsumer.
packages/modules/consumers/my_pv/acthor/consumer.py Update set_power_limit signature and wiring in ConfigurableConsumer.
packages/modules/consumers/lambda_/lambda_/consumer.py Update set_power_limit signature and wiring in ConfigurableConsumer.
packages/modules/consumers/idm/idm/consumer.py Update set_power_limit signature and wiring in ConfigurableConsumer.
packages/modules/consumers/generic/json/consumer.py Update set_power_limit signature to accept SetLimitData.
packages/modules/consumers/generic/http/consumer.py Update set_power_limit signature to accept SetLimitData.
packages/modules/consumers/generic/dac/consumer.py Implement DAC scaling using data.max_power + Modbus typed writes.
packages/modules/consumers/askoma/askoheat/consumer.py Update set_power_limit signature and wiring in ConfigurableConsumer.
docs/samples/sample_consumer/sample_consumer/consumer.py Update sample implementation to new set_power_limit(..., data) signature.
Suppressed comments (1)

packages/modules/consumers/generic/dac/consumer.py:33

  • data.max_power is used as a divisor without validation and the computed register value is a float. With ModbusDataType.INT_16, the Modbus wrapper writes the value directly as a 16-bit register (expects an int), so this can raise at runtime and will also crash on max_power <= 0. Guard against non-positive max_power and convert/clamp the register value to an int before writing.
    def set_power_limit(power_limit: float, data: SetLimitData) -> None:
        power_limit = max(power_limit, 0)
        modbus_id = config.configuration.modbus_id
        if config.configuration.model == Model.N4Dac02:
            client.write_register(1, power_limit * 1000 / data.max_power, ModbusDataType.INT_16, unit=modbus_id)
        elif config.configuration.model == Model.DA02:
            client.write_register(0x01f4, power_limit * 4000 / data.max_power, ModbusDataType.INT_16, unit=modbus_id)
        elif config.configuration.model == Model.M120T:

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@@ -12,7 +12,7 @@


def create_consumer(config: Dac):
client = None
client: ModbusTcpClient_ = None
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@LKuemmel
LKuemmel merged commit 0258045 into openWB:feature_consumer_modules Aug 26, 2026
1 check passed
LKuemmel added a commit that referenced this pull request Aug 26, 2026
* draft dac

* add dataclass object for set_power_limit

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
LKuemmel added a commit that referenced this pull request Aug 28, 2026
* draft dac

* add dataclass object for set_power_limit

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
LKuemmel added a commit that referenced this pull request Sep 7, 2026
* draft dac

* add dataclass object for set_power_limit

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
LKuemmel added a commit that referenced this pull request Sep 8, 2026
* draft dac

* add dataclass object for set_power_limit

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
LKuemmel added a commit that referenced this pull request Sep 9, 2026
* draft dac

* add dataclass object for set_power_limit

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
LKuemmel added a commit that referenced this pull request Sep 9, 2026
* draft dac

* add dataclass object for set_power_limit

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
LKuemmel added a commit that referenced this pull request Sep 9, 2026
* draft dac

* add dataclass object for set_power_limit

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
LKuemmel added a commit that referenced this pull request Sep 9, 2026
* draft dac

* add dataclass object for set_power_limit

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
LKuemmel added a commit that referenced this pull request Sep 9, 2026
* draft dac

* add dataclass object for set_power_limit

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
LKuemmel added a commit that referenced this pull request Sep 9, 2026
* draft dac

* add dataclass object for set_power_limit

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
LKuemmel added a commit that referenced this pull request Sep 9, 2026
* draft dac

* add dataclass object for set_power_limit

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
LKuemmel added a commit that referenced this pull request Sep 9, 2026
* draft dac

* add dataclass object for set_power_limit

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
LKuemmel added a commit that referenced this pull request Sep 9, 2026
* modules

* Vampair (#3815)

* Vampair

* typo

* review

* review

* review

* add dataclass object for set_power_limit, DAC (#3855)

* draft dac

* add dataclass object for set_power_limit

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* Fix consumer modules (#3865)

* fix configuration type hints

* fix consumer type hints and errors

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* rewrite dac consumer module (#3878)

* fix avm usage (#3913)

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: benderl <[email protected]>
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