Skip to content

fix: use real elapsed time for energy calculation instead of fixed in…#107

Merged
derolli1976 merged 1 commit into
devfrom
fix/energy-calculation-websocket
Mar 15, 2026
Merged

fix: use real elapsed time for energy calculation instead of fixed in…#107
derolli1976 merged 1 commit into
devfrom
fix/energy-calculation-websocket

Conversation

@derolli1976
Copy link
Copy Markdown
Owner

…terval

In WebSocket mode, push updates arrive more frequently than the configured polling interval (e.g. every 15s vs 60s). The energy calculation was using the fixed configured interval for every update, causing energy to be overcounted by a factor of (interval / real_elapsed).

Fix: Track the actual timestamp of each update and use the real elapsed time between consecutive updates for the Riemann sum integration. The configured interval is only used as fallback for the very first update after start/restore.

Fixes overcounted Energy produced today (DC) sensor values in WebSocket mode.

Description

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

…terval

In WebSocket mode, push updates arrive more frequently than the
configured polling interval (e.g. every 15s vs 60s). The energy
calculation was using the fixed configured interval for every update,
causing energy to be overcounted by a factor of (interval / real_elapsed).

Fix: Track the actual timestamp of each update and use the real elapsed
time between consecutive updates for the Riemann sum integration.
The configured interval is only used as fallback for the very first
update after start/restore.

Fixes overcounted Energy produced today (DC) sensor values in
WebSocket mode.
@derolli1976 derolli1976 merged commit 0fc5da8 into dev Mar 15, 2026
10 of 11 checks passed
@derolli1976 derolli1976 deleted the fix/energy-calculation-websocket branch March 15, 2026 16:15
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] Über Websocket bringt sensor.inverter_energy_produced_total_dc falsche Werte

1 participant