node-red-contrib-bool-gate
Node RED node to include boolean logic gates.
Installation
$ npm install node-red-contrib-bool-gate
Restart Node-RED and use the node!
Or from the Node-RED's palette, search for "node-red-contrib-bool-gate
Boolean condition
If you know how the boolean logic work, you can skip this section.
The boolean logic is a way to determine a condition regarding to the input.
Condition A | Condition B | AND | NAND | OR | NOR | XOR | XNOR |
---|
false | false | false | true | false | true | false | true |
false | true | false | true | true | false | true | false |
true | false | false | true | true | false | true | false |
true | true | true | true | true | false | false | true |
You can do it to for more than 2 condition :
Condition A | Condition B | Condition C | AND | NAND | OR | NOR | XOR | XNOR |
---|
false | false | false | false | true | false | true | false | true |
false | false | true | false | true | true | false | true | false |
false | true | false | false | true | true | false | true | false |
false | true | true | false | true | true | false | false | true |
true | false | false | false | true | true | false | true | false |
true | false | true | false | true | true | false | false | true |
true | true | false | false | true | true | false | false | true |
true | true | true | true | false | true | false | false | true |
You can follow this link to learn more about the boolean logic.
Usage
Notion of Rules
A rule can be read from top, like :
<TOPIC><PROPERTY><CONDITION><VALUE>
with topic, the topic of incomming message (if needed), property to perform the test, condition the condition you want for the property and value the value you want for the property (if needed).
You can pick property from everywhere :
- from the incomming message
- from the flow context
- from the global context
The following condition are implemented :
- ==
- !=
- <
- <=
- >
- >=
- is between
- contains
- match regex
- is true
- is false
- is null
- is not null
You can pick value from the following type (depending on your condition) :
- number
- string
- message's property
- flow's property
- global's property
- regex
- previous value
Configuration
Please take you time to create your gate, by following these steps :
- Select the type of gate you want for your node (between AND and NAND for the and-gate and OR, NOR, XOR and XNOR for the or-gate)
- Tick the "True restriction" checkbox if you want to have output only when the gate is at true state.
- Fill if needed the "Input message topic" input to filter your incomming message
- Select the property you need to check (Default : msg, assuming you defined the input message topic)
- Select the condition(Defautl : =)
- Type the value you want for your property, assuming you picked up the correct type
- Add a rule by cliking on + add below the list, and repeat the procedure
See the node information for more details