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

Re-lint a load of nodes

This commit is contained in:
Dave Conway-Jones 2017-01-29 17:45:44 +00:00
parent 603189f123
commit 316a2fd272
42 changed files with 447 additions and 254 deletions

View File

@ -6,11 +6,13 @@
"disallowMixedSpacesAndTabs": true,
"disallowMultipleSpaces": {"allowEOLComments": true},
"disallowKeywordsOnNewLine": [],
"requireKeywordsOnNewLine": ["else", "catch"],
"requireSpaceBeforeBlockStatements": 1,
//"requireSpaceBeforeObjectValues": false,
//"requireSemicolons": true,
//"validateParameterSeparator": ", ",
//"validateQuoteMarks": false,
"requireSpaceAfterKeywords": ["do","for","if","else","switch","case","try","while"],
"maximumLineLength": 255
"maximumLineLength": 255,
"disallowTabs": true
}

View File

@ -20,14 +20,17 @@ module.exports = function(RED) {
}
if (node.fieldType === 'msg') {
RED.util.setMessageProperty(msg,node.field,value);
} else if (node.fieldType === 'flow') {
}
else if (node.fieldType === 'flow') {
node.context().flow.set(node.field,value);
} else if (node.fieldType === 'global') {
}
else if (node.fieldType === 'global') {
node.context().global.set(node.field,value);
}
node.send(msg);
} catch(err) {
node.error(err.message);
}
catch(e) {
node.error(e.message);
}
});
}

View File

@ -10,7 +10,8 @@ module.exports = function(RED) {
this.on("input", function(msg) {
if (node.inte == "true" || node.inte === true) {
msg.payload = Math.round(Number(Math.random()) * (node.high - node.low + 1) + node.low - 0.5);
} else {
}
else {
msg.payload = Number(Math.random()) * (node.high - node.low) + node.low;
}
node.send(msg);

View File

@ -42,7 +42,7 @@ module.exports = function(RED) {
tot = tot + n - pop;
tot2 = tot2 + (n*n) - (pop * pop);
if (a.length > 1) {
msg.payload = Math.sqrt((a.length * tot2 - tot * tot)/(a.length * (a.length - 1)));
msg.payload = Math.sqrt((a.length * tot2 - tot * tot)/(a.length * (a.length - 1)));
}
else { msg.payload = 0; }
}

View File

@ -14,9 +14,11 @@ module.exports = function (RED) {
adjustName = function (pin) {
if (pin === "P8_7") {
pin = "P8_07";
} else if (pin === "P8_8") {
}
else if (pin === "P8_8") {
pin = "P8_08";
} else if (pin === "P8_9") {
}
else if (pin === "P8_9") {
pin = "P8_09";
}
return pin;
@ -38,7 +40,8 @@ module.exports = function (RED) {
this.averaging = n.averaging;
if (this.averaging) {
this.averages = 10;
} else {
}
else {
this.averages = 1;
}
@ -54,7 +57,8 @@ module.exports = function (RED) {
count = count - 1;
if (count > 0) {
bonescript.analogRead(node._pin, analogReadCallback);
} else {
}
else {
var msg = {};
msg.topic = node.topic;
sum = sum/node.averages;
@ -76,7 +80,8 @@ module.exports = function (RED) {
count = node.averages;
bonescript.analogRead(node._pin, analogReadCallback);
});
} else {
}
else {
node.error("Unconfigured input pin");
}
}
@ -92,18 +97,22 @@ module.exports = function (RED) {
this._pin = adjustName(this.pin); // Adjusted for Octal if necessary
if (n.activeLow) { // Set the 'active' state 0 or 1 as appropriate
this.activeState = 0;
} else {
}
else {
this.activeState = 1;
}
this.updateInterval = n.updateInterval*1000; // How often to send totalActiveTime messages
this.debounce = n.debounce || null; // Enable switch contact debouncing algorithm
if (n.outputOn === "rising") {
this.activeEdges = [false, true];
} else if (n.outputOn === "falling") {
}
else if (n.outputOn === "falling") {
this.activeEdges = [true, false];
} else if (n.outputOn === "both") {
}
else if (n.outputOn === "both") {
this.activeEdges = [true, true];
} else {
}
else {
node.error("Invalid edge type: " + n.outputOn);
}
@ -130,10 +139,12 @@ module.exports = function (RED) {
node.interruptAttached = true;
node.on("input", inputCallback);
node.intervalId = setInterval(timerCallback, node.updateInterval);
} else {
}
else {
node.error("Failed to attach interrupt");
}
} else if (node.currentState !== Number(x)) {
}
else if (node.currentState !== Number(x)) {
if (node.debounce) {
if (node.debouncing === false) {
node.debouncing = true;
@ -141,7 +152,8 @@ module.exports = function (RED) {
bonescript.digitalRead(node._pin, debounceCallback);
}, Number(node.debounce));
}
} else {
}
else {
sendStateMessage(x);
}
}
@ -166,7 +178,8 @@ module.exports = function (RED) {
var now = Date.now();
if (node.currentState === node.activeState) {
node.lastActiveTime = now;
} else if (!isNaN(node.lastActiveTime)) {
}
else if (!isNaN(node.lastActiveTime)) {
node.totalActiveTime += now - node.lastActiveTime;
}
if (node.activeEdges[node.currentState]) {
@ -203,7 +216,8 @@ module.exports = function (RED) {
var inputCallback = function (ipMsg) {
if (String(ipMsg.topic).search(/load/i) < 0 || isFinite(ipMsg.payload) === false) {
node.totalActiveTime = 0;
} else {
}
else {
node.totalActiveTime = Number(ipMsg.payload);
}
if (node.currentState === node.activeState) {
@ -217,7 +231,8 @@ module.exports = function (RED) {
if (node.activeEdges[0] && node.activeEdges[1]) {
msg = [{topic: node.topic}, {topic: node.topic}];
msg[0].payload = node.currentState;
} else {
}
else {
msg = [null, {topic: node.topic}];
}
msg[1].payload = node.totalActiveTime;
@ -246,12 +261,14 @@ module.exports = function (RED) {
node.emit("input", {});
}, 50);
});
} else {
}
else {
node.error("Unable to set " + pin + " as input: " + response);
}
});
});
} else {
}
else {
node.error("Unconfigured input pin");
}
}
@ -286,10 +303,12 @@ module.exports = function (RED) {
node.interruptAttached = true;
node.on("input", inputCallback);
node.intervalId = setInterval(timerCallback, node.updateInterval);
} else {
}
else {
node.error("Failed to attach interrupt");
}
} else {
}
else {
node.pulseTime = [node.pulseTime[1], process.hrtime()];
node.pulseCount = node.pulseCount + 1;
}
@ -301,7 +320,8 @@ module.exports = function (RED) {
var inputCallback = function (msg) {
if (String(msg.topic).search(/load/i) < 0 || isFinite(msg.payload) === false) {
node.pulseCount = 0;
} else {
}
else {
node.pulseCount = Number(msg.payload);
}
};
@ -337,19 +357,22 @@ module.exports = function (RED) {
if (node.countType === "pulse") {
// interruptType = bonescript.FALLING; <- doesn't work in v0.2.4
interruptType = bonescript.RISING;
} else {
}
else {
interruptType = bonescript.CHANGE;
}
// Attempt to attach the required interrupt handler to the pin. If we succeed,
// the input event and interval handlers will be installed by interruptCallback
bonescript.attachInterrupt(node._pin, interruptType, interruptCallback)
});
} else {
}
else {
node.error("Unable to set " + pin + " as input: " + response);
}
});
});
} else {
}
else {
node.error("Unconfigured input pin");
}
}
@ -376,12 +399,15 @@ module.exports = function (RED) {
var newState;
if (node.toggle) {
newState = node.currentState === 0 ? 1 : 0;
} else {
}
else {
if (isFinite(Number(msg.payload))) {
newState = Number(msg.payload) > 0.5;
} else if (msg.payload) {
}
else if (msg.payload) {
newState = true;
} else {
}
else {
newState = false;
}
if (node.inverting) {
@ -402,7 +428,8 @@ module.exports = function (RED) {
setPinMode(node._pin, bonescript.OUTPUT, function (response, pin) {
if (response) {
node.error("Unable to set " + pin + " as output: " + response.err);
} else {
}
else {
node.on("input", inputCallback);
setTimeout(function () {
bonescript.digitalWrite(node._pin, node.defaultState, function() {});
@ -410,7 +437,8 @@ module.exports = function (RED) {
}
});
});
} else {
}
else {
node.error("Unconfigured output pin");
}
}
@ -453,10 +481,12 @@ module.exports = function (RED) {
node.send({topic: node.topic, payload: node.pulseState});
});
}
} else {
}
else {
if (node.pulseTimer !== null) {
clearTimeout(node.pulseTimer);
} else {
}
else {
bonescript.digitalWrite(node._pin, node.pulseState, function() {
node.send({topic: node.topic, payload: node.pulseState});
});
@ -484,12 +514,14 @@ module.exports = function (RED) {
node.on("input", inputCallback);
// Set the pin to the default state once the dust settles
setTimeout(endPulseCallback, 50);
} else {
}
else {
node.error("Unable to set " + pin + " as output: " + response.err);
}
});
});
} else {
}
else {
node.error("Unconfigured output pin");
}
}

