Skip to content

Fix: Verbraucher-Temperaturen als None publiziert, statt nur bei vorhandenem Wert - #4272

Merged
LKuemmel merged 1 commit into
openWB:masterfrom
seaspotter:fix-consumer-temperatures-none-payload
Nov 6, 2026
Merged

LKuemmel merged 1 commit into
openWB:masterfrom
seaspotter:fix-consumer-temperatures-none-payload

Conversation

@seaspotter

@seaspotter seaspotter commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Bei jedem Zyklus wird dieser Fehler geloggt, sobald ein Verbraucher keine Temperaturen liefert (bei mir: Wärmepumpe, Verbraucher 15):

Payload ungültig: Topic 'openWB/set/consumer/15/get/temperatures', Payload 'None' sollte eine Kollektion vom Typ <class 'list'> sein und nur Elemente vom Typ <class 'float'> enthalten.

Mit Abstand die häufigste Fehlermeldung in meinem Log - über 8000 mal am Tag...

Ursache

#4196 hat den Guard if self.state.temperatures is not None: entfernt, damit das Topic laut PR-Beschreibung "beim Hinzufügen" existiert. Das wird aber bereits unabhängig davon in command.py erledigt - dort publiziert add_consumer jedes Feld aus ConsumerGet() (inkl. temperatures=None) einmalig direkt beim Anlegen. Der entfernte Guard in _consumer.py war damit für das eigentliche Ziel der PR unnötig und sorgt seitdem nur noch dafür, dass bei jedem Zyklus None an die Validierung in setdata.py (collection=list, akzeptiert nie None) geschickt wird - für jeden Verbraucher ohne Temperaturdaten, nicht nur für Shelly-Geräte ohne Sensor.

Der automatische Review auf #4196 hat genau das zweimal bemängelt ("Avoid publishing null temperatures for unsupported consumers"), wurde vor dem Merge aber nicht behoben.

Fix

Stellt den ursprünglichen Guard wieder her.

Summary by Sourcery

Bug Fixes:

  • Prevent publishing null consumer temperature values when no temperature data is available, eliminating repeated invalid-payload validation errors.

@sourcery-ai

sourcery-ai Bot commented Nov 5, 2026 •

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

Reviewer's Guide

Restores the temperature availability guard so consumers without temperature data no longer publish None every cycle, eliminating repeated payload validation errors while retaining publication of valid temperature values.

Sequence diagram for guarded consumer temperature publication

sequenceDiagram
    participant ConsumerStore
    participant Broker
    participant Validator

    ConsumerStore->>ConsumerStore: update()
    alt temperatures is not None
        ConsumerStore->>Broker: pub_to_broker(temperatures)
        Broker->>Validator: validate(list[float])
    else temperatures is None
        ConsumerStore-->>Broker: No publication
    end
Loading

File-Level Changes

Change Details Files
Only publish consumer temperature data when a value is available, preventing invalid None payloads from reaching validation.
  • Restore the temperatures is not None guard in the consumer state update flow.
  • Continue publishing valid temperature collections while skipping unsupported or unavailable temperature data.
  • Preserve initial topic creation behavior, which is already handled when adding the consumer.
packages/modules/common/store/_consumer.py

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 5, 2026 22:44

@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 reviewed your changes and they look great!


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

@LKuemmel
LKuemmel merged commit b06c189 into openWB:master Nov 6, 2026
2 checks passed
@seaspotter
seaspotter deleted the fix-consumer-temperatures-none-payload branch November 11, 2026 10:23
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