Reset sunset times every time enabled

This commit is contained in:
watsonb8
2020-04-11 16:44:55 -04:00
parent 106a1280dd
commit 6625ce952a
2 changed files with 22 additions and 2 deletions

View File

@ -31,7 +31,6 @@ export class FluxAccessory implements IAccessory {
private _switchService: HAPNodeJS.Service;
private _infoService: HAPNodeJS.Service;
private _isEnabled: boolean;
private _hue: Api;
private _lights: Array<Light> = [];
@ -51,7 +50,6 @@ export class FluxAccessory implements IAccessory {
this._scheduler = new Scheduler(this._config.delay ? this._config.delay : 60000, 60000, this._log);
this._scheduler.addTask({ delegate: this.updateDelegate, title: "Update" })
this._isEnabled = false;
this._hue = props.hue;
this.name = this._config.name;
@ -88,6 +86,7 @@ export class FluxAccessory implements IAccessory {
*/
private onSetEnabled = async (activeState: boolean, callback: (error?: Error | null | undefined) => void) => {
if (activeState) {
this._times = getTimes(new Date(), this._config.latitude, this._config.longitude);
this._scheduler.start();
} else {
this._scheduler.stop();