Making default cron schedule configurable
All checks were successful
continuous-integration/drone/push Build is passing

asdf
This commit is contained in:
Brandon Watson 2022-09-07 21:55:39 -05:00
parent a9833729f7
commit c378e46cb3
3 changed files with 14 additions and 7 deletions

View File

@ -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
}
}
},

View File

@ -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<ScheduledTask> {
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}`
);

View File

@ -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