Making default cron schedule configurable
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
asdf
This commit is contained in:
parent
a9833729f7
commit
c378e46cb3
@ -5,6 +5,11 @@
|
|||||||
"schema": {
|
"schema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"title": "Switch Name",
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
"ipAddress": {
|
"ipAddress": {
|
||||||
"title": "IP Address",
|
"title": "IP Address",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -107,10 +112,10 @@
|
|||||||
"type": "number",
|
"type": "number",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"delay": {
|
"cron": {
|
||||||
"title": "Poll Delay in MS",
|
"title": "Default Cron",
|
||||||
"type": "number",
|
"type": "string",
|
||||||
"required": true
|
"required": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -33,6 +33,7 @@ export class FluxAccessory {
|
|||||||
private _hueRGB: RGB;
|
private _hueRGB: RGB;
|
||||||
private _wizRGB: RGB;
|
private _wizRGB: RGB;
|
||||||
private _fade: number;
|
private _fade: number;
|
||||||
|
private _cron: string;
|
||||||
|
|
||||||
//Service fields
|
//Service fields
|
||||||
private _switchService;
|
private _switchService;
|
||||||
@ -57,6 +58,7 @@ export class FluxAccessory {
|
|||||||
this._hueRGB = { r: 0, g: 0, b: 0 };
|
this._hueRGB = { r: 0, g: 0, b: 0 };
|
||||||
this._wizRGB = { r: 0, g: 0, b: 0 };
|
this._wizRGB = { r: 0, g: 0, b: 0 };
|
||||||
this._fade = this._config.transition ?? 30000;
|
this._fade = this._config.transition ?? 30000;
|
||||||
|
this._cron = this._config.cron ?? "*/30 * * * * *";
|
||||||
|
|
||||||
this._times = getTimes(
|
this._times = getTimes(
|
||||||
new Date(),
|
new Date(),
|
||||||
@ -272,7 +274,7 @@ export class FluxAccessory {
|
|||||||
private getHueTasks(): Array<ScheduledTask> {
|
private getHueTasks(): Array<ScheduledTask> {
|
||||||
return this._config.hueLights.map((hueLightConfig) => {
|
return this._config.hueLights.map((hueLightConfig) => {
|
||||||
let light = this._lights.find((x) => x.name == hueLightConfig.name);
|
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(
|
this._platform.log.info(
|
||||||
`Scheduling task for ${light?.name}: ${schedule}`
|
`Scheduling task for ${light?.name}: ${schedule}`
|
||||||
);
|
);
|
||||||
@ -294,7 +296,7 @@ export class FluxAccessory {
|
|||||||
let wizLightConfig = this._config.wizLights.find(
|
let wizLightConfig = this._config.wizLights.find(
|
||||||
(x) => x.ip == wizBulb.getIp()
|
(x) => x.ip == wizBulb.getIp()
|
||||||
);
|
);
|
||||||
let schedule: string = wizLightConfig?.cron ?? "*/6 * * * *";
|
let schedule: string = wizLightConfig?.cron ?? this._cron;
|
||||||
this._platform.log.info(
|
this._platform.log.info(
|
||||||
`Scheduling task for ${wizBulb.getMac()}: ${schedule}`
|
`Scheduling task for ${wizBulb.getMac()}: ${schedule}`
|
||||||
);
|
);
|
||||||
|
@ -59,7 +59,7 @@ export interface IConfig {
|
|||||||
/**
|
/**
|
||||||
* The number of milliseconds to wait btw updates
|
* The number of milliseconds to wait btw updates
|
||||||
*/
|
*/
|
||||||
delay?: number;
|
cron?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current formatted date and time to use with testing
|
* The current formatted date and time to use with testing
|
||||||
|
Loading…
Reference in New Issue
Block a user