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