|
|
@@ -10,19 +10,19 @@ module.exports = function(RED) { |
|
|
|
if (msg.hasOwnProperty("topic")){ |
|
|
|
sTopic = (msg.topic === "" ? sTopic : msg.topic); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (typeof msg.payload !== "undefined") { |
|
|
|
var bRes = ToBoolean(msg.payload); |
|
|
|
if (typeof bRes === "undefined") return; |
|
|
|
|
|
|
|
|
|
|
|
// 24/01/2020 Clone input message and replace only relevant topics |
|
|
|
var msgTrue = RED.util.cloneMessage(msg); |
|
|
|
var msgTrue = RED.util.cloneMessage(msg); |
|
|
|
msgTrue.topic = sTopic; |
|
|
|
msgTrue.payload = true; |
|
|
|
var msgFalse = RED.util.cloneMessage(msg); |
|
|
|
var msgFalse = RED.util.cloneMessage(msg); |
|
|
|
msgFalse.topic = sTopic; |
|
|
|
msgFalse.payload = false; |
|
|
|
|
|
|
|
|
|
|
|
if (bRes === true) { |
|
|
|
setNodeStatus({ fill: "green", shape: "dot", text: "(Send) true" }); |
|
|
|
node.send([msgTrue, null]); |
|
|
@@ -34,20 +34,20 @@ module.exports = function(RED) { |
|
|
|
return; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
function setNodeStatus({fill, shape, text}) |
|
|
|
{ |
|
|
|
var dDate = new Date(); |
|
|
|
node.status({fill: fill,shape: shape,text: text + " (" + dDate.getDate() + ", " + dDate.toLocaleTimeString() + ")"}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ToBoolean( value ) { |
|
|
|
var res = false; |
|
|
|
|
|
|
|
|
|
|
|
if (typeof value === 'boolean') { |
|
|
|
res = value; |
|
|
|
} |
|
|
|
} |
|
|
|
else if( typeof value === 'number' || typeof value === 'string' ) { |
|
|
|
// Is it formated as a decimal number? |
|
|
|
if( decimal.test( value ) ) { |
|
|
@@ -58,11 +58,11 @@ module.exports = function(RED) { |
|
|
|
res = value.toLowerCase() === "true"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RED.nodes.registerType("FilterUltimate",FilterUltimate); |
|
|
|
} |
|
|
|
} |