# node-red-contrib-boolean-logic-ultimate | # node-red-contrib-boolean-logic-ultimate | ||||
<p> | <p> | ||||
<b>Version 0.0.6</b><br/> | |||||
- Fixed crappy "Invert" node.<br/> | |||||
</p> | |||||
<p> | |||||
<b>Version 0.0.5</b><br/> | <b>Version 0.0.5</b><br/> | ||||
- Bypass persistency if node-red user hasn't permissions to write to the filesystem.<br/> | - Bypass persistency if node-red user hasn't permissions to write to the filesystem.<br/> | ||||
</p> | </p> |
icon: "serial.png", | icon: "serial.png", | ||||
label: | label: | ||||
function() { | function() { | ||||
var label = "Logic" + " [" + this.inputCount + "]"; | |||||
var label = "Logic" + (this.filtertrue=="both" ? "" : " filtered" ) + " [" + this.inputCount + "]"; | |||||
if( this.name !== undefined && this.name.length > 0 ) { | if( this.name !== undefined && this.name.length > 0 ) { | ||||
label = label + " (" + this.name + ")"; | label = label + " (" + this.name + ")"; | ||||
} | } | ||||
- Output "AND": true or false<br/> | - Output "AND": true or false<br/> | ||||
- Output "OR": true or false<br/> | - Output "OR": true or false<br/> | ||||
- Output "XOR": true or false<br/> | - Output "XOR": true or false<br/> | ||||
<br/> | <br/> | ||||
Changing the topic is usually only needed when chaining multiple boolean nodes after each other becuse the topics will then all be the same when delivered to the nodes further down the chain.<br/> | Changing the topic is usually only needed when chaining multiple boolean nodes after each other becuse the topics will then all be the same when delivered to the nodes further down the chain.<br/> | ||||
<br/> | <br/> | ||||
<li>Output both 'true' and 'false' results: Standard behaviour, the node will output <b>true</b> and <b>false</b> whenever it receives an input and calculate the boolean logics as output.</li> | <li>Output both 'true' and 'false' results: Standard behaviour, the node will output <b>true</b> and <b>false</b> whenever it receives an input and calculate the boolean logics as output.</li> | ||||
<li>Output only 'true' results: whenever the node receives an input, it outputs a payload <b>true</b> only if the result of the logic is true. <b>False</b> results are filtered out.</li> | <li>Output only 'true' results: whenever the node receives an input, it outputs a payload <b>true</b> only if the result of the logic is true. <b>False</b> results are filtered out.</li> | ||||
</ol> | </ol> | ||||
<b>filtered</b>: shown on label, means that the node will pass out only <code>true</code> values (Output only 'true' results). <br/> | |||||
<br/><br/> | <br/><br/> | ||||
<b>Remember latest input values after reboot</b><br /> | <b>Remember latest input values after reboot</b><br /> | ||||
If checked, the input values are retained after a node-red reboot. That means, that if you reboot your node-red, you don't need to wait all inputs to arrive and initialize the node, before the node can output a payload.<br/> | If checked, the input values are retained after a node-red reboot. That means, that if you reboot your node-red, you don't need to wait all inputs to arrive and initialize the node, before the node can output a payload.<br/> |
<script type="text/javascript"> | <script type="text/javascript"> | ||||
RED.nodes.registerType('InvertUltimate',{ | RED.nodes.registerType('InvertUltimate',{ | ||||
category: 'boolean logic ultimate', | |||||
category: 'boolean logic', | |||||
color: '#ff8080', | color: '#ff8080', | ||||
defaults: { | defaults: { | ||||
name: { | name: { | ||||
value: "InvertUltimate" | |||||
value: "Invert" | |||||
} | } | ||||
}, | }, | ||||
inputs:1, | inputs:1, | ||||
icon: "serial.png", | icon: "serial.png", | ||||
label: | label: | ||||
function() { | function() { | ||||
return this.name||"InvertUltimate"; | |||||
return this.name||"Invert"; | |||||
}, | }, | ||||
paletteLabel: function() { | paletteLabel: function() { | ||||
return "InvertUltimate"; | return "InvertUltimate"; |
RED.nodes.createNode(this,config); | RED.nodes.createNode(this,config); | ||||
this.config = config; | this.config = config; | ||||
var node = this; | var node = this; | ||||
node.status( {fill: "grey" ,shape: "dot" ,text: "waiting"}); | |||||
this.on('input', function(msg) { | this.on('input', function(msg) { | ||||
var topic = msg.topic; | |||||
var topic = msg.topic || ""; | |||||
var payload = msg.payload; | var payload = msg.payload; | ||||
if (topic !== undefined && payload !== undefined) { | if (topic !== undefined && payload !== undefined) { | ||||
node.status( {fill: "green" ,shape: "dot" ,text: !ToBoolean(payload)}); | node.status( {fill: "green" ,shape: "dot" ,text: !ToBoolean(payload)}); | ||||
return({ topic: topic, payload: !ToBoolean(payload) }); | |||||
node.send({ topic: topic, payload: !ToBoolean(payload) }); | |||||
return; | |||||
} | } | ||||
}); | }); | ||||
node.status( {fill: "grey" ,shape: "dot" ,text: payload}); | |||||
function ToBoolean( value ) { | function ToBoolean( value ) { | ||||
var res = false; | var res = false; |
{ | { | ||||
"name": "node-red-contrib-boolean-logic-ultimate", | "name": "node-red-contrib-boolean-logic-ultimate", | ||||
"version": "0.0.5", | |||||
"version": "0.0.6", | |||||
"description": "A set of Node-RED enhanced boolean logic, with persisten values after reboot and more", | "description": "A set of Node-RED enhanced boolean logic, with persisten values after reboot and more", | ||||
"author": "Supergiovane (https://github.com/Supergiovane)", | "author": "Supergiovane (https://github.com/Supergiovane)", | ||||
"dependencies": { | "dependencies": { |