From 317aaa1b64cb8e2117919c77b41a722d8cc60202 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Thu, 20 Nov 2014 08:44:05 +0000 Subject: [PATCH] Handle users of old Blinkstick npm a bit more nicely. Don't barf (quite so badly) on new API calls if they don't exist yet. --- hardware/blinkstick/76-blinkstick.html | 6 ++---- hardware/blinkstick/76-blinkstick.js | 12 ++++++++++-- hardware/blinkstick/package.json | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/hardware/blinkstick/76-blinkstick.html b/hardware/blinkstick/76-blinkstick.html index de84b05d..959bfb75 100644 --- a/hardware/blinkstick/76-blinkstick.html +++ b/hardware/blinkstick/76-blinkstick.html @@ -60,9 +60,7 @@ -
Expects a msg.payload with either hex "#rrggbb" or decimal "red,green,blue" string.
- - +
Expects a msg.payload with either hex "#rrggbb" or decimal "red,green,blue" string, or HTML color name.
diff --git a/hardware/blinkstick/76-blinkstick.js b/hardware/blinkstick/76-blinkstick.js index f5f6202b..54c1485e 100644 --- a/hardware/blinkstick/76-blinkstick.js +++ b/hardware/blinkstick/76-blinkstick.js @@ -165,7 +165,14 @@ module.exports = function(RED) { node.led.setColor(node.color, blinkstickAnimationComplete); } } catch (err) { - node.warn("BlinkStick missing ? " + err); + if (err.toString().indexOf("setColor") !== -1) { + node.led.setColour(node.color, blinkstickAnimationComplete); + node.warn("Old version - please upgrade Blinkstick npm"); + } + else { + node.warn("BlinkStick missing ? " + err); + } + console.log(err); //Reset animation animationComplete = true; //Clear color @@ -233,7 +240,8 @@ module.exports = function(RED) { if (Object.size(node.led) !== 0) { //Close device and stop animations - this.led.close(); + if (typeof this.led.close === "function") { this.led.close(); } + else { node.warn("Please upgrade blinkstick npm"); } } }); } diff --git a/hardware/blinkstick/package.json b/hardware/blinkstick/package.json index 11f08f66..7bc2b1ad 100644 --- a/hardware/blinkstick/package.json +++ b/hardware/blinkstick/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-blinkstick", - "version" : "0.1.0", + "version" : "0.1.1", "description" : "A Node-RED node to control a Blinkstick", "dependencies" : { "blinkstick" : "1.1.*"