Repository navigation
add dataclass object for set_power_limit, DAC - #3855
Merged
LKuemmel merged 3 commits intoAug 26, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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_limitcallbacks to accept aSetLimitDataparameter. - Update multiple consumer modules (and the sample consumer) to the new callback signature and imports.
- Implement DAC power limit scaling using
data.max_powerandModbusDataType.
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_poweris used as a divisor without validation and the computed register value is a float. WithModbusDataType.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 onmax_power <= 0. Guard against non-positivemax_powerand 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
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]>
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.