Skip to content

[pihole] Discrepencies between dashboard and channels#20394

Open
clinique wants to merge 3 commits intoopenhab:mainfrom
clinique:pihole_20381
Open

[pihole] Discrepencies between dashboard and channels#20394
clinique wants to merge 3 commits intoopenhab:mainfrom
clinique:pihole_20381

Conversation

@clinique
Copy link
Contributor

@clinique clinique commented Mar 17, 2026

Solves #20381

  • Discrepency on ads_percentage_today : dashboard displays it on the past 24h, while binding worked 'since midnight'. Corrected.
  • unique_clients was not provided by the binding.
  • Fixes actions failing from UI
  • Reintroduce missing channels gravity-last-update and gravity-file-exists

Signed-off-by: gael@lhopital.org <gael@lhopital.org>
@clinique clinique self-assigned this Mar 17, 2026
@clinique clinique requested a review from magx2 as a code owner March 17, 2026 11:20
@clinique clinique added the bug An unexpected problem or unintended behavior of an add-on label Mar 17, 2026
Signed-off-by: gael@lhopital.org <gael@lhopital.org>
@magx2
Copy link
Contributor

magx2 commented Mar 17, 2026

I'm ooo. Will take a look next week

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns the Pi-hole v6 binding’s ads_percentage_today and unique_clients channels with what the Pi-hole dashboard reports by switching the stats window to the last 24 hours and by populating unique_clients from the v6 stats response.

Changes:

  • Change the v6 database summary query window from “since midnight” to “last 24 hours” to match dashboard semantics for ads_percentage_today.
  • Populate unique_clients in the translated DnsStatistics using v6 clients.active.
  • Adjust the v6 stats model naming/visibility to expose the clients record component.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
bundles/org.openhab.binding.pihole/src/main/java/org/openhab/binding/pihole/internal/rest/model/v6/StatAnswer.java Renames/exposes the clients component so the v6 stats payload can be consumed for unique client count.
bundles/org.openhab.binding.pihole/src/main/java/org/openhab/binding/pihole/internal/rest/JettyAdminServiceV6.java Updates the stats aggregation window to last-24h and maps v6 client activity into uniqueClients.
Comments suppressed due to low confidence (1)

bundles/org.openhab.binding.pihole/src/main/java/org/openhab/binding/pihole/internal/rest/JettyAdminServiceV6.java:132

  • summary() captures Instant now = Instant.now() but later uses a second Instant.now() when computing duration. Reuse the already-captured now for consistency (and to avoid tiny time-drift issues in calculations/tests).
        Instant now = Instant.now();
        String oneDayAgo = Long.toString(now.minus(24, ChronoUnit.HOURS).getEpochSecond());
        String toNow = Long.toString(now.getEpochSecond());

        StatDatabaseSummary statDatabase = get(databaseSummaryURI, StatDatabaseSummary.class, "from", oneDayAgo,
                "until", toNow);

        HistoryClients historyClients = get(historyClientsURI, HistoryClients.class, "N", "0");
        ConfigAnswer configAnswer = get(configURI, ConfigAnswer.class);
        Duration duration = Duration.between(gravity.instant(), Instant.now());
        Relative relative = new Relative((int) duration.toDaysPart(), duration.toHoursPart(), duration.toMinutesPart());

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Reintroduce missing channels

Signed-off-by: clinique <gael@lhopital.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An unexpected problem or unintended behavior of an add-on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants