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-multi-sensor

v2.0.3

Published

A Node-RED multiple binary-sensor linker

Downloads

88

Readme

node-red-contrib-multi-sensor

Binary motion sensor and activation state machine node for Node-red.

This node is a companion for any binary sensor (physical or virtual), storing all recieved sensors and their state and merge them into a single node.

node-appearance
Fig. 1: Node appearance

Installation

In Node-RED (preferred)

  • Via Manage Palette -> Search for "node-red-contrib-multi-sensor"

In a shell

  • go to the Node-RED installation folder, e.g.: ~/.node-red
  • run npm install node-red-contrib-multi-sensor

Usage

node-explain Fig. 2: Node explaination

To give an understanding on how the node works, we can take a look at this where you have three sensors that will enter a registration object that will store data about all sensors. Then it continues to check if any changes has been made to the state, if so, we check if we're active or inactive. We need to ensure that the opposite timer is reset (if we use one). This flow is merged down into a single node to ease and speed up the view.

node-appearance
Fig. 3: Node appearance

The node has two or three output channels (by default, it uses two). The last output channel here is the "status" channel, this one informs about the current state. These states matches the structure: {"id":x, "name":name}

The different id's are:

  • 0: Inactive
  • 1: Active
  • 2: Activating
  • 3: Deactivating
  • 32: Sensor change
  • 65: Timeout
  • 66: Reset
  • 130: Abort activation
  • 131: Abort deactivation

Node Configuration

The node configuration sets up how the sensor should react.

node-settings
Fig. 4: Node properties

Name (optional)

(Optional) The name of this node. (Will change the content of the node to the name)

Identifier

The data field that should be used to uniquely identify a sensor. Each sensor should have their own unique identifier that this node can use as an id to differentiate it from each other.

Input

The value to read and validate against the Activate on and Deactivate on values.

  • If the input value doesn't match any of the two values, it will be ignored.
  • If matches the Activate on value, it will use the Identifier to create a record with an active flag.
  • If matches the Deactivate on value, it will try to find an already created record with the current Identifier to deactivate the flag.

Activate on / Deactivate on

The input value needs to match one of these fieds to trigger an action. As explained for the input field, the activation and deactivion will only take place if matching one of these fields.

Send on active

As soon as a message where the input matches the Activate on value, will trigger the activation of the node. The data specified in this field will then be sent, either directly or when Activate delay time has passed (If not being deactivated before, then the activation will be canceled out).

Send on inactive

When the last active sensor record is received and its input value matches the Deactivate on value, the deactivation of the node will be executed. The data specified in this field will then be sent, either directly or when Deactivate delay time has passed (If not a sensor is being activated again, then the deactivation will be canceled out).

Activate delay / Deactivate delay

The delays are there to enable a latency between the actual event and the message being sent. You can here choose if to directly send the message when activated/deactivated (set to zero), or wait a specified amount.

Sensor timeout

The time to wait when a sensor getting active before automatically deactivate it. (Zero, means no timeout.)

Active timeout

The time to wait when the node getting active before automatically deactivate it and all its active sensors. (Zero, means no timeout.)

Send sensor count state

If checked, the status channel will include the number of sensors currently active (this will include counting the active sensors and also include the 32 value (6th bit) sent out, causing some extra traffic).

Seperated outputs

If checked, there will be a different channel for the deactivation messages. Otherwise, if unchecked, the activation and deactivation messages will be sent through the same output channel.

Node reset

There's two different reset models implemented:

  • soft: Will deactivate any active sensor and return to idle state with or without delays as configured.
  • hard: Will force a direct deactivation of all active sensors and return to idle state without any delays.

To use this, you can send the *msg.reset='soft' (or actually anything other than false or 'hard') to make a soft reset. or emsg.reset='hard' to make a hard reset.

Node status

The node has a default status behavior that will explain the number of found sensors as well as current state (active, inactive or pending by delay). The status can be overridden by usage of the msg.status field.

Examples


Remark: Example flows are present in the examples subdirectory. In Node-RED they can be imported via the import function and then selecting Examples in the vertical tab menu.


Example 1: Basic usage

This example shows the basic usage.
The configuration simulates two different sensors and gives you the option to manually activate and deactive the sensors to try out the functionality.

example-1.json
Fig. 5: Basic usage example

Version history

  • v2.0.2 Fixed bug with object sub staged after refactorization.
  • v2.0.0 Breaking change when output native values (booleans, numbers, strings). Now they're contained in {payload:[value]} previously the value was sent direclty.
  • v1.0.0 Completed documentation and translations
  • v0.1.0 Initial release

Credits