diff --git a/lib/devices/yeelight.js b/lib/devices/yeelight.js index cb23ead..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); + }); } }); @@ -258,12 +259,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