Only updating wiz bulb if pilot is not undefined
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Brandon Watson 2022-09-20 21:32:35 -05:00
parent e35a206a59
commit b1a80b17ec

View File

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