From b1a80b17ec02686bc2d17c47462c40c6720d24d9 Mon Sep 17 00:00:00 2001 From: Brandon Watson Date: Tue, 20 Sep 2022 21:32:35 -0500 Subject: [PATCH] Only updating wiz bulb if pilot is not undefined --- src/fluxAccessory.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/fluxAccessory.ts b/src/fluxAccessory.ts index 0183e47..21ca05f 100644 --- a/src/fluxAccessory.ts +++ b/src/fluxAccessory.ts @@ -130,6 +130,8 @@ export class FluxAccessory { .on("set", this.onSetEnabled) //@ts-ignore .on("get", this.onGetEnabled); + + this.test(); } public name: string = "Flux"; @@ -320,6 +322,9 @@ export class FluxAccessory { } catch (err: any) { this._platform.log.error(err.message); } + if (!pilot) { + return; + } this._platform.log.info(`Adjusting wiz bulb: ${wizBulb.getMac()}`); wizBulb.set(this._wizRGB, pilot?.state ? pilot.dimming : 0, this._fade); }; @@ -359,4 +364,23 @@ export class FluxAccessory { private disable() { this._tasks.forEach((task) => task.stop()); } + + private test = async () => { + for (let i = 2500; i > 0; i--) { + this._platform.log.info(`i: ${i}`); + for (const wizBulb of this._wizLights) { + let pilot; + try { + pilot = await wizBulb.get(); + } catch (err: any) { + this._platform.log.error(err.message); + } + this._platform.log.info( + `Adjusting wiz bulb: ${wizBulb.getMac()}` + ); + wizBulb.set(colorTemperature2rgb(i), 100, this._fade); + } + await Sleep(100); + } + }; }