node-red-contrib-boolean-logic-ultimate
Advanced tools
Comparing version
@@ -7,2 +7,3 @@ module.exports = function(RED) { | ||
var node = this; | ||
node.config = config; | ||
var fs = require('fs'); | ||
@@ -72,3 +73,17 @@ var decimal = /^\s*[+-]{0,1}\s*([\d]+(\.[\d]*)*)\s*$/ | ||
} | ||
SetResult(resAND,resOR,resXOR, node.config.topic); | ||
// Operation mode evaluation | ||
if (node.config.outputtriggeredby == "onlyonetopic") { | ||
if (typeof node.config.triggertopic !== "undefined" | ||
&& node.config.triggertopic !== "" | ||
&& msg.hasOwnProperty("topic") && msg.topic !=="" | ||
&& node.config.triggertopic === msg.topic) | ||
{ | ||
SetResult(resAND, resOR, resXOR, node.config.topic); | ||
} | ||
node.status({ fill: "grey", shape: "ring", text: " Saved " + msg.hasOwnProperty("topic") ? msg.topic : "empty input topic"}); | ||
} else | ||
{ | ||
SetResult(resAND, resOR, resXOR, node.config.topic); | ||
} | ||
} | ||
@@ -75,0 +90,0 @@ else if(keyCount > node.config.inputCount ) { |
# node-red-contrib-boolean-logic-ultimate | ||
<p> | ||
<b>Version 1.0.0 LTS</b><br/> | ||
<b>Version 1.0.1</b><br/> | ||
- Added "trigger mode" option<br/> | ||
</p> | ||
<p> | ||
<b>Version 1.0.0</b><br/> | ||
- Added Filter node<br/> | ||
@@ -5,0 +9,0 @@ </p> |
{ | ||
"name": "node-red-contrib-boolean-logic-ultimate", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A set of Node-RED enhanced boolean logic, with persisten values after reboot and more", | ||
@@ -5,0 +5,0 @@ "author": "Supergiovane (https://github.com/Supergiovane)", |
@@ -19,2 +19,6 @@ # node-red-contrib-boolean-logic-ultimate | ||
## ADDITIONAL FUNCTIONS | ||
* Filter ouput results (outputs only true or trye/false) | ||
* Trigger mode selection (Can output a payload only by single input's topic trigger and after evaluation ot other inputs, or can oputput a payload by change of every input) | ||
## CHANGELOG | ||
@@ -35,2 +39,25 @@ * See <a href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/blob/master/CHANGELOG.md">here the changelog</a> | ||
<br/> | ||
<b>Trigger mode</b><br /> | ||
The node can acts ad a standard boolean logic or as single topic triggered boolean logic.<br/> | ||
As single topic triggered boolean logic, the node will evaluate the inputs (and thus will output a payload) only if a specified topic input arrives.<br/> | ||
In a coding perspectives, it acts as follows:<br/> | ||
<code> | ||
if (msg.topic == specified topic)<br/> | ||
{<br/> | ||
If (all other inputs are true) -> outputs true otherwise false<br/> | ||
}<br/> | ||
</code> | ||
<ol> | ||
<li>All topics: standard behaviour, the node will output <b>true</b> and <b>false</b> by evaluating all inputs. Each input change will trigger the node output.</li> | ||
<li>Single topic + eval other inputs: <u>only whenever the node receives a msg input with the <b>specified topic</b> (having payload = true)</u>, it starts the evaluation of all other inputs as well and outputs the evaluated payload. If the node receives a msg input other than the <b>specified topic</b>), it only retains it's value for the boolean evaluation.</li> | ||
</ol> | ||
Example of trigger mode = Single topic + eval other inputs | ||
```js | ||
[{"id":"4d2e4d1.4a02034","type":"BooleanLogicUltimate","z":"5635003e.2d70f","name":"","filtertrue":"both","persist":true,"triggertopic":"MotionSensor","outputtriggeredby":"onlyonetopic","inputCount":"3","topic":"result","x":460,"y":580,"wires":[["a9e93fa0.99508"],[],[]]},{"id":"b3a4633e.ff06c","type":"inject","z":"5635003e.2d70f","name":"","topic":"MotionSensor","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":560,"wires":[["4d2e4d1.4a02034"]]},{"id":"150ff8fd.8110e7","type":"inject","z":"5635003e.2d70f","name":"","topic":"Dusk","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":760,"wires":[["4d2e4d1.4a02034"]]},{"id":"6ecd73e1.9ac75c","type":"inject","z":"5635003e.2d70f","name":"","topic":"Rain","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":660,"wires":[["4d2e4d1.4a02034"]]},{"id":"350fb477.b0d484","type":"inject","z":"5635003e.2d70f","name":"","topic":"Dusk","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":800,"wires":[["4d2e4d1.4a02034"]]},{"id":"1118f46a.b967ac","type":"inject","z":"5635003e.2d70f","name":"","topic":"MotionSensor","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":600,"wires":[["4d2e4d1.4a02034"]]},{"id":"4e793dec.646b4c","type":"inject","z":"5635003e.2d70f","name":"","topic":"Rain","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":700,"wires":[["4d2e4d1.4a02034"]]},{"id":"a9e93fa0.99508","type":"debug","z":"5635003e.2d70f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":650,"y":580,"wires":[]},{"id":"8d44deef.e81d","type":"comment","z":"5635003e.2d70f","name":"Switch on the light only when it's raining and it's dusk. The trigger is someone entering in the Motion Sensor's area.","info":"Triggers only if someone enters \nin the motion sensor's area","x":410,"y":520,"wires":[]}] | ||
``` | ||
<br/><br/> | ||
<b>Remember latest input values after reboot</b><br /> | ||
@@ -50,2 +77,5 @@ 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/> | ||
<p> | ||
## OTHER NODES | ||
<b>Invert Ultimate</b><br /> | ||
@@ -55,2 +85,3 @@ Outputs the inverted input. For example true -> false | ||
<p> | ||
<b>Filter Ultimate</b><br /> | ||
@@ -57,0 +88,0 @@ This node has 2 outputs.<br /> |
Sorry, the diff of this file is not supported yet
30089
24.11%293
5.02%95
48.44%11
-8.33%