mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Remove redundant msg != null checks.
This commit is contained in:
@@ -32,27 +32,25 @@ module.exports = function(RED) {
|
||||
var node = this;
|
||||
|
||||
this.on("input", function(msg) {
|
||||
if (msg != null) {
|
||||
if (Object.size(node.led) !== 0) {
|
||||
try {
|
||||
if (p2.test(msg.payload)) {
|
||||
var rgb = msg.payload.split(",");
|
||||
node.led.setColor(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255);
|
||||
}
|
||||
else {
|
||||
node.led.setColor(msg.payload.toLowerCase().replace(/\s+/g,''));
|
||||
}
|
||||
if (Object.size(node.led) !== 0) {
|
||||
try {
|
||||
if (p2.test(msg.payload)) {
|
||||
var rgb = msg.payload.split(",");
|
||||
node.led.setColor(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255);
|
||||
}
|
||||
catch (err) {
|
||||
node.warn("BlinkStick missing ?");
|
||||
node.led = blinkstick.findFirst();
|
||||
else {
|
||||
node.led.setColor(msg.payload.toLowerCase().replace(/\s+/g,''));
|
||||
}
|
||||
}
|
||||
else {
|
||||
//node.warn("No BlinkStick found");
|
||||
catch (err) {
|
||||
node.warn("BlinkStick missing ?");
|
||||
node.led = blinkstick.findFirst();
|
||||
}
|
||||
}
|
||||
else {
|
||||
//node.warn("No BlinkStick found");
|
||||
node.led = blinkstick.findFirst();
|
||||
}
|
||||
});
|
||||
if (Object.size(node.led) === 0) {
|
||||
node.error("No BlinkStick found");
|
||||
|
@@ -42,8 +42,7 @@ module.exports = function(RED) {
|
||||
var p2 = /[0-9]+,[0-9]+,[0-9]+/
|
||||
|
||||
if (device) {
|
||||
this.on("input", function(msg) {
|
||||
if (msg != null) {
|
||||
this.on("input", function(msg) {
|
||||
if (p1.test(msg.payload)) {
|
||||
var r = parseInt(msg.payload.slice(1,3),16);
|
||||
var g = parseInt(msg.payload.slice(3,5),16);
|
||||
@@ -57,8 +56,7 @@ module.exports = function(RED) {
|
||||
} else {
|
||||
node.warn("incompatable input - " + msg.payload);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
node.warn("no digispark RGB found");
|
||||
}
|
||||
|
@@ -25,14 +25,12 @@ module.exports = function(RED) {
|
||||
var node = this;
|
||||
|
||||
this.on("input", function(msg) {
|
||||
if (msg != null) {
|
||||
var state = 0;
|
||||
if ( msg.payload == 1 || msg.payload === true || msg.payload == "on" ) { state = 1; }
|
||||
node.wemoSwitch.setBinaryState(state, function(err, result) {
|
||||
if (err) { node.warn(err); }
|
||||
//else { node.log(result); }
|
||||
});
|
||||
}
|
||||
var state = 0;
|
||||
if ( msg.payload == 1 || msg.payload === true || msg.payload == "on" ) { state = 1; }
|
||||
node.wemoSwitch.setBinaryState(state, function(err, result) {
|
||||
if (err) { node.warn(err); }
|
||||
//else { node.log(result); }
|
||||
});
|
||||
});
|
||||
}
|
||||
RED.nodes.registerType("wemo out",WemoOut);
|
||||
|
Reference in New Issue
Block a user