From 96da9b218b2dc67a1b0666c12bd09c3f007eb88d Mon Sep 17 00:00:00 2001 From: Vincent Schoonenburg Date: Tue, 23 Mar 2021 00:41:00 +0100 Subject: [PATCH 1/2] Custom Animation cannot be stopped #224 --- huemagic/hue-magic.js | 1 + 1 file changed, 1 insertion(+) diff --git a/huemagic/hue-magic.js b/huemagic/hue-magic.js index 1933679..90b1472 100644 --- a/huemagic/hue-magic.js +++ b/huemagic/hue-magic.js @@ -206,6 +206,7 @@ module.exports = function(RED) if(scope.isAnimating == false) { var animationSteps = (typeof msg.payload.steps != 'undefined') ? msg.payload.steps : JSON.parse(scope.steps); + scope.steps = animationSteps; scope.status({fill: "green", shape: "dot", text: "hue-magic.node.animating"}); scope.isAnimating = true; From 6343243d43c61e252108545e6f767fea2b5bce78 Mon Sep 17 00:00:00 2001 From: Vincent Schoonenburg Date: Tue, 23 Mar 2021 01:18:56 +0100 Subject: [PATCH 2/2] "Unexpected end of JSON" error when stopping not running Hue Magic animation #222 --- huemagic/hue-magic.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/huemagic/hue-magic.js b/huemagic/hue-magic.js index 90b1472..0564091 100644 --- a/huemagic/hue-magic.js +++ b/huemagic/hue-magic.js @@ -187,8 +187,14 @@ module.exports = function(RED) { // Node-RED < 1.0 send = send || function() { scope.send.apply(scope,arguments); } + + if(typeof msg.payload.steps != 'undefined') { + scope.steps = msg.payload.steps; + //we animate if we receive steps from the input. + msg.payload.animate = true; + } - if(scope.steps != null||typeof msg.payload.steps != 'undefined') + if(scope.steps != null) { // SPECIALS CONFIG if(typeof msg.payload.specials != 'undefined') @@ -201,12 +207,11 @@ module.exports = function(RED) } // TURN ON ANIMATION - if(typeof msg.payload.animate == 'undefined'||msg.payload.animate == true||msg.payload === true) + if(msg.payload.animate == true||msg.payload === true) { + var animationSteps = typeof scope.steps === 'string' ? JSON.parse(scope.steps) : scope.steps; if(scope.isAnimating == false) { - var animationSteps = (typeof msg.payload.steps != 'undefined') ? msg.payload.steps : JSON.parse(scope.steps); - scope.steps = animationSteps; scope.status({fill: "green", shape: "dot", text: "hue-magic.node.animating"}); scope.isAnimating = true;