From e4cc9da1220cbecc6a9e35c0929ffffa35745204 Mon Sep 17 00:00:00 2001 From: watsonb8 Date: Mon, 13 Apr 2020 21:16:56 -0400 Subject: [PATCH] Ignoring expected errors --- src/fluxAccessory.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/fluxAccessory.ts b/src/fluxAccessory.ts index 84d7c4e..7d4cb8d 100644 --- a/src/fluxAccessory.ts +++ b/src/fluxAccessory.ts @@ -153,13 +153,21 @@ export class FluxAccessory implements IAccessory { return x; } + private isHueError = (object: any): object is HueError => { + return '_hueError' in object; + } + private setLights = async (state: LightState) => { const promises: Array | PromiseLike> = []; this._lights.map(async (light: Light) => { try { await this._hue.lights.setLightState(light.id, state); } catch (err) { - this._log(`Error while setting lights: ${err}`); + if (this.isHueError(err) && err.message === "Error: parameter, xy, is not modifiable. Device is set to off.") { + //Eat this + } else { + this._log(`Error while setting lights: ${err}`); + } } });