Skip to content

consumer ems-esp: automatisch zwischen heatpump/boiler ermitteln - #4290

Merged
LKuemmel merged 2 commits into
openWB:masterfrom
seaspotter:fix-ems-esp-heatpump-boiler-fallback
Nov 10, 2026
Merged

LKuemmel merged 2 commits into
openWB:masterfrom
seaspotter:fix-ems-esp-heatpump-boiler-fallback

Conversation

@seaspotter

@seaspotter seaspotter commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #4282. Der EMS-ESP-Gerätename war hart auf "heatpump" kodiert.
Bei manchen Wärmepumpen (hier: Bosch Compress 6800i) liegen die hp*-Entities (inkl. hpcurrpower) stattdessen unter "boiler" - "heatpump" liefert dort ein 404 mit {"message":"unknown device heatpump"}.
Betraf nicht nur die Leistungsmessung, sondern auch SG-Ready-Schalten (switch_on/switch_off/set_power_limit nutzen denselben base_url).

Ermittelt beim ersten Zugriff automatisch, unter welchem der beiden
Gerätenamen hpcurrpower tatsächlich existiert, und verwendet das Ergebnis
danach für Lesen und Schreiben. Kein neues Konfigurationsfeld nötig.

Summary by Sourcery

Automatically detect and reuse the EMS-ESP device endpoint that exposes the heat-pump entities.

Bug Fixes:

  • Detect the EMS-ESP heat-pump entity under either the heatpump or boiler device name, fixing power readings and SG-Ready controls for devices such as Bosch Compress 6800i.

Enhancements:

  • Cache the detected device endpoint for subsequent reads and writes without requiring a new configuration option.

Tests:

  • Add coverage for endpoint detection, fallback behavior, caching, write operations, missing entities, and non-404 HTTP errors.

@sourcery-ai

sourcery-ai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Inspect endpoint detection and caching together with the imports, device-name candidates, and read/write paths that use the selected endpoint.

  • packages/modules/consumers/ems_esp/ems_esp/consumer.py L15-27, L32-54, L64-70 (+2 small edits)

Tests

Review tests covering endpoint selection, fallback, caching, writes through the detected endpoint, missing entities, and propagation of non-404 HTTP errors.

  • packages/modules/consumers/ems_esp/ems_esp/consumer_test.py L1-86

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

@seaspotter
seaspotter requested a review from LKuemmel November 9, 2026 15:17

@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/ems_esp/ems_esp/consumer.py" line_range="37" />
<code_context>
+            url = f"http://{config.configuration.ip_address}/api/{device_name}"
+            try:
+                values = session.get(url, headers=headers).json()
+            except requests.exceptions.HTTPError:
+                continue
+            if "hpcurrpower" in values:
</code_context>
<issue_to_address>
**HTTP failures are misreported**

When an endpoint probe returns a non-404 HTTP error, `_detect_base_url` catches the error and probes the next endpoint, so it can raise a misleading `ValueError` or select and cache `boiler` when `heatpump` failed; later readings and control writes then use the wrong endpoint instead of surfacing the HTTP failure.

Continue probing only for the expected unknown-device 404 and re-raise other HTTP errors.
</issue_to_address>

Linked issues

#4282 [BUG] ems-esp heatpump vs. boiler · 2 of 2 met

# Requirement Status Notes
1 Die Leistung der Wärmepumpe unter /api/boiler erfassen, wenn hpcurrpower dort vorhanden ist. ✅ Met Beim ersten Zugriff wird /api/heatpump und danach /api/boiler auf hpcurrpower geprüft; der gefundene Endpunkt wird für die Messung verwendet.
2 SG-Ready-Schalten ebenfalls über den passenden Gerätenamen unterstützen. ✅ Met Alle Schreibvorgänge, einschließlich switch_on, switch_off und set_power_limit, verwenden den ermittelten Endpunkt.

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

@LKuemmel
LKuemmel merged commit 638a94b into openWB:master Nov 10, 2026
2 checks passed
@seaspotter
seaspotter deleted the fix-ems-esp-heatpump-boiler-fallback branch November 10, 2026 12:47
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.

[BUG] ems-esp heatpump vs. boiler

2 participants