From 2e5764dbdc48e47f6dfb72aadb4d3163efbe2f4c Mon Sep 17 00:00:00 2001 From: JuniorGenius Date: Fri, 2 Apr 2021 02:50:47 -0700 Subject: [PATCH] Added white color to light accessory --- accessories/light.js | 10 +++++++++- config-sample.json | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/accessories/light.js b/accessories/light.js index 43096c18..15681448 100644 --- a/accessories/light.js +++ b/accessories/light.js @@ -84,9 +84,17 @@ class LightAccessory extends SwitchAccessory { // Find hue closest to the one requested const foundValues = this.dataKeys('hue'); const closest = foundValues.reduce((prev, curr) => Math.abs(curr - state.hue) < Math.abs(prev - state.hue) ? curr : prev); - const hexData = data[`hue${closest}`]; + var hexData = ""; + + if (state.saturation < 10) { + hexData = data[`white`]; + log(`${name} setHue: (closest: white)`); + } else { + hexData = data[`hue${closest}`]; log(`${name} setHue: (closest: hue${closest})`); + } + await this.performSend(hexData); }); } diff --git a/config-sample.json b/config-sample.json index c3eb78a7..cfbdcf4d 100644 --- a/config-sample.json +++ b/config-sample.json @@ -165,7 +165,8 @@ "hue99": "2600500000012...", "hue199": "2600500000012...", "hue299": "2600500000012...", - "hue359": "2600500000012..." + "hue359": "2600500000012...", + "white": "2600500000012..." } }, {