From 8f96bae31db5d4a590a18a79306e79093c6634a9 Mon Sep 17 00:00:00 2001 From: Jasper Seinhorst Date: Sun, 3 Mar 2024 17:19:15 +0100 Subject: [PATCH] feat: pollInterval setting --- README.md | 3 ++- config.schema.json | 8 ++++++++ package-lock.json | 4 ++-- package.json | 2 +- src/Platform.ts | 3 ++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a6d24f1..7333809 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ To install the *Homebridge Homewizard Power Consumption* plugin follow these ste ``` { "platform": "HomewizardPowerConsumption", - "ip": "<>" + "ip": "<>", + "pollInterval": 60 } ``` diff --git a/config.schema.json b/config.schema.json index 7ae2b4b..022bd90 100644 --- a/config.schema.json +++ b/config.schema.json @@ -10,6 +10,14 @@ "type": "string", "required": true, "default": "" + }, + "pollInterval": { + "title": "Poll interval (in seconds)", + "type": "number", + "required": true, + "default": 60, + "minimum": 5, + "maximum": 3600 } } } diff --git a/package-lock.json b/package-lock.json index 9d0e460..d2352c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "homebridge-homewizard-power-consumption", - "version": "0.0.1", + "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "homebridge-homewizard-power-consumption", - "version": "0.0.1", + "version": "1.1.0", "license": "Apache-2.0", "dependencies": { "axios": "^1.6.7" diff --git a/package.json b/package.json index a0dc3cd..b00fb3c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "Homebridge Homewizard Power Consumption", "name": "homebridge-homewizard-power-consumption", - "version": "1.0.0", + "version": "1.1.0", "description": "See current power consumption or power return in Homekit", "license": "Apache-2.0", "author": "Jasper Seinhorst", diff --git a/src/Platform.ts b/src/Platform.ts index 05cd22c..66be38f 100644 --- a/src/Platform.ts +++ b/src/Platform.ts @@ -8,11 +8,12 @@ export class HomewizardPowerConsumption implements DynamicPlatformPlugin { public readonly Service: typeof Service = this.api.hap.Service; public readonly Characteristic: typeof Characteristic = this.api.hap.Characteristic; public readonly accessories: PlatformAccessory[] = []; - private readonly heartBeatInterval = 60 * 1000; // every minute + private heartBeatInterval: number; private devices: HomewizardPowerConsumptionAccessory[] = []; constructor(public readonly log: Logger, public readonly config: PlatformConfig, public readonly api: API) { + this.heartBeatInterval = (config.pollInterval || 60) * 1000; this.api.on('didFinishLaunching', () => { this.initialise(); });