Skip to content

Hinzufügen eines Modul für LHG - #26

Merged
DrNiels merged 9 commits into
masterfrom
feture/LHG-PDF
Nov 16, 2026
Merged

DrNiels merged 9 commits into
masterfrom
feture/LHG-PDF

Conversation

@Sunnyka98

Copy link
Copy Markdown
Contributor

No description provided.

Sunnyka98 and others added 8 commits April 14, 2025 16:03
- Complete rebuild of generated chart, allowing more flexibility for start and end
- Removed aggregation level, it's determined depending on start and end
- Translate module, including configuration, variable names and report, removing property for decimal seperator in the process
…ifferent units, taking the displayed one from the first variable on the list
@DrNiels
DrNiels requested a balanced review from Copilot November 16, 2026 13:52
@DrNiels DrNiels self-assigned this Nov 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Archive queries can silently omit data beyond 10,000 logged days and understate totals, alongside unresolved lifecycle, dependency-tracking, failure-return, and precision defects.

5 open issues
What changed in this PR

Adds a consumption-report module for LHG to the existing PDF reporting library, using archived counter data to generate totals and charts.

Changes:

  • Generates PDF consumption reports for selected date ranges, with configurable logos and SMTP delivery.
  • Adds module registration, configuration controls, and German translations.
  • Corrects an existing translation key and ignores local VS Code settings.
File Description
PDFReportSingle/​locale.json Corrects the decimal-separator translation key.
PDFReportConsumption/​module.php Implements consumption calculations, charts, PDF generation, and email delivery.
PDFReportConsumption/​module.json Registers the new consumption-report module.
PDFReportConsumption/​locale.json Adds German translations for the module.
PDFReportConsumption/​form.json Adds logo, SMTP, recipient, and counter configuration.
.gitignore Excludes the root .vscode directory.

Review effort: Balanced

$name = $variable['Name'] == '' ? IPS_GetName($variable['CounterVariable']) : $variable['Name'];
$variable = $variable['CounterVariable'];
//AC_GetAggregatedValues returns all periods starting within [start, end], so the period starting at the end has to be excluded
$aggregatedValues = AC_GetAggregatedValues($archiveID, $variable, $interval['Level'], $startTime, $endTime - 1, 0);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ist zu selten als dass es wirklich relevant wird

Comment thread PDFReportConsumption/module.php Resolved
Comment thread PDFReportConsumption/module.php Resolved
Comment thread PDFReportConsumption/module.php Resolved
Comment thread PDFReportConsumption/module.php Resolved
- Call parent::ApplyChanges
- Register references
- Return false when generation fails
- Preserve consumption precision until formatting

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The report sums counters with incompatible units and labels values using the first counter’s unit, producing misleading per-counter readings and invalid totals.

2 open issues
3 previously missed issues

In code that hasn't changed since last review

Medium severity Validate configured counters before generating the report

PDFReportConsumption/​module.php:45

The list's Add action initializes CounterVariable to 0 (form.json:53), so a nonempty list does not guarantee a usable counter. An unfinished row, or a row referencing a deleted variable, passes this check and reaches the archive and formatting APIs with an invalid ID. Please validate every configured counter before generating the PDF and return false for invalid selections.

Medium severity Preserve chart-wide settings when updating datasets

PDFReportConsumption/​module.php:95

Saving or reapplying the instance configuration discards all chart-wide settings because the existing content is reduced to datasets here. For example, a chart customized with type: "bar" or a profile loses those settings even when the counter list is unchanged. Preserve the existing top-level chart properties and replace only datasets.

Medium severity Treat missing archive data as unavailable, not zero consumption

PDFReportConsumption/​module.php:453

When a selected counter has no archived aggregates for the chosen dates (for example, logging has only just been enabled), this code produces zero-filled bars and a consumption of 0. No error status is set, so GenerateReport() returns true and SendReport() can email missing data as a valid zero-consumption report. Please detect empty or failed archive results and propagate a failure or explicitly mark the data as unavailable instead of treating it as measured zero usage.

4 resolved since last review

Review effort: Balanced

}

$consumption = array_sum($barValues);
$totalConsumption += $consumption;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Es ist ziemlich kompliziert auszuwerten, ob das jetzt wirklich unterschiedliche Einheiten sind oder nicht. Somit kann es meiner Meinung nach einfach so bleiben.

@DrNiels
DrNiels marked this pull request as ready for review November 16, 2026 15:01
@DrNiels
DrNiels merged commit 6f931b0 into master Nov 16, 2026
5 checks passed
@DrNiels
DrNiels deleted the feture/LHG-PDF branch November 16, 2026 15:02
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.

3 participants