Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setTimeout(async () => {
if (debounceColorMode) {
clearTimeout(debounceColorMode);
debounceColorMode = false;
return this.setCapabilityValue('light_mode', value);
}
if (value === 'color') {
const hue = this.getCapabilityValue('light_hue') || 1;
const saturation = this.getCapabilityValue('light_saturation') || 1;
const _value = 1; // brightness value is not determined in SWITCH_COLOR but with SWITCH_MULTILEVEL, changing this throws the dim value vs real life brightness out of sync
const rgb = Utils.convertHSVToRGB({ hue, saturation, _value });
return await this._sendColors({
warm: 0,
cold: 0,
red: rgb.red,
green: rgb.green,
blue: rgb.blue,
duration: options.duration || null,
});
} else if (value === 'temperature') {
const temperature = this.getCapabilityValue('light_temperature') || 1;
const warm = temperature * 255;
const cold = (1 - temperature) * 255;
return await this._sendColors({