npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-contrib-boolean-parser

v1.4.6

Published

A Node-RED node to parse and convert several types of on/off, start/stop, true/false values.

Downloads

210

Readme

node-red-contrib-boolean-parser

A Node-RED node to parse, convert and format several types of on/off, start/stop, true/false values.

Platform License Downloads Total Downloads NPM Known Vulnerabilities Package Quality Open Issues Closed Issues


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.

node-appearance

Install

Webend

Burgermenu on the right -> Manage palette -> Tab Install -> serach for node-red-contrib-boolean-parser -> press install

CLI

Run the following command in your Node-RED user directory - typically ~/.node-red:

npm install node-red-contrib-boolean-parser

Docker

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

Usage

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.

Compared traditional way to change values.

Nodes can be configured like this:

Node Configuration

For detailed description of configuration settings see below.

Input field

A field of the message, which contains the value to be parsed. Sub-properties like msg.payload.state are also valid.

Invert input

The logic can be inverted. An input detected as true will be handled as false and vice versa.

Default is false (no inversion).

Strict input

If a value can't be treaten as true or false by comparing current input value to available formats (see [Supportet output formats][]),

  • it will be handled as null in case of strict input is enabled
  • it will try to treat to true or false automatically, case-insensitive, trimmed. Example: "foo" -> true, "" -> false

Handle null inputs

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:

  • keep as null
  • treat as true
  • treat as false
  • stop flow

Output field

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.

Supportet output formats

for boolean true and false

  • true / false
  • "true" / "false"
  • "True" / "False"
  • "TRUE" / "FALSE"
  • 1 / 0
  • "1" / "0"
  • "start" / "stop"
  • "started" / "stopped"
  • "enable" / "disable"
  • "enabled" / "disabled"
  • "activated" / "deactivated"
  • "active" / "inactive"
  • "running" / "stopped"
  • "run" / "stop"
  • "on" / "off"
  • "On" / "Off"
  • "ON" / "OFF"

Different outputs

There are two ways to send outgoing messages:

  1. A combined single output sending all messages.
  2. Three split outputs, sending messages, seperated by true, false, undefined.

Output: Single, split

Input formats

All input values which represent a supportet output format are detected automatically. Additionally common rules try to evaluate values to true or false. Examples:

  • "foobar" -> true
  • "" -> false
  • 42 -> true

Output status

The last processed value is displayed as node status:

  • Color: true (green), false (red) or null (grey)
  • Text:
    • input value
    • > or !> for inverted input
    • output value or # if flow was stopped

Node status

Examples

Input and output formatsĸ

Example: Several inputs and output conversion

See JSON for import.

Null handling

Example: Different undefined inputs and conversion strategies

See [JSON](examples/Handle Null.json) for import.

Split outputs

Example: Single vs split outputs

See JSON for import.

Known Issues

Contribute

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:

donate

License

MIT