View File

@ -1,9 +1,9 @@
{
"name" : "node-red-node-beaglebone",
"version" : "0.1.8",
"version" : "0.1.9",
"description" : "A set of Node-RED nodes to interface to the GPIO pins of a Beaglebone Black board",
"dependencies" : {
"octalbonescript":"^1.2.*"
"octalbonescript":"^1.2.2"
},
"repository" : {
"type":"git",

View File

@ -12,7 +12,8 @@ module.exports = function(RED) {
try {
var cpuinfo = fs.readFileSync("/proc/cpuinfo").toString();
if (cpuinfo.indexOf(": BCM") === -1) { throw "Info : "+RED._("rpi-gpio.errors.ignorenode"); }
} catch(err) {
}
catch(err) {
throw "Info : "+RED._("rpi-gpio.errors.ignorenode");
}

View File

@ -164,10 +164,12 @@ module.exports = function(RED) {
if (node.pin !== undefined) {
if (node.pin === "12") {
node.child = spawn(gpioCommand, ["buzz",node.pin]);
} else {
}
else {
if (node.set && (node.out === "out")) {
node.child = spawn(gpioCommand, [node.out,node.pin,node.level]);
} else {
}
else {
node.child = spawn(gpioCommand, [node.out,node.pin]);
}
}

View File

@ -32,7 +32,7 @@ module.exports = function(RED) {
return typeof (value) === "undefined" || value === null ? value = defaultValue : value;
}
function validateArray(value, defaultValue){
function validateArray(value, defaultValue) {
return typeof (value) === "undefined" || Array.isArray(value) ? value : defaultValue;
}
@ -66,7 +66,7 @@ module.exports = function(RED) {
this.name = n.name;
this.serial = n.serial;
this.mode = n.mode || "normal";
this.mode = n.mode || "normal";
this.task = n.task || "set_color";
this.delay = n.delay || 500;
this.repeats = n.repeats || 1;
@ -95,25 +95,28 @@ module.exports = function(RED) {
if (Object.size(node.led) === 0) {
node.status({fill:"red",shape:"ring",text:"not found"});
node.error("BlinkStick with serial number " + node.serial + " not found");
} else {
}
else {
node.status({fill:"green",shape:"dot",text:"connected"});
if(node.mode == "normal"){node.led.setMode(0);}
else if(node.mode == "inverted"){node.led.setMode(1);}
else if(node.mode == "neopixel"){node.led.setMode(2);}
if (node.mode == "normal") {node.led.setMode(0);}
else if (node.mode == "inverted") {node.led.setMode(1);}
else if (node.mode == "neopixel") {node.led.setMode(2);}
if (callback) { callback(); }
}
});
} else {
}
else {
node.led = blinkstick.findFirst();
if (Object.size(node.led) === 0) {
node.status({fill:"red",shape:"ring",text:"not found"});
node.error("No BlinkStick found");
} else {
}
else {
node.status({fill:"green",shape:"dot",text:"connected"});
if(node.mode == "normal"){node.led.setMode(0);}
else if(node.mode == "inverted"){node.led.setMode(1);}
else if(node.mode == "neopixel"){node.led.setMode(2);}
if (node.mode == "normal") {node.led.setMode(0);}
else if (node.mode == "inverted") {node.led.setMode(1);}
else if (node.mode == "neopixel") {node.led.setMode(2);}
if (callback) { callback(); }
}
}
@ -159,12 +162,15 @@ module.exports = function(RED) {
//Select animation to perform
if (node.task == "pulse") {
node.led.pulse(node.color, {'duration': node.duration, 'steps': node.steps, 'channel': node.channel, 'index': node.index }, blinkstickAnimationComplete);
} else if (node.task == "morph") {
}
else if (node.task == "morph") {
node.led.morph(node.color, {'duration': node.duration, 'steps': node.steps, 'channel': node.channel, 'index': node.index }, blinkstickAnimationComplete);
} else if (node.task == "blink") {
}
else if (node.task == "blink") {
node.led.blink(node.color,{'repeats': node.repeats, 'delay': node.delay, 'channel': node.channel, 'index': node.index }, blinkstickAnimationComplete);
} else {
if(node.row.length > 0){
}
else {
if (node.row.length > 0) {
var dat = [];
for (var i = 0; i < node.row.length; i++) {
if (typeof node.row[i] === "string") { // if string then assume must be colour names
@ -187,14 +193,15 @@ module.exports = function(RED) {
node.led.setColors(node.channel, dat, blinkstickAnimationComplete);
}
else {
node.warn("Colour array length not / 3");
node.warn("Colour array length not / 3");
}
}
else {
node.led.setColor(node.color, {'channel': node.channel, 'index': node.index}, blinkstickAnimationComplete);
}
}
} catch (err) {
}
catch (err) {
if (err.toString().indexOf("setColor") !== -1) {
node.led.setColour(node.color, blinkstickAnimationComplete);
node.warn("Old version - please upgrade Blinkstick npm");
@ -269,19 +276,22 @@ module.exports = function(RED) {
node.channel = typeof(data.channel) !== 'undefined' ? data.channel : node.channel;
node.index = data.index ? data.index : node.index;
node.row = data.row ? data.row : node.row;
} else {
}
else {
node.error(data);
return;
}
}
} else if (p1.test(msg.payload)) {
}
else if (p1.test(msg.payload)) {
//Color value is represented as "red,green,blue" string of bytes
var rgb = msg.payload.split(",");
//Convert color value back to HEX string for easier implementation
node.color = "#" + decimalToHex(parseInt(rgb[0])&255) +
decimalToHex(parseInt(rgb[1])&255) + decimalToHex(parseInt(rgb[2])&255);
} else {
}
else {
//Sanitize color value
node.color = msg.payload.toLowerCase().replace(/\s+/g,'');
if (node.color === "amber") { node.color = "#FFBF00"; }
@ -293,7 +303,8 @@ module.exports = function(RED) {
if (animationComplete) {
applyColor();
}
} else {
}
else {
//Attempt to find BlinkStick and start animation if it's found
findBlinkStick(function() {
if (animationComplete) {

View File

@ -16,7 +16,8 @@ module.exports = function(RED) {
try {
device = new HID.HID(devices[i].path);
break;
} catch (e) {
}
catch (e) {
node.log(e)
}
}
@ -32,16 +33,19 @@ module.exports = function(RED) {
var g = parseInt(msg.payload.slice(3,5),16);
var b = parseInt(msg.payload.slice(5),16);
device.sendFeatureReport([115,r,g,b]);
} else if (p2.test(msg.payload)) {
}
else if (p2.test(msg.payload)) {
var args = msg.payload.split(',');
if (args.length == 3) {
device.sendFeatureReport([115,parseInt(args[0]),parseInt(args[1]),parseInt(args[2])]);
}
} else {
}
else {
node.warn("incompatable input - " + msg.payload);
}
});
} else {
}
else {
node.warn("no digispark RGB found");
}

View File

@ -16,31 +16,37 @@ module.exports = function(RED) {
var g = node.x.read();
var msg = { payload:g, topic:node.board+"/D"+node.pin };
switch (g) {
case 0:
case 0: {
node.status({fill:"green",shape:"ring",text:"low"});
if (node.interrupt=== "f" || node.interrupt === "b") {
node.send(msg);
}
break;
case 1:
}
case 1: {
node.status({fill:"green",shape:"dot",text:"high"});
if (node.interrupt=== "r" || node.interrupt === "b") {
node.send(msg);
}
break;
default:
}
default: {
node.status({fill:"grey",shape:"ring",text:"unknown"});
}
}
});
switch (node.x.read()) {
case 0:
case 0: {
node.status({fill:"green",shape:"ring",text:"low"});
break;
case 1:
}
case 1: {
node.status({fill:"green",shape:"dot",text:"high"});
break;
default:
}
default: {
node.status({});
}
}
this.on('close', function() {
node.x.isr(m.EDGE_BOTH, null);

View File

@ -10,7 +10,8 @@ module.exports = function(RED) {
var node = this;
if (node.pin === 14) {
node.p = new m.Gpio(3,false,true); // special for onboard LED v1
} else {
}
else {
node.p = new m.Gpio(node.pin);
}
node.p.mode(m.PIN_GPIO);
@ -21,7 +22,8 @@ module.exports = function(RED) {
node.on("input", function(msg) {
if (msg.payload == "1") {
node.p.write(1);
} else {
}
else {
node.p.write(0);
}
});

View File

@ -56,7 +56,8 @@ module.exports = function(RED) {
}
else { console.log(key); }
});
} catch(err) { node.warn("can't open MakeyMakey: Do you need root access ?"); }
}
catch(err) { node.warn("can't open MakeyMakey: Do you need root access ?"); }
}
else {
findmakey();

View File

@ -6,7 +6,8 @@ module.exports = function(RED) {
try {
var cpuinfo = fs.readFileSync("/proc/cpuinfo").toString();
if (cpuinfo.indexOf(": BCM") === -1) { throw "Info : "+RED._("rpi-gpio.errors.ignorenode"); }
} catch(err) {
}
catch(err) {
throw "Info : "+RED._("rpi-gpio.errors.ignorenode");
}

View File

@ -10,7 +10,8 @@ module.exports = function(RED) {
try {
var cpuinfo = fs.readFileSync("/proc/cpuinfo").toString();
if (cpuinfo.indexOf(": BCM") === -1) { throw "Info : "+RED._("rpi-gpio.errors.ignorenode"); }
} catch(err) {
}
catch(err) {
throw "Info : "+RED._("rpi-gpio.errors.ignorenode");
}
@ -57,7 +58,8 @@ module.exports = function(RED) {
if (node.mode.indexOf("need") >= 0) {
needle = colors.getRGB(parts[0],node.rgb);
pay = "0,"+(l-1)+","+node.fgnd+"\n"+l+","+needle+"\n"+(l+1)+","+(node.pixels-1)+","+node.bgnd;
} else {
}
else {
node.fgnd = colors.getRGB(parts[0],node.rgb);
pay = "0,"+l+","+node.fgnd+"\n"+(l+1)+","+(node.pixels-1)+","+node.bgnd;
}
@ -78,7 +80,8 @@ module.exports = function(RED) {
ll = ll - 1;
if (node.mode.indexOf("need") >= 0) {
pay = "0,"+(ll-1)+","+node.fgnd+"\n"+ll+","+needle+"\n"+(ll+1)+","+(node.pixels-1)+","+node.bgnd;
} else {
}
else {
pay = "0,"+ll+","+node.fgnd+"\n"+(ll+1)+","+(node.pixels-1)+","+node.bgnd;
}
}

View File

@ -7,42 +7,49 @@ module.exports = function(RED) {
var checkLength = function(text) {
var l = text.length;
switch(true) {
case /^http:\/\/www./.test(text):
l -= 10;
break;
case /^https:\/\/www./.test(text):
l -= 11;
break;
case /^http:\/\//.test(text):
l -= 6;
break;
case /^https:\/\//.test(text):
l -= 7;
break;
switch (true) {
case /^http:\/\/www./.test(text): {
l -= 10;
break;
}
case /^https:\/\/www./.test(text): {
l -= 11;
break;
}
case /^http:\/\//.test(text): {
l -= 6;
break;
}
case /^https:\/\//.test(text): {
l -= 7;
break;
}
}
switch(true) {
case /.*\.info\/.*/.test(text):
l -= 5;
break;
switch (true) {
case /.*\.info\/.*/.test(text): {
l -= 5;
break;
}
case /.*\.com\/.*/.test(text):
case /.*\.net\/.*/.test(text):
case /.*\.org\/.*/.test(text):
case /.*\.edu\/.*/.test(text):
case /.*\.biz\/.*/.test(text):
case /.*\.gov\/.*/.test(text):
case /.*\.info.*/.test(text):
l -= 4;
break;
case /.*\.info.*/.test(text): {
l -= 4;
break;
}
case /.*\.com.*/.test(text):
case /.*\.net.*/.test(text):
case /.*\.org.*/.test(text):
case /.*\.edu.*/.test(text):
case /.*\.biz.*/.test(text):
case /.*\.gov.*/.test(text):
l -= 3;
break;
case /.*\.gov.*/.test(text): {
l -= 3;
break;
}
}
return l;
}
@ -70,7 +77,8 @@ module.exports = function(RED) {
try {
eddystoneBeacon.advertiseUrl(node.url, node.options);
node.status({fill:"green",shape:"dot",text:node.url});
} catch(e) {
}
catch(e) {
node.error('Error setting beacon URL', e);
}
}
@ -83,7 +91,8 @@ module.exports = function(RED) {
try {
eddystoneBeacon.advertiseUid(node.namespace, node.instance, node.options);
node.status({fill:"green",shape:"dot",text:node.namespace});
} catch(e) {
}
catch(e) {
node.error('Error setting beacon information', e);
}
}
@ -96,7 +105,8 @@ module.exports = function(RED) {
try {
eddystoneBeacon.stop();
node.status({fill:"red",shape:"dot",text:"Stopped"});
} catch(e) {
}
catch(e) {
node.error('error shutting down beacon', e);
}
return;
@ -107,7 +117,8 @@ module.exports = function(RED) {
try {
eddystoneBeacon.advertiseUrl(node.url, node.options);
node.status({fill:"green",shape:"dot",text:node.url});
} catch(e) {
}
catch(e) {
node.error('Error setting beacon URL', e);
}
return;
@ -116,7 +127,8 @@ module.exports = function(RED) {
try {
eddystoneBeacon.advertiseUid(node.namespace, node.instance, node.options);
node.status({fill:"green",shape:"dot",text:node.namespace});
} catch(e) {
}
catch(e) {
node.error('Error setting beacon information', e);
}
return;
@ -124,30 +136,33 @@ module.exports = function(RED) {
}
// url mode
if (node.mode === "url") {
if (checkLength(msg.payload) <= 18) {
try {
node.url = msg.payload;
eddystoneBeacon.advertiseUrl(node.url, node.options);
node.status({fill:"green",shape:"dot",text:node.url});
} catch(e) {
node.status({fill:"red",shape:"dot",text:"Error setting URL"});
node.error('error updating beacon URL', e);
}
} else {
node.status({fill:"red",shape:"dot",text:"URL too long"});
}
if (checkLength(msg.payload) <= 18) {
try {
node.url = msg.payload;
eddystoneBeacon.advertiseUrl(node.url, node.options);
node.status({fill:"green",shape:"dot",text:node.url});
}
catch(e) {
node.status({fill:"red",shape:"dot",text:"Error setting URL"});
node.error('error updating beacon URL', e);
}
}
else {
node.status({fill:"red",shape:"dot",text:"URL too long"});
}
}
// uid mode
else {
try {
node.namespace = msg.payload;
node.instance = msg.topic;
eddystoneBeacon.advertiseUid(node.namespace, node.instance, node.options);
node.status({fill:"green",shape:"dot",text:msg.payload});
} catch(e) {
node.status({fill:"red",shape:"dot",text:"Error setting beacon information"});
node.error('Error setting beacon information', e);
}
try {
node.namespace = msg.payload;
node.instance = msg.topic;
eddystoneBeacon.advertiseUid(node.namespace, node.instance, node.options);
node.status({fill:"green",shape:"dot",text:msg.payload});
}
catch(e) {
node.status({fill:"red",shape:"dot",text:"Error setting beacon information"});
node.error('Error setting beacon information', e);
}
}
});
@ -157,7 +172,8 @@ module.exports = function(RED) {
node.status({});
eddystoneBeacon.stop();
done();
} catch(e) {
}
catch(e) {
node.error('error shutting down beacon', e);
}
});

View File

@ -100,7 +100,8 @@ module.exports = function(RED) {
},node.uuid);
}
},15000);
} else {
}
else {
console.log("reconfig",node.uuid);
enable(node);
}
@ -114,46 +115,54 @@ module.exports = function(RED) {
var enable = function(node) {
if (node.temperature) {
node.stag.notifyIrTemperature(function() {});
} else {
}
else {
node.stag.unnotifyIrTemperature(function() {});
}
if (node.pressure) {
node.stag.notifyBarometricPressure(function() {});
} else {
}
else {
node.stag.unnotifyBarometricPressure(function() {});
}
if (node.humidity) {
node.stag.notifyHumidity(function() {});
} else {
}
else {
node.stag.unnotifyHumidity(function() {});
}
if (node.accelerometer) {
node.stag.notifyAccelerometer(function() {});
} else {
}
else {
node.stag.unnotifyAccelerometer(function() {});
}
if (node.magnetometer) {
node.stag.notifyMagnetometer(function() {});
} else {
}
else {
node.stag.unnotifyMagnetometer(function() {});
}
if (node.gyroscope) {
node.stag.notifyGyroscope(function() {});
} else {
}
else {
node.stag.unnotifyGyroscope(function() {});
}
if (node.stag.type === "cc2650") {
if (node.luxometer) {
node.stag.enableLuxometer(function() {});
node.stag.notifyLuxometer(function() {});
} else {
}
else {
node.stag.unnotifyLuxometer(function() {});
node.stag.disableLuxometer(function() {});
}
}
if (node.keys) {
node.stag.notifySimpleKey(function() {});
} else {
}
else {
node.stag.unnotifySimpleKey(function() {});
}
}

View File

@ -48,7 +48,8 @@ module.exports = function(RED) {
delete subscriptions[dev];
delete sub2dev[sub.sid];
subscribe({dev: subs[s]});
} else {
}
else {
// console.log("resubscription good %s", res.statusCode);
// console.log("dev - %s", util.inspect(dev));
}
@ -78,7 +79,8 @@ module.exports = function(RED) {
if (subscriptions[dev]) {
//exists
subscriptions[dev].count++;
} else {
}
else {
//new
var ipAddr;
@ -97,7 +99,8 @@ module.exports = function(RED) {
break;
}
}
} else {
}
else {
//node 0.10 not great but best we can do
if (!addrs[add].internal && addrs[add].family == 'IPv4') {
ipAddr = addrs[add].address;
@ -143,7 +146,8 @@ module.exports = function(RED) {
if (res.statusCode == 200) {
subscriptions[dev] = {'count': 1, 'sid': res.headers.sid};
sub2dev[res.headers.sid] = dev;
} else {
}
else {
console.log('failed to subsrcibe');
}
});
@ -181,10 +185,12 @@ module.exports = function(RED) {
unSubreq.end();
} else {
}
else {
subscriptions[dev].count--;
}
} else {
}
else {
//shouldn't ever get here
}
}
@ -210,7 +216,8 @@ module.exports = function(RED) {
node.status({fill: 'green',shape: 'dot',text: 'found'});
}
});
} else {
}
else {
node.status({fill: 'green',shape: 'dot',text: 'found'});
}
@ -227,27 +234,32 @@ module.exports = function(RED) {
if (typeof msg.payload === 'string') {
if (msg.payload == 'on' || msg.payload == '1' || msg.payload == 'true') {
on = 1;
} else if (msg.payload === 'toggle') {
}
else if (msg.payload === 'toggle') {
on = 2;
}
} else if (typeof msg.payload === 'number') {
}
else if (typeof msg.payload === 'number') {
if (msg.payload >= 0 && msg.payload < 3) {
on = msg.payload;
}
} else if (typeof msg.payload === 'object') {
}
else if (typeof msg.payload === 'object') {
//object need to get complicated here
if (msg.payload.state && typeof msg.payload.state === 'number') {
if (dev.type === 'socket') {
if (msg.payload >= 0 && msg.payload < 2) {
on = msg.payload.state;
}
} else if (dev.type === 'light' || dev.type === 'group') {
}
else if (dev.type === 'light' || dev.type === 'group') {
if (msg.payload >= 0 && msg.payload < 3) {
on = msg.payload.state;
}
}
}
} else if (typeof msg.payload === 'boolean') {
}
else if (typeof msg.payload === 'boolean') {
if (msg.payload) {
on = 1;
}
@ -256,10 +268,12 @@ module.exports = function(RED) {
if (dev.type === 'socket') {
//console.log("socket");
wemo.toggleSocket(dev, on);
} else if (dev.type === 'light`') {
}
else if (dev.type === 'light`') {
//console.log("light");
wemo.setStatus(dev,'10006', on);
} else {
}
else {
console.log('group');
wemo.setStatus(dev, '10006', on);
}
@ -295,17 +309,18 @@ module.exports = function(RED) {
switch (notification.type){
case 'light':
case 'group':
case 'group': {
if (dd.id === notification.id) {
node.send(msg);
}
break;
case 'socket':
}
case 'socket': {
node.send(msg);
break;
default:
}
default: {}
}
}
};
@ -316,7 +331,8 @@ module.exports = function(RED) {
if (wemo.get(node.dev)) {
node.status({fill: 'green',shape: 'dot',text: 'found'});
subscribe(node);
} else {
}
else {
wemo.on('discovered', function(d) {
if (node.dev === d) {
node.status({fill: 'green',shape: 'dot',text: 'found'});
@ -324,7 +340,8 @@ module.exports = function(RED) {
}
});
}
} else if (node.ipaddr) {
}
else if (node.ipaddr) {
//legacy
var devices = Object.keys(wemo.devices);
for (var d in devices) {

View File

@ -34,7 +34,8 @@ module.exports = function(RED) {
else {
if (msg.payload.indexOf(':') > -1) {
this.url += 'json={' + msg.payload + '}';
} else {
}
else {
this.url += 'csv='+msg.payload;
}
}
@ -96,7 +97,8 @@ module.exports = function(RED) {
if (msg.rc === 200) {
try {
msg.payload = JSON.parse(msg.payload);
} catch(err) {
}
catch(err) {
// Failed to parse, pass it on
}
node.send(msg);

View File

@ -22,7 +22,8 @@ module.exports = function(RED) {
this.client = mqlight.createClient(opts, function(err) {
if (err) {
util.log('[mqlight] ['+id+'] not connected to service '+n.service);
} else {
}
else {
util.log('[mqlight] ['+id+'] connected to service '+n.service);
}
});
@ -72,13 +73,15 @@ module.exports = function(RED) {
var subscribeCallback = function(err) {
if (err) {
node.error("Failed to subscribe: " + err);
} else {
}
else {
node.log("Subscribed to "+node.topic+(node.share?" ["+node.share+"]":""));
}
};
if (node.share) {
recvClient.subscribe(node.topic, node.share, subscribeCallback);
} else {
}
else {
recvClient.subscribe(node.topic, subscribeCallback);
}
});
@ -113,7 +116,8 @@ module.exports = function(RED) {
if (topic === "") {
if (msg.topic) {
topic = msg.topic;
} else {
}
else {
node.warn("No topic set in MQ Light out node");
return;
}

View File

@ -45,11 +45,13 @@ module.exports = function(RED) {
if (!Buffer.isBuffer(payload)) {
if (typeof payload === "object") {
payload = JSON.stringify(payload);
} else {
}
else {
payload = payload.toString();
}
payload += node.addCh;
} else if (node.addCh !== "") {
}
else if (node.addCh !== "") {
payload = Buffer.concat([payload,new Buffer(node.addCh)]);
}
node.port.write(payload,function(err,res) {
@ -66,14 +68,16 @@ module.exports = function(RED) {
node.port.on('closed', function() {
node.status({fill:"red",shape:"ring",text:"node-red:common.status.not-connected"});
});
} else {
}
else {
this.error(RED._("serial.errors.missing-conf"));
}
this.on("close", function(done) {
if (this.serialConfig) {
serialPool.close(this.serialConfig.serialport,done);
} else {
}
else {
done();
}
});
@ -105,7 +109,8 @@ module.exports = function(RED) {
var splitc;
if (node.serialConfig.newline.substr(0,2) == "0x") {
splitc = new Buffer([parseInt(node.serialConfig.newline)]);
} else {
}
else {
splitc = new Buffer(node.serialConfig.newline.replace("\\n","\n").replace("\\r","\r").replace("\\t","\t").replace("\\e","\e").replace("\\f","\f").replace("\\0","\0")); // jshint ignore:line
}
@ -169,14 +174,16 @@ module.exports = function(RED) {
this.port.on('closed', function() {
node.status({fill:"red",shape:"ring",text:"node-red:common.status.not-connected"});
});
} else {
}
else {
this.error(RED._("serial.errors.missing-conf"));
}
this.on("close", function(done) {
if (this.serialConfig) {
serialPool.close(this.serialConfig.serialport,done);
} else {
}
else {
done();
}
});
@ -273,7 +280,8 @@ module.exports = function(RED) {
}
catch(err) { }
delete connections[port];
} else {
}
else {
done();
}
}

View File

@ -18,7 +18,8 @@ module.exports = function(RED) {
node.session.get(oids.split(","), function(error, varbinds) {
if (error) {
node.error(error.toString(),msg);
} else {
}
else {
for (var i = 0; i < varbinds.length; i++) {
if (snmp.isVarbindError(varbinds[i])) {
node.error(snmp.varbindError(varbinds[i]),msg);
@ -62,7 +63,8 @@ module.exports = function(RED) {
function responseCb(error, table) {
if (error) {
console.error(error.toString());
} else {
}
else {
var indexes = [];
for (var index in table) {
if (table.hasOwnProperty(index)) {

View File

@ -41,7 +41,7 @@ module.exports = function(RED) {
}
};
if (this.serverConfig.vhost) {
this.stompClientOpts.vhost = this.serverConfig.vhost;
this.stompClientOpts.vhost = this.serverConfig.vhost;
}
var node = this;
@ -49,7 +49,7 @@ module.exports = function(RED) {
node.client = new StompClient(node.stompClientOpts);
node.client.on("connect", function() {
node.status({fill:"green",shape:"dot",text:"connected"});
node.status({fill:"green",shape:"dot",text:"connected"});
});
node.client.on("reconnecting", function() {
@ -110,14 +110,14 @@ module.exports = function(RED) {
}
};
if (this.serverConfig.vhost) {
this.stompClientOpts.vhost = this.serverConfig.vhost;
this.stompClientOpts.vhost = this.serverConfig.vhost;
}
var node = this;
node.client = new StompClient(node.stompClientOpts);
node.client.on("connect", function() {
node.status({fill:"green",shape:"dot",text:"connected"});
node.status({fill:"green",shape:"dot",text:"connected"});
});
node.client.on("reconnecting", function() {

View File

@ -22,7 +22,8 @@ module.exports = function(RED) {
node.log("sent WOL magic packet");
}
});
} catch(e) {
}
catch(e) {
if (RED.settings.verbose) { node.log("WOL: socket error"); }
}
}

View File

@ -28,7 +28,8 @@ module.exports = function(RED) {
else {
node.warn("This node only handles strings or buffers.");
}
} else { node.warn("No payload found to process"); }
}
else { node.warn("No payload found to process"); }
});
}
RED.nodes.registerType("base64",Base64Node);

View File

@ -29,7 +29,8 @@ module.exports = function(RED) {
if (lt && ln) {
msg.location.geohash = geohash.encode(lt, ln, le);
node.send(msg);
} else {
}
else {
node.warn("lat or lon missing from msg.location");
}
}
@ -62,7 +63,8 @@ module.exports = function(RED) {
if (!isNaN(la) && !isNaN(lo)) {
msg.payload = geohash.encode(la, lo, li);
node.send(msg);
} else {
}
else {
node.warn("Incorrect string format - should be lat,lon");
}
}
@ -79,7 +81,8 @@ module.exports = function(RED) {
if (lat && lon) {
msg.payload.geohash = geohash.encode(lat, lon, len);
node.send(msg);
} else {
}
else {
node.warn("lat or lon missing from msg.payload");
}
}

View File

@ -26,7 +26,8 @@ module.exports = function(RED) {
node.send(msg);
node.status({text:le +" o->b "+ msg.payload.length});
}
} else { node.warn("No payload found to process"); }
}
else { node.warn("No payload found to process"); }
});
}
RED.nodes.registerType("msgpack",MsgPackNode);

View File

@ -7,7 +7,8 @@ module.exports = function(RED) {
RED.nodes.createNode(this, n);
this.lang = n.lang || "en";
var credentials = RED.nodes.getCredentials(n.id);
if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; } else { this.error("No what3words API key set"); }
if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; }
else { this.error("No what3words API key set"); }
this.w3w = new What3Words(this.pushkey);
var node = this;
var w1 = /^\*\w{6,31}$/;
@ -25,7 +26,8 @@ module.exports = function(RED) {
.catch(function(err) {
node.warn(err)
});
} else if (typeof (msg.payload) === "string") {
}
else if (typeof (msg.payload) === "string") {
if (msg.payload.split(",").length === 2) { // see if it's 2 comma separated words
node.w3w.positionToWords({ position:msg.payload, lang:node.lang })
.then(function(response) {
@ -36,7 +38,8 @@ module.exports = function(RED) {
.catch(function(err) {
node.warn(err);
});
} else if (msg.payload.match(w3)) { // see if it's 3 dot separated words
}
else if (msg.payload.match(w3)) { // see if it's 3 dot separated words
node.w3w.wordsToPosition({ words:msg.payload })
.then(function(response) {
if (!msg.hasOwnProperty("location")) { msg.location = {}; }
@ -47,7 +50,8 @@ module.exports = function(RED) {
.catch(function(err) {
node.warn(err)
});
} else if (msg.payload.match(w1)) { // see if it's a *Oneword
}
else if (msg.payload.match(w1)) { // see if it's a *Oneword
node.w3w.wordsToPosition({ words:msg.payload })
.then(function(response) {
if (!msg.hasOwnProperty("location")) { msg.location = {}; }
@ -59,8 +63,10 @@ module.exports = function(RED) {
.catch(function(err) {
node.warn(err);
});
} else { node.warn("No useable data found. See info."); }
} else { node.warn("No useable data found. See info."); }
}
else { node.warn("No useable data found. See info."); }
}
else { node.warn("No useable data found. See info."); }
});
}
RED.nodes.registerType("what3words", what3wordsNode);
@ -71,7 +77,8 @@ module.exports = function(RED) {
var credentials = RED.nodes.getCredentials(req.params.id);
if (credentials) {
res.send(JSON.stringify({hasPassword:(credentials.pushkey && credentials.pushkey !== "")}));
} else {
}
else {
res.send(JSON.stringify({}));
}
});
@ -91,7 +98,8 @@ module.exports = function(RED) {
var credentials = RED.nodes.getCredentials(req.params.id) || {};
if (newCreds.pushkey === "") {
delete credentials.pushkey;
} else {
}
else {
credentials.pushkey = newCreds.pushkey || credentials.pushkey;
}
RED.nodes.addCredentials(req.params.id, credentials);

View File

@ -45,7 +45,8 @@ module.exports = function(RED) {
// This will be called anytime there is a new dweet for my-thing
if (dweet.content.hasOwnProperty("payload")) {
dweet.payload = dweet.content.payload;
} else {
}
else {
dweet.payload = dweet.content;
}
delete dweet.content;

View File

@ -19,7 +19,8 @@ module.exports = function(RED) {
try {
var globalkeys = RED.settings.email || require(process.env.NODE_RED_HOME+"/../emailkeys.js");
} catch(err) {
}
catch(err) {
}
function EmailNode(n) {
@ -57,7 +58,7 @@ module.exports = function(RED) {
var smtpTransport = nodemailer.createTransport({
host: node.outserver,
port: node.outport,
secure: true,
secure: node.useSSL,
auth: {
user: node.userid,
pass: node.password

View File

@ -1,6 +1,6 @@
{
"name": "node-red-node-email",
"version": "0.1.15",
"version": "0.1.16",
"description": "Node-RED nodes to send and receive simple emails",
"dependencies": {
"nodemailer": "^1.11.0",

View File

@ -15,7 +15,8 @@ module.exports = function(RED) {
var parsedUrl = url.parse(this.url);
if (!(parsedUrl.host || (parsedUrl.hostname && parsedUrl.port)) && !parsedUrl.isUnix) {
this.error(RED._("feedparse.errors.invalidurl"));
} else {
}
else {
var getFeed = function() {
var req = request(node.url, {timeout: 10000, pool: false});
//req.setMaxListeners(50);

View File

@ -33,10 +33,10 @@ module.exports = function(RED) {
}
RED.nodes.registerType("irc-server",IRCServerNode, {
credentials: {
username: {type:"text"},
password: {type:"password"}
}
credentials: {
username: {type:"text"},
password: {type:"password"}
}
});

View File

@ -62,7 +62,8 @@ module.exports = function(RED) {
pusher.me(function(err, me) {
if (err) {
reject(err);
} else {
}
else {
resolve(me);
}
});
@ -74,7 +75,8 @@ module.exports = function(RED) {
pusher.history({limit:1}, function(err, res) {
if (err) {
resolve(0);
} else {
}
else {
try {
resolve(res.pushes[0].modified);
}
@ -144,7 +146,8 @@ module.exports = function(RED) {
closing = true;
try {
this.stream.close();
} catch(err) {
}
catch(err) {
// Ignore error if not connected
}
});
@ -167,7 +170,8 @@ module.exports = function(RED) {
}
try {
resolve(res.pushes[0].modified);
} catch(ex) {
}
catch(ex) {
resolve(last);
}
});
@ -360,7 +364,8 @@ module.exports = function(RED) {
if (me) {
deviceid = me.email;
self.pushMsg(pushtype, deviceid, title, msg);
} else {
}
else {
self.error("Unable to push",msg);
}
});

View File

@ -39,10 +39,12 @@ module.exports = function(RED) {
if (this.api) {
this.twilioClient = twilio(this.api.sid,this.api.token);
this.fromNumber = this.api.from;
} else if (twiliokey) {
}
else if (twiliokey) {
this.twilioClient = twilio(twiliokey.account, twiliokey.authtoken);
this.fromNumber = twiliokey.from;
} else {
}
else {
this.error("missing twilio credentials");
return;
}
@ -66,7 +68,8 @@ module.exports = function(RED) {
}
//console.log(response);
});
} else {
}
else {
// Send SMS
node.twilioClient.sendMessage( {to: tonum, from: node.fromNumber, body: msg.payload}, function(err, response) {
if (err) {
@ -76,7 +79,8 @@ module.exports = function(RED) {
});
}
} catch (err) {
}
catch (err) {
node.error(err);
}
});

View File

@ -32,7 +32,8 @@ module.exports = function(RED) {
msg.location.lon = msg.tweet.geo.coordinates[1];
msg.location.icon = "twitter";
}
} else if (msg.tweet.coordinates) { // otherwise attempt go get it from coordinates
}
else if (msg.tweet.coordinates) { // otherwise attempt go get it from coordinates
if (msg.tweet.coordinates.coordinates && msg.tweet.coordinates.coordinates.length === 2) {
if (!msg.location) { msg.location = {}; }
// WARNING! coordinates[1] is lat, coordinates[0] is lon!!!
@ -94,7 +95,8 @@ module.exports = function(RED) {
}
if (cb[0]) {
node.since_ids[u] = cb[0].id_str;
} else {
}
else {
node.since_ids[u] = '0';
}
node.poll_ids.push(setInterval(function() {
@ -143,7 +145,8 @@ module.exports = function(RED) {
}
if (cb[0]) {
node.since_id = cb[0].id_str;
} else {
}
else {
node.since_id = '0';
}
node.poll_ids.push(setInterval(function() {
@ -203,7 +206,8 @@ module.exports = function(RED) {
//console.log("ERRO",rc,tweet);
if (rc == 420) {
node.status({fill:"red", shape:"ring", text:RED._("twitter.errors.ratelimit")});
} else {
}
else {
node.status({fill:"red", shape:"ring", text:" "});
node.warn(RED._("twitter.errors.streamerror",{error:tweet.toString(),rc:rc}));
}
@ -265,7 +269,8 @@ module.exports = function(RED) {
//console.log("ERRO",rc,tweet);
if (rc == 420) {
node.status({fill:"red", shape:"ring", text:RED._("twitter.errors.ratelimit")});
} else {
}
else {
node.status({fill:"red", shape:"ring", text:tweet.toString()});
node.warn(RED._("twitter.errors.streamerror",{error:tweet.toString(),rc:rc}));
}
@ -409,13 +414,15 @@ module.exports = function(RED) {
if (err) {
node.error(err,msg);
node.status({fill:"red",shape:"ring",text:"twitter.status.failed"});
} else {
}
else {
var response = JSON.parse(body);
if (response.errors) {
var errorList = response.errors.map(function(er) { return er.code+": "+er.message }).join(", ");
node.error(RED._("twitter.errors.sendfail",{error:errorList}),msg);
node.status({fill:"red",shape:"ring",text:"twitter.status.failed"});
} else {
}
else {
node.status({});
}
}
@ -424,7 +431,8 @@ module.exports = function(RED) {
form.append("status",msg.payload);
form.append("media[]",msg.media,{filename:"image"});
} else {
}
else {
if (typeof msg.params === 'undefined') { msg.params = {}; }
twit.updateStatus(msg.payload, msg.params, function (err, data) {
if (err) {
@ -460,7 +468,8 @@ module.exports = function(RED) {
var err = {statusCode: 401, data: "dummy error"};
var resp = RED._("twitter.errors.oautherror",{statusCode: err.statusCode, errorData: err.data});
res.send(resp)
} else {
}
else {
credentials.oauth_token = oauth_token;
credentials.oauth_token_secret = oauth_token_secret;
res.redirect('https://api.twitter.com/oauth/authorize?oauth_token='+oauth_token)
@ -481,7 +490,8 @@ module.exports = function(RED) {
if (error) {
RED.log.error(error);
res.send(RED._("twitter.errors.oauthbroke"));
} else {
}
else {
credentials = {};
credentials.access_token = oauth_access_token;
credentials.access_token_secret = oauth_access_token_secret;

View File

@ -104,7 +104,8 @@ module.exports = function(RED) {
skipPresence : true,
reconnect : false
});
} catch(e) {
}
catch(e) {
node.error("Bad xmpp configuration");
node.status({fill:"red",shape:"ring",text:"not connected"});
}
@ -180,7 +181,8 @@ module.exports = function(RED) {
skipPresence : true,
reconnect : false
});
} catch(e) {
}
catch(e) {
node.error("Bad xmpp configuration");
node.status({fill:"red",shape:"ring",text:"not connected"});
}
@ -201,7 +203,8 @@ module.exports = function(RED) {
else if (msg.payload) {
if (typeof(msg.payload) === "object") {
xmpp.send(to, JSON.stringify(msg.payload), node.join);
} else {
}
else {
xmpp.send(to, msg.payload.toString(), node.join);
}
}

View File

@ -55,7 +55,8 @@ module.exports = function(RED) {
if (noerror) { node.error(err); }
noerror = false;
node.tout = setTimeout(connectToDB, 10000);
} else {
}
else {
node.status({fill:"green",shape:"dot",text:RED._("mongodb.status.connected")});
node.clientDb = db;
noerror = true;
@ -67,7 +68,8 @@ module.exports = function(RED) {
if (!node.collection) {
if (msg.collection) {
coll = db.collection(msg.collection);
} else {
}
else {
node.error(RED._("mongodb.errors.nocollection"),msg);
return;
}
@ -87,14 +89,16 @@ module.exports = function(RED) {
node.error(err,msg);
}
});
} else {
}
else {
coll.save(msg,function(err, item) {
if (err) {
node.error(err,msg);
}
});
}
} else if (node.operation === "insert") {
}
else if (node.operation === "insert") {
if (node.payonly) {
if (typeof msg.payload !== "object") {
msg.payload = {"payload": msg.payload};
@ -107,14 +111,16 @@ module.exports = function(RED) {
node.error(err,msg);
}
});
} else {
}
else {
coll.insert(msg, function(err,item) {
if (err) {
node.error(err,msg);
}
});
}
} else if (node.operation === "update") {
}
else if (node.operation === "update") {
if (typeof msg.payload !== "object") {
msg.payload = {"payload": msg.payload};
}
@ -132,7 +138,8 @@ module.exports = function(RED) {
node.error(err,msg);
}
});
} else if (node.operation === "delete") {
}
else if (node.operation === "delete") {
coll.remove(msg.payload, function(err, items) {
if (err) {
node.error(err,msg);
@ -173,7 +180,8 @@ module.exports = function(RED) {
if (noerror) { node.error(err); }
noerror = false;
node.tout = setTimeout(connectToDB, 10000);
} else {
}
else {
node.status({fill:"green",shape:"dot",text:RED._("mongodb.status.connected")});
node.clientDb = db;
noerror = true;
@ -217,7 +225,8 @@ module.exports = function(RED) {
node.send(msg);
}
});
} else if (node.operation === "count") {
}
else if (node.operation === "count") {
selector = ensureValidSelectorObject(msg.payload);
coll.count(selector, function(err, count) {
if (err) {
@ -234,7 +243,8 @@ module.exports = function(RED) {
coll.aggregate(msg.payload, function(err, result) {
if (err) {
node.error(err);
} else {
}
else {
msg.payload = result;
node.send(msg);
}

View File

@ -47,7 +47,8 @@ module.exports = function(RED) {
if (this.client.connected) {
this.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"});
} else {
}
else {
this.status({fill:"red",shape:"ring",text:"node-red:common.status.disconnected"},true);
}
@ -64,23 +65,29 @@ module.exports = function(RED) {
if (k) {
if (this.structtype == "string") {
this.client.set(k,RED.util.ensureString(msg.payload));
} else if (this.structtype == "hash") {
}
else if (this.structtype == "hash") {
if (typeof msg.payload == "object") {
this.client.hmset(k,msg.payload);
} else {
}
else {
var r = hashFieldRE.exec(msg.payload);
if (r) {
this.client.hset(k,r[1],r[2]);
} else {
}
else {
this.warn(RED._("redisout.errors.invalidpayload"));
}
}
} else if (this.structtype == "set") {
}
else if (this.structtype == "set") {
this.client.sadd(k,msg.payload);
} else if (this.structtype == "list") {
}
else if (this.structtype == "list") {
this.client.rpush(k,msg.payload);
}
} else {
}
else {
this.warn(RED._("redisout.errors.nokey"));
}
});

View File

@ -144,11 +144,13 @@ module.exports = function(RED) {
try {
node.emit("input", {payload:"reset"});
res.sendStatus(200);
} catch (err) {
}
catch (err) {
res.sendStatus(500);
node.error("Inject failed:" + err);
}
} else {
}
else {
res.sendStatus(404);
}
});

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-daemon",
"version" : "0.0.10",
"version" : "0.0.11",
"description" : "A Node-RED node that runs and monitors a long running system command.",
"dependencies" : {
},

View File

@ -50,13 +50,16 @@ module.exports = function(RED) {
msg.location.lat = latitude;
msg.location.lon = longitude;
return;
} else {
}
else {
node.log("Invalid longitude data, no location information has been added to the message.");
}
} else {
}
else {
node.log("Invalid latitude data, no location information has been added to the message.");
}
} else {
}
else {
node.log("The location of this image cannot be determined safely so no location information has been added to the message.");
}
}
@ -68,26 +71,31 @@ module.exports = function(RED) {
new ExifImage({ image : msg.payload }, function (error, exifData) {
if (error) {
node.log(error.toString());
} else {
}
else {
//msg.payload remains the same buffer
if ((exifData) && (exifData.hasOwnProperty("gps")) && (Object.keys(exifData.gps).length !== 0)) {
msg.exif = exifData;
addMsgLocationDataFromExifGPSData(msg);
} else {
}
else {
node.warn("The incoming image did not contain Exif GPS data, nothing to do. ");
}
}
node.send(msg);
});
} else {
}
else {
node.error("Invalid payload received, the Exif node cannot proceed, no messages sent.");
return;
}
} else {
}
else {
node.error("No payload received, the Exif node cannot proceed, no messages sent.");
return;
}
} catch (error) {
}
catch (error) {
node.error("An error occurred while extracting Exif information. Please check the log for details.");
node.log('Error: '+error.message);
return;