This packages provides an additional node in parser section. You can use it to transform properties describung boolean states. For example running or stopped (String) to 1 or 0 (int). Input values will be detected automatically.
Burgermenu on the right -> Manage palette -> Tab Install -> serach for node-red-contrib-boolean-parser -> press install
Run the following command in your Node-RED user directory - typically ~/.node-red
:
npm install node-red-contrib-boolean-parser
Running node-red in an docker environment this should do the job:
Enter container:
docker exec -it <containername> /bin/bash
Inside container run the following command in your Node-RED user directory - typically /data
:
npm install node-red-contrib-boolean-parser
Think of a device stating running and stopped. You want to send string like ON or OFF in MQTT, write values like 1 and 0 to influxDB show messages status like enabled and disabled and following nodes exept boolean values in inverted logic.
To be honest nearly every type tranformation can be realized by multiple switch and change nodes or function nodes having individual code (see example below). But to keep it simple, stable and universal it is easier to have a node handling this and you don't need to blow up your flows.
Nodes can be configured like this:
For detailed description of configuration settings see below.
A field of the message, which contains the value to be parsed. Sub-properties like msg.payload.state are also valid.
The logic can be inverted. An input detected as true
will be handled as false
and vice versa.
Default is false (no inversion).
If a value can't be treaten as true
or false
by comparing current input value to available formats
(see [Supportet output formats][]),
null
in case of strict input is enabledtrue
or false
automatically, case-insensitive, trimmed. Example: "foo" -> true
, "" -> false
Input values like undefined, unknown, invalid, null, NA, not-available, null
, undefined
, {}
, []
, ... will be handled as null
automatically.
If a value can't be treaten as true
or false
, (e.g. null
), it will be handled as defined by Handle null inputs:
A field of the message, which should be used for output. A existing field will be overwritten. Sub-properties like msg.payload.state are also valid.
for boolean true and false
There are two ways to send outgoing messages:
true
, false
, undefined
.All input values which represent a supportet output format are detected automatically. Additionally common rules try to evaluate values to true or false. Examples:
The last processed value is displayed as node status:
>
or !>
for inverted input#
if flow was stoppedSee JSON for import.
See [JSON](examples/Handle Null.json) for import.
See JSON for import.
There are several ways to contribute to this project. You can report bugs or ask for new features directly on GitHub. You can also submit your own new features of bug fixes via a pull request.
And of course you can always buy me a beer, coffee, ... via the donation button: