From 4b9cc771913ad34f372962c3052875656f16298a Mon Sep 17 00:00:00 2001 From: Yingyu Cheng Date: Sun, 18 Nov 2018 11:50:56 +0800 Subject: [PATCH 1/2] colorTemperatureRange is function returns promise check https://github.com/tinkerhub/abstract-things/commit/5121e614c2618748fac88d98f62489cde7198a2c#diff-83bad355d17b3dd97dec348a02af104dR37 --- lib/devices/yeelight.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/devices/yeelight.js b/lib/devices/yeelight.js index cb23ead..c9a2ec3 100644 --- a/lib/devices/yeelight.js +++ b/lib/devices/yeelight.js @@ -258,12 +258,12 @@ module.exports.ColorFull = Thing.mixin(Parent => class extends Parent if(color.is('temperature')) { // The user has request a color via temperature - const range = this.colorTemperatureRange; - const temperature = Math.min(Math.max(color.temperature.kelvins, range.min), range.max); - - return this.call('set_ct_abx', Yeelight.withEffect(temperature, options.duration), { - refresh: [ 'colorTemperature', 'colorMode' ] - }).then(MiioApi.checkOk); + this.colorTemperatureRange().then(range => { + const temperature = Math.min(Math.max(color.temperature.kelvins, range.min), range.max); + return this.call('set_ct_abx', Yeelight.withEffect(temperature, options.duration), { + refresh: [ 'colorTemperature', 'colorMode' ] + }).then(MiioApi.checkOk); + }); } else if(color.is('hsl')) { /* * User has requested hue and saturation From 783c5448fa0e77832caa2b8a2d6bd1a71c434d44 Mon Sep 17 00:00:00 2001 From: Yingyu Cheng Date: Sun, 18 Nov 2018 15:46:06 +0800 Subject: [PATCH 2/2] Update yeelight.js --- lib/devices/yeelight.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/devices/yeelight.js b/lib/devices/yeelight.js index c9a2ec3..4341fc4 100644 --- a/lib/devices/yeelight.js +++ b/lib/devices/yeelight.js @@ -170,12 +170,13 @@ module.exports.ColorTemperature = Thing.mixin(Parent => class extends Parent } changeColor(color, options) { - const range = this.colorTemperatureRange; - const temperature = Math.min(Math.max(color.temperature.kelvins, range.min), range.max); + return this.colorTemperatureRange().then(range => { + const temperature = Math.min(Math.max(color.temperature.kelvins, range.min), range.max); - return this.call('set_ct_abx', Yeelight.withEffect(temperature, options.duration), { - refresh: [ 'colorTemperature' ] - }).then(MiioApi.checkOk); + return this.call('set_ct_abx', Yeelight.withEffect(temperature, options.duration), { + refresh: [ 'colorTemperature' ] + }).then(MiioApi.checkOk); + }); } });