diff --git a/config.schema.json b/config.schema.json index 4ff5046..17a0ffb 100644 --- a/config.schema.json +++ b/config.schema.json @@ -5,6 +5,11 @@ "schema": { "type": "object", "properties": { + "name": { + "title": "Switch Name", + "type": "string", + "required": true + }, "ipAddress": { "title": "IP Address", "type": "string", @@ -107,10 +112,10 @@ "type": "number", "required": true }, - "delay": { - "title": "Poll Delay in MS", - "type": "number", - "required": true + "cron": { + "title": "Default Cron", + "type": "string", + "required": false } } }, diff --git a/src/fluxAccessory.ts b/src/fluxAccessory.ts index ab5758a..bcc4c8c 100644 --- a/src/fluxAccessory.ts +++ b/src/fluxAccessory.ts @@ -33,6 +33,7 @@ export class FluxAccessory { private _hueRGB: RGB; private _wizRGB: RGB; private _fade: number; + private _cron: string; //Service fields private _switchService; @@ -57,6 +58,7 @@ export class FluxAccessory { this._hueRGB = { r: 0, g: 0, b: 0 }; this._wizRGB = { r: 0, g: 0, b: 0 }; this._fade = this._config.transition ?? 30000; + this._cron = this._config.cron ?? "*/30 * * * * *"; this._times = getTimes( new Date(), @@ -272,7 +274,7 @@ export class FluxAccessory { private getHueTasks(): Array { return this._config.hueLights.map((hueLightConfig) => { let light = this._lights.find((x) => x.name == hueLightConfig.name); - let schedule: string = hueLightConfig.cron ?? "*/6 * * * *"; + let schedule: string = hueLightConfig.cron ?? this._cron; this._platform.log.info( `Scheduling task for ${light?.name}: ${schedule}` ); @@ -294,7 +296,7 @@ export class FluxAccessory { let wizLightConfig = this._config.wizLights.find( (x) => x.ip == wizBulb.getIp() ); - let schedule: string = wizLightConfig?.cron ?? "*/6 * * * *"; + let schedule: string = wizLightConfig?.cron ?? this._cron; this._platform.log.info( `Scheduling task for ${wizBulb.getMac()}: ${schedule}` ); diff --git a/src/models/iConfig.ts b/src/models/iConfig.ts index f7116f8..702adcb 100644 --- a/src/models/iConfig.ts +++ b/src/models/iConfig.ts @@ -59,7 +59,7 @@ export interface IConfig { /** * The number of milliseconds to wait btw updates */ - delay?: number; + cron?: string; /** * The current formatted date and time to use with testing