Skip to content

fix: consumer Lambda - #4269

Merged
LKuemmel merged 2 commits into
openWB:masterfrom
seaspotter:fix/lambda-consumer-negative-evu-power
Nov 6, 2026
Merged

LKuemmel merged 2 commits into
openWB:masterfrom
seaspotter:fix/lambda-consumer-negative-evu-power

Conversation

@seaspotter

@seaspotter seaspotter commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

UI: openWB/openwb-ui-settings#1162

#4226 (comment)
#4264

Fixt den Fehler und gibt im UI eindeutig vor welche Einstellung an der Lambda WP im E-Manager eingestellt werden muss, damit openWB die korrekten Werte sendet.

Will close: #4269

Summary by Sourcery

Fix Lambda consumer power exchange so openWB sends correctly signed values for the required E-Manager surplus configuration.

Bug Fixes:

  • Correct Lambda heat pump power and surplus communication by sending signed 16-bit values with the required polarity.

Enhancements:

  • Clarify the required Lambda E-Manager configuration for interpreting negative surplus values correctly.

@sourcery-ai

sourcery-ai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The Lambda consumer now sends register 102 values as signed 16-bit Modbus data and applies the required negative sign when writing calculated surplus limits, matching the documented E-Manager configuration and preventing incorrect power interpretation.

Sequence diagram for Lambda consumer Modbus updates

sequenceDiagram
    participant Core
    participant LambdaConsumer
    participant EManager

    Core->>LambdaConsumer: send_values(values)
    LambdaConsumer->>EManager: write_register(102, values.evu_power, data_type=INT_16, wordorder=Little)
    Core->>LambdaConsumer: set_power_limit(power_limit, data)
    LambdaConsumer->>EManager: write_register(102, -max(power_limit, 0), data_type=INT_16, wordorder=Little)
    EManager-->>LambdaConsumer: Interpret register 102 as Neg. E-Überschuss
Loading

File-Level Changes

Change Details Files
Correct Lambda E-Manager power-value encoding and sign handling for both telemetry and surplus limits.
  • Explicitly write register 102 as a signed 16-bit Modbus value.
  • Negate non-negative surplus limits so the required “Neg. E-Überschuss” E-Manager setting interprets them correctly.
  • Keep the Modbus byte order and configured unit ID unchanged.
packages/modules/consumers/lambda_/lambda_/consumer.py

Possibly linked issues

  • #Lambda Modul: The PR explicitly fixes the Lambda consumer error reported in the issue and updates its required settings.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/modules/consumers/lambda_/lambda_/consumer.py" line_range="32" />
<code_context>
         # das kann openWB nicht per Modbus setzen. Wird vom Core automatisch aufgerufen,
         # solange dieser Verbraucher als ConsumerUsage.SELF_CONTROLLED konfiguriert ist.
-        client.write_register(102, values.evu_power, wordorder=Endian.Little, unit=config.configuration.modbus_id)
+        client.write_register(102, values.evu_power, data_type=ModbusDataType.INT_16,
+                              wordorder=Endian.Little, unit=config.configuration.modbus_id)

</code_context>
<issue_to_address>
**Signed power writes fail**

When the EVU value is negative, a positive power limit is negated, or a float power value reaches the write, `ModbusClient.write_register` passes 16-bit values directly to pymodbus instead of encoding them as signed register words, so negative EVU values and negated limits are rejected; float values also reach pymodbus without integer conversion. The register write fails, and the Lambda does not receive the EVU or power-limit update.

Encode signed 16-bit values into valid register words, and convert float power inputs to integers, before calling pymodbus.

Also at `packages/modules/consumers/lambda_/lambda_/consumer.py:47-48`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

# das kann openWB nicht per Modbus setzen. Wird vom Core automatisch aufgerufen,
# solange dieser Verbraucher als ConsumerUsage.SELF_CONTROLLED konfiguriert ist.
client.write_register(102, values.evu_power, wordorder=Endian.Little, unit=config.configuration.modbus_id)
client.write_register(102, values.evu_power, data_type=ModbusDataType.INT_16,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Signed power writes fail

When the EVU value is negative, a positive power limit is negated, or a float power value reaches the write, ModbusClient.write_register passes 16-bit values directly to pymodbus instead of encoding them as signed register words, so negative EVU values and negated limits are rejected; float values also reach pymodbus without integer conversion. The register write fails, and the Lambda does not receive the EVU or power-limit update.

Encode signed 16-bit values into valid register words, and convert float power inputs to integers, before calling pymodbus.

Also at packages/modules/consumers/lambda_/lambda_/consumer.py:47-48.

Prompt for AI agents
In `packages/modules/consumers/lambda_/lambda_/consumer.py` at line 32:

**Signed power writes fail**

When the EVU value is negative, a positive power limit is negated, or a float power value reaches the write, `ModbusClient.write_register` passes 16-bit values directly to pymodbus instead of encoding them as signed register words, so negative EVU values and negated limits are rejected; float values also reach pymodbus without integer conversion. The register write fails, and the Lambda does not receive the EVU or power-limit update.

Encode signed 16-bit values into valid register words, and convert float power inputs to integers, before calling pymodbus.

Also at `packages/modules/consumers/lambda_/lambda_/consumer.py:47-48`.

@Funkentratzer

Copy link
Copy Markdown

THX Seaspotter

@seaspotter
seaspotter requested a review from LKuemmel November 5, 2026 22:45
@seaspotter seaspotter mentioned this pull request Nov 6, 2026
@LKuemmel
LKuemmel merged commit ababe7f into openWB:master Nov 6, 2026
2 checks passed
@seaspotter
seaspotter deleted the fix/lambda-consumer-negative-evu-power branch November 6, 2026 09:12
@LKuemmel LKuemmel linked an issue Nov 6, 2026 that may be closed by this pull request
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.

Lambda Modul

3 participants