From 28ad80369ff4733d448cdf8bcb08010f3979b0f8 Mon Sep 17 00:00:00 2001 From: Molham Date: Sat, 19 Apr 2025 14:19:28 +0200 Subject: [PATCH] add support to dynamic interval time for polling the status --- docs/customservices.md | 3 ++- src/components/services/PiHole.vue | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/customservices.md b/docs/customservices.md index fc6d318..ac77ba3 100644 --- a/docs/customservices.md +++ b/docs/customservices.md @@ -468,10 +468,11 @@ The following configuration is available for the PiHole service. - name: "Pi-hole" logo: "assets/tools/sample.png" # subtitle: "Network-wide Ad Blocking" # optional, if no subtitle is defined, PiHole statistics will be shown - url: "http://192.168.0.151/admin" + url: "http://192.168.0.151/admin" # For v6 API, do not include /admin in the URL apikey: "<---insert-api-key-here--->" # optional, needed if web interface is password protected type: "PiHole" apiVersion: 5 # optional, defaults to 5. Use 6 if your PiHole instance uses API v6 + checkInterval: 3000 # optional, defaults to 300000. interval in ms to check Pi-hole status ``` **Remarks:** diff --git a/src/components/services/PiHole.vue b/src/components/services/PiHole.vue index 004f382..9a20d42 100644 --- a/src/components/services/PiHole.vue +++ b/src/components/services/PiHole.vue @@ -68,8 +68,12 @@ export default { methods: { startStatusPolling: function () { this.fetchStatus(); - // Poll every 5 minutes - this.pollInterval = setInterval(this.fetchStatus, 300000); + // Set the interval to the checkInterval or default to 5 minutes + const interval = parseInt(this.item.checkInterval, 10) || 300000; + if (this.item.checkInterval < 1000) { + this.item.checkInterval = 1000; + } + this.pollInterval = setInterval(this.fetchStatus, interval); }, stopStatusPolling: function () { if (this.pollInterval) {