1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Catch blink1 missing device error

This commit is contained in:
dceejay 2015-02-24 17:29:51 +00:00
parent f550024bb2
commit a5adbc2207
2 changed files with 38 additions and 36 deletions

View File

@ -30,6 +30,7 @@ module.exports = function(RED) {
var p1 = /^\#[A-Fa-f0-9]{6}$/ var p1 = /^\#[A-Fa-f0-9]{6}$/
var p2 = /[0-9]+,[0-9]+,[0-9]+/ var p2 = /[0-9]+,[0-9]+,[0-9]+/
this.on("input", function(msg) { this.on("input", function(msg) {
try {
blink1 = blink1 || new Blink1.Blink1(); blink1 = blink1 || new Blink1.Blink1();
if (blink1) { if (blink1) {
var r,g,b; var r,g,b;
@ -70,6 +71,7 @@ module.exports = function(RED) {
else { else {
node.warn("Blink1 : not found"); node.warn("Blink1 : not found");
} }
} catch (e) { node.warn("Blink1 : device not found"); blink1 = null; }
}); });
this.on("close", function() { this.on("close", function() {
if (blink1 && typeof blink1.close == "function") { if (blink1 && typeof blink1.close == "function") {

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-blink1", "name" : "node-red-node-blink1",
"version" : "0.0.2", "version" : "0.0.3",
"description" : "A Node-RED node to control a Thingm Blink(1)", "description" : "A Node-RED node to control a Thingm Blink(1)",
"dependencies" : { "dependencies" : {
"node-blink1" : "0.1.2" "node-blink1" : "0.1.2"