Skip to content

Prevent negative PV string energy (v1.2.7.4) - #421

Merged
TypQxQ merged 1 commit into
mainfrom
Dev-1.2.7.4
Sep 15, 2026
Merged

TypQxQ merged 1 commit into
mainfrom
Dev-1.2.7.4

Conversation

@TypQxQ

@TypQxQ TypQxQ commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Treat non-positive PV-string voltage or current as zero production.
  • Prevent signed low-light measurement offsets from reducing calculated PV-string energy.
  • Bump the integration version to 1.2.7.4.
  • Add focused regression tests for positive, zero, and negative PV inputs.

Root cause

Sigenergy's signed per-string current registers can report small negative offsets under low-light conditions. The integration multiplied those values by the still-positive string voltage and integrated the resulting negative power. This allowed the accumulated and daily PV-string energy sensors to decrease between resets, violating the daily sensor's TOTAL_INCREASING contract.

The captured log in #419 confirms examples such as 168.6 V × -0.02 A = -0.003372 kW, which is sufficient to explain the reported micro-kWh decreases.

Fix

The PV-string power calculation now returns 0.0 kW whenever either input is non-positive. The shared integration sensor and its daily reset behavior remain unchanged, so this does not affect any future intentionally bidirectional integration sensors.

Validation

  • python -m unittest discover -s tests -v — 15 tests passed
  • Python syntax compilation
  • Manifest JSON validation
  • git diff --check

Fixes #419

@greptile-apps

greptile-apps Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with the PV power floor matching the production-source contract and no actionable regressions identified.

Summary

This PR prevents signed low-light PV measurement offsets from producing negative string power and decreasing integrated energy.

  • Returns unavailable state for conversion failures and zero power when voltage or current is non-positive.
  • Adds focused regression coverage for positive, zero, and negative PV inputs.
  • Updates the integration version to 1.2.7.4.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read PV voltage and current] --> B{Inputs present and numeric?}
  B -- No --> C[Return None]
  B -- Yes --> D[Convert inputs to Decimal]
  D --> E{Conversion successful?}
  E -- No --> C
  E -- Yes --> F{Voltage or current non-positive?}
  F -- Yes --> G[Return 0.0 kW]
  F -- No --> H[Multiply voltage by current]
  H --> I[Convert watts to kilowatts]
Loading

Reviews (1) · Last reviewed commit: "Prevent negative PV string energy (v1.2...."

@TypQxQ

TypQxQ commented Sep 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: eb8e0ae43c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@TypQxQ
TypQxQ merged commit 3f8fd26 into main Sep 15, 2026
4 checks passed
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] Entity sensor.outside_sigen_inverter_pv1_daily_energy from integration sigen has state class total_increasing, but its state is negative

1 participant