@@ -1,5 +1,9 @@ | |||
# node-red-contrib-boolean-logic-ultimate | |||
<p> | |||
<b>Version 1.0.0 LTS</b><br/> | |||
- Added Filter node<br/> | |||
</p> | |||
<p> | |||
<b>Version 0.0.8</b><br/> | |||
- Delete persistent states when a new unexpected topic arrrives<br/> | |||
- Better status representation<br/> |
@@ -44,7 +44,16 @@ All incoming msg.payloads are converted into a boolean value according to the fo | |||
<br> | |||
The XOR operation operates in a one, and only one mode, i.e. (A ^ B) ^ C ... ^ n | |||
</p> | |||
<p> | |||
<b>Invert Ultimate</b><br /> | |||
Outputs the inverted input. For example true -> false | |||
</p> | |||
<p> | |||
<b>Filter Ultimate</b><br /> | |||
This node has 2 outputs.<br /> | |||
If the input payload is true, the node will send <code>true</code> on output 1 and nothing on oputput 2<br /> | |||
If the input payload is false, the node will send nothing on output 1, and <code>false</code> on oputput 2<br /> | |||
</p> | |||
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg | |||
[license-url]: https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/LICENSE |
@@ -1,6 +1,6 @@ | |||
# node-red-contrib-boolean-logic-ultimate | |||
<p> | |||
<b>Version 0.0.9 LTS (Long term stable)</b><br/> | |||
<b>Version 1.0.0 LTS (Long term stable)</b><br/> | |||
- For invert node, changed the category in the palette list to match the boolean logic ultimate's category<br/> | |||
</p> | |||
<p> |
@@ -0,0 +1,47 @@ | |||
<script type="text/javascript"> | |||
RED.nodes.registerType('FilterUltimate',{ | |||
category: 'boolean logic ultimate', | |||
color: '#ff8080', | |||
defaults: { | |||
name: { | |||
value: "Filter" | |||
} | |||
}, | |||
inputs:1, | |||
outputs:2, | |||
outputLabels: function(i) { | |||
var ret=""; | |||
switch (i) { | |||
case 0: | |||
return "True"; | |||
break; | |||
case 1: | |||
return "False"; | |||
break; | |||
default: | |||
break; | |||
} | |||
}, | |||
icon: "switch.png", | |||
label: | |||
function() { | |||
return this.name||"Filter"; | |||
}, | |||
paletteLabel: function() { | |||
return "FilterUltimate"; | |||
} | |||
}); | |||
</script> | |||
<script type="text/x-red" data-template-name="FilterUltimate"> | |||
<div class="form-row"> | |||
<label for="node-input-name"><i class="icon-tag"></i> Name (topic)</label> | |||
<input type="text" id="node-input-name" placeholder="Name"> | |||
</div> | |||
</script> | |||
<script type="text/x-red" data-help-name="FilterUltimate"> | |||
<p>The node emits on output "true", only input payloads that are true<br/> | |||
and on the output "false", only input payload that are false. | |||
</p> | |||
</script> |
@@ -0,0 +1,61 @@ | |||
module.exports = function(RED) { | |||
function FilterUltimate(config) { | |||
RED.nodes.createNode(this,config); | |||
this.config = config; | |||
var node = this; | |||
node.status( {fill: "grey" ,shape: "dot" ,text: "Waiting"}); | |||
this.on('input', function (msg) { | |||
var sTopic = node.config.name; | |||
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; | |||
var msgTrue = { | |||
topic: sTopic, | |||
payload: true | |||
}; | |||
var msgFalse = { | |||
topic: sTopic, | |||
payload: false | |||
}; | |||
if (bRes === true) { | |||
node.status( {fill: "green" ,shape: "dot" ,text: "(Send) true,null"}); | |||
node.send([msgTrue, null]); | |||
} else | |||
{ | |||
node.status( {fill: "green" ,shape: "dot" ,text: "(Send) null,false"}); | |||
node.send([null, msgFalse]); | |||
} | |||
return; | |||
} | |||
}); | |||
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 ) ) { | |||
var v = parseFloat( value ); | |||
res = v != 0; | |||
} | |||
else { | |||
res = value.toLowerCase() === "true"; | |||
} | |||
} | |||
return res; | |||
}; | |||
} | |||
RED.nodes.registerType("FilterUltimate",FilterUltimate); | |||
} |
@@ -9,7 +9,7 @@ | |||
}, | |||
inputs:1, | |||
outputs:1, | |||
icon: "serial.png", | |||
icon: "swap.png", | |||
label: | |||
function() { | |||
return this.name||"Invert"; |
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "node-red-contrib-boolean-logic-ultimate", | |||
"version": "0.0.9", | |||
"version": "1.0.0", | |||
"description": "A set of Node-RED enhanced boolean logic, with persisten values after reboot and more", | |||
"author": "Supergiovane (https://github.com/Supergiovane)", | |||
"dependencies": { | |||
@@ -9,6 +9,8 @@ | |||
"keywords": [ | |||
"node-red", | |||
"boolean", | |||
"gate", | |||
"filter", | |||
"logic" | |||
], | |||
"license": "MIT", | |||
@@ -19,7 +21,8 @@ | |||
"node-red": { | |||
"nodes": { | |||
"BooleanLogicUltimate": "boolean-logic-ultimate/BooleanLogicUltimate.js", | |||
"InvertUltimate": "boolean-logic-ultimate/InvertUltimate.js" | |||
"InvertUltimate": "boolean-logic-ultimate/InvertUltimate.js", | |||
"FilterUltimate": "boolean-logic-ultimate/FilterUltimate.js" | |||
} | |||
} | |||
} |
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "node-red-contrib-boolean-logic-ultimate", | |||
"version": "0.0.1", | |||
"version": "0.0.8", | |||
"lockfileVersion": 1, | |||
"requires": true, | |||
"dependencies": { |
@@ -19,7 +19,8 @@ | |||
"node-red": { | |||
"nodes": { | |||
"BooleanLogicUltimate": "boolean-logic-ultimate/BooleanLogicUltimate.js", | |||
"InvertUltimate": "boolean-logic-ultimate/InvertUltimate.js" | |||
"InvertUltimate": "boolean-logic-ultimate/InvertUltimate.js", | |||
"FilterUltimate": "boolean-logic-ultimate/FilterUltimate.js" | |||
} | |||
} | |||
} |