From c56caf3de8158d8a9b27be0086bd03a4baa12295 Mon Sep 17 00:00:00 2001 From: jangxx Date: Tue, 29 Jan 2019 22:51:58 +0100 Subject: [PATCH] fixed a bug where the effects were not updated --- HCMagicHome.js | 15 +++++++++++++-- package.json | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/HCMagicHome.js b/HCMagicHome.js index 955a0c4..38fd596 100644 --- a/HCMagicHome.js +++ b/HCMagicHome.js @@ -184,8 +184,19 @@ class HCMagicHome extends HCColorLamp { //console.log(status); futureState.on = status.on; - futureState.brightness = extractBrightness(status.color); - futureState.color = RGB_to_HSL(removeBrightness(status.color)); + + let effect = (status.mode != 'color' && status.mode != 'warm_white' && status.mode != 'special') ? status.mode : 'none'; + if(effect != 'none') { + let speed = (status.speed > 80) ? 'fast' : (status.speed > 30) ? 'medium' : 'slow'; + futureState.effect = speed + '-' + effect; + } else { + futureState.effect = 'none'; + } + + if (futureState.effect == 'none') { // only update color when no effects are playing + futureState.brightness = extractBrightness(status.color); + futureState.color = RGB_to_HSL(removeBrightness(status.color)); + } if (currentState.hash != futureState.hash) { // the state of the controller has changed externally diff --git a/package.json b/package.json index f2764ed..19c28c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hc-magichome", - "version": "1.0.0", + "version": "1.0.1", "description": "Magic Home Plugin for Homecontrol", "main": "HCMagicHome.js", "scripts": {