Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
Massimo f888b843b9 . 5 lat temu
boolean-logic-ultimate . 5 lat temu
.gitattributes Initial commit 5 lat temu
.gitignore Fixed persistent state deletion upon node update/delete 5 lat temu
CHANGELOG.md Node status adjustmend 5 lat temu
LICENSE Update LICENSE 5 lat temu
README.md . 5 lat temu
package-lock.json LTS + added Filter node 5 lat temu
package.json Node status adjustmend 5 lat temu

README.md

node-red-contrib-boolean-logic-ultimate

NPM version NPM downloads per month NPM downloads total MIT License JavaScript Style Guide Donate via PayPal

DESCRIPTION

The node performs Boolean logic on the incoming payloads.
The node performs 3 checks (AND,OR,XOR) on the incoming boolean payloads and outputs the result at the same time, as follow:

  • Output “AND”: true or false
  • Output “OR”: true or false
  • Output “XOR”: true or false

The node can have a persistent input: 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.

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

CONFIGURATION

The node expects a fixed number of topics (configured in the settings) on which it will operate. It will only output a value when it has seen the expected number of topics. If it ever sees more than the configured number of topics it will log a message then reset its state and start over.
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.

Filter output result

  1. Output both 'true' and 'false' results: Standard behaviour, the node will output true and false whenever it receives an input and calculate the boolean logics as output.
  2. Output only 'true' results: whenever the node receives an input, it outputs a payload true only if the result of the logic is true. False results are filtered out.

Trigger mode
The node can acts ad a standard boolean logic or as single topic triggered boolean logic.
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.
In a coding perspectives, it acts as follows:
if (msg.topic == specified topic)
{
If (all other inputs are true) -> outputs true otherwise false
}
  1. All topics: standard behaviour, the node will output true and false by evaluating all inputs. Each input change will trigger the node output.
  2. Single topic + eval other inputs: only whenever the node receives a msg input with the specified topic (having payload = true), 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 specified topic), it only retains it's value for the boolean evaluation.
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":[]}] ```

Remember latest input values after reboot
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.
Every time you modify the node's config, the retained values are cleared.

All incoming msg.payloads are converted into a boolean value according to the following rules (this applies to all boolean logic nodes):
  1. Boolean values are taken as-is.
  2. For numbers, 0 evaluates to false, all other numbers evaluates to true.
  3. Strings are converted to numbers if they match the format of a decimal value, then the same rule as for numbers are applied. If it does not match, it evaluates to false. Also, the string "true" evaluates to true.

The XOR operation operates in a one, and only one mode, i.e. (A ^ B) ^ C ... ^ n

## OTHER NODES Invert Ultimate
Outputs the inverted input. For example true -> false

Filter Ultimate
This node has 2 outputs.
If the input payload is true, the node will send true on output 1 and nothing on oputput 2
If the input payload is false, the node will send nothing on output 1, and false on oputput 2