Skip to content

Add custom output IDs and harden source configuration and calculations - #1200

Open
softwarecrash wants to merge 9 commits into
DrozmotiX:mainfrom
softwarecrash:fix/1198-1199-calculation-safety
Open

Add custom output IDs and harden source configuration and calculations#1200
softwarecrash wants to merge 9 commits into
DrozmotiX:mainfrom
softwarecrash:fix/1198-1199-calculation-safety

Conversation

@softwarecrash

@softwarecrash softwarecrash commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR improves SourceAnalytix source configuration, output ID handling, cumulative meter reset detection, calculation stability and per-source rounding settings.

Changes

Custom output IDs

  • Adds an editable output ID for every configured source.
  • Pre-fills the field with the existing source-derived ID for backward compatibility.
  • Supports shorter IDs containing letters, numbers, underscores and hyphens.
  • Validates reserved, invalid and duplicate output IDs before saving.
  • Migrates an existing generated object tree when the output ID changes.
  • Copies and verifies the complete tree before removing the previous output.
  • Keeps the source name separate from its technical output ID.

Source configuration validation

  • Validates required price definitions, units and output IDs directly in the custom settings.
  • Disables saving while required settings are invalid when supported by the Admin adapter.
  • Remains compatible with older Admin versions that do not support blocking root validation.

Cumulative meter resets

  • A large decrease is now treated as a reset candidate first.
  • The reset is confirmed only when a following reading remains in the lower range.
  • Temporary zero or low readings are discarded when the meter returns to its previous range.
  • Confirmed resets and replacement meters continue from the previous cumulative total.
  • Small backwards fluctuations remain covered by the configured threshold.

Calculation stability

  • Keeps a stable source state snapshot while asynchronous calculations are running.
  • Prevents configuration updates or object changes from invalidating an active calculation.

Explicit rounding settings

  • Every source now stores explicit decimal settings for consumption and cost values.
  • New sources are pre-filled from the configured instance templates.
  • Existing sources without these fields are migrated once to their previously effective values.
  • Later changes to the instance templates no longer alter existing sources.
  • -1 continues to store exact values without rounding.
  • Invalid legacy values are normalized consistently in both the Admin UI and backend.

Documentation and tests

  • Updates the README for output IDs, meter reset confirmation and rounding behavior.
  • Adds coverage for output ID validation and migration helpers.
  • Adds tests for transient meter readings, confirmed resets and replacement meters.
  • Adds tests for source-specific rounding defaults and legacy value normalization.
  • Updates all included translations.

Closes #617
Closes #1198
Closes #1199
Closes #1202

@softwarecrash
softwarecrash marked this pull request as draft August 5, 2026 08:36
@softwarecrash softwarecrash changed the title Add custom output IDs and harden cumulative calculations Add custom output IDs and harden source configuration and calculations Aug 5, 2026
@softwarecrash
softwarecrash marked this pull request as ready for review August 5, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant