Node-RED Nodes

repository·master·Indexed 21 days ago

https://github.com/node-red/node-red-nodes

A collection of official and community-contributed nodes for the Node-RED flow-based programming environment. This repository includes documentation for various utility nodes, including sentiment analysis (node-red-node-sentiment, node-red-node-multilang-sentiment), text filtering (node-red-node-badwords), part-of-speech analysis (node-red-node-wordpos), data generation (node-red-node-data-generator), PID control (node-red-node-pidcontrol), random number generation (node-red-node-random), and Report-By-Exception filtering (node-red-node-rbe).

Tokens
40.2K
Snippets
150
Records
262
Agent score
77%

What's inside node-red-nodes

  1. Use MongoDB input nodes to query data

    master

    Input nodes allow you to execute MongoDB collection methods. The results are returned in msg.payload.

    Supported Operators

    • Find: Queries a collection using msg.payload as the query statement. You can optionally control the result set using:
      • msg.projection: An object to constrain returned fields.
      • msg.sort: An object for sorting.
      • msg.limit: A number to limit results.
      • msg.skip: A number to skip results.
    • Count: Returns the number of documents matching the query in msg.payload.
    • Aggregate: Executes an aggregation pipeline using msg.payload as the pipeline array.

    Collection Selection

    You can specify the collection name in the node configuration or dynamically via msg.collection. The node configuration takes precedence and will override msg.collection.

  2. Use the Email Output node

    master

    The Output node sends an email using the following message properties:

    Core Properties:

    • msg.payload: The email body. Can be HTML. If it is a binary buffer, it will be sent as an attachment.
    • msg.topic: The email subject.
    • msg.to: The recipient (if not configured in the node settings).

    Additional Routing & Formatting:

    • msg.cc, msg.bcc, msg.replyTo, msg.inReplyTo, msg.references, msg.headers, msg.priority.
    • msg.from: The sender address. Note: Many services require this to be a valid user ID/email associated with the account.
    • msg.plaintext: Used to provide a plain text version if msg.payload is HTML.

    Attachments:

    • msg.filename: The name of the attachment.
    • msg.description: Optional body text for the attachment.
    • msg.attachments: An array of attachments in Nodemailer format.

    Connection Settings:

    • Use secure connection:
      • Enabled: Uses TLS when connecting. Recommended for port 465.
      • Disabled: Uses TLS only if the server supports the STARTTLS extension. Recommended for ports 587 or 25.
    • TLS/Certificates: If you use custom signed certificates and encounter errors, you may need to disable TLS.
  3. Use the Email Input node

    master

    The Input node fetches emails from an IMAP or POP3 server and forwards them as messages if they haven't been seen before.

    Message Properties Emitted:

    • msg.topic: The email subject.
    • msg.payload: The plain text body of the email.
    • msg.html: The HTML body (if available).
    • msg.from: The sender's email address.
    • msg.date: The email date.
    • msg.header: A complete header object containing properties like to, cc, etc.

    Authentication Note: Modern authentication via OAuth2.0 is supported but must be triggered by an incoming access token from upstream nodes.

  4. Use RBE mode to filter repeated messages

    master

    In RBE mode, the node only sends an output if the incoming msg.payload is different from the previous one. This mode works with both numbers and strings and is useful for saving bandwidth by filtering out repeated messages with the same value.

    Note that the node operates on a per msg.topic basis, meaning a single RBE node can track and filter multiple topics simultaneously.

  5. Use node-red-node-junction to support Node-RED 3.0+ flows in older versions

    master

    The junction node type was introduced in Node-RED 3.0.0. If you need to run flows that contain these junctions on older versions of Node-RED (version 2 or older), you can install the node-red-node-junction module.

    This module automatically detects the Node-RED version it is loaded into. It will only register the junction node type if it detects that it is running on Node-RED version 2 or older; on newer versions, it remains inactive to avoid conflicts with the core node.

  6. Use the Sense HAT Input Node

    master

    The Input Node emits sensor readings from the Sense HAT. Data is grouped into three distinct event types, each identified by a specific topic and payload structure.

    Motion Events

    • Topic: motion
    • Frequency: ~10 per second
    • Payload Object Keys:
      • acceleration.x/y/z: Acceleration intensity in Gs
      • gyroscope.x/y/z: Rotational intensity in radians/s
      • orientation.roll/pitch/yaw: Axis angle in degrees
      • compass: North direction in degrees

    Environment Events

    • Topic: environment
    • Frequency: ~1 per second
    • Payload Object Keys:
      • temperature: Degrees Celsius
      • humidity: Percentage of relative humidity
      • pressure: Millibars

    Joystick Events

    • Topic: joystick
    • Payload Object Keys:
      • key: One of UP, DOWN, LEFT, RIGHT, ENTER
      • state: 0 (released), 1 (pressed), or 2 (held down)
  7. Control pixels and sprites on the Unicorn HAT

    master

    The Unicorn HAT node uses msg.payload and msg.topic to manipulate pixels and independent 'sprites'.

    Drawing Pixels

    Set msg.payload to a CSV string in the format x,y,r,g,b.

    • x and y can be a single pixel (0 to 7), a range (e.g., 2-5), or * for a whole line.
    • You can send multiple pixels in one string: x1,y1,r1,g1,b1,x2,y2,r2,g2,b2,....

    Using Sprites

    A 'sprite' is a group of pixels that can be moved independently of the background.

    • Identify a sprite: Use msg.topic to name the sprite.
    • Delete a specific sprite: Set msg.payload to 0 for the sprite identified by msg.topic.
    • Delete all sprites: Set msg.payload to DEL (leaves the background intact).
    • Clear everything: Set msg.payload to CLS to turn off the display and delete all sprites.
    # Example pixel payload: x,y,r,g,b
    "0,0,255,0,0"
    
    # Example multiple pixel payload
    "0,0,255,0,0,1,1,0,255,0"
  8. Use the Sense HAT Input Node to receive sensor data

    master

    The Input Node emits sensor readings grouped into three event types. Note that Motion events are currently not supported by the simulator.

    Environment events

    Sent at approximately 1 per second. msg.topic is set to environment. Payload object keys:

    • temperature: degrees Celsius
    • humidity: percentage of relative humidity
    • pressure: Millibars

    Joystick events

    Sent when the joystick is interacted with. msg.topic is set to joystick. Payload object keys:

    • key: UP, DOWN, LEFT, RIGHT, or ENTER
    • state: 0 (released), 1 (pressed), or 2 (held down)
  9. Use Deadband and Narrowband modes for numeric filtering

    master

    Deadband and Narrowband modes are used to filter numeric data based on a specified threshold (band gap). The incoming msg.payload must be a number or a parseable string (e.g., "18.4 C" or "$500").

    Modes

    • Deadband mode: The node outputs the value only if it has changed by more than the specified band gap (absolute or percentage) away from the previous value.
    • Narrowband mode: The node blocks the output if the incoming value change is greater than the specified band gap. This is useful for ignoring outliers from faulty sensors.

    Comparison Logic

    You can choose how the node compares the current value to previous values:

    • Compare with previous valid output value: Ignores any values that fall outside the valid range. This is useful for maintaining a stable baseline.
    • Compare with previous input value: Allows two consecutive "bad" readings to reset the range. This is useful for handling valid step changes that might otherwise be flagged as outliers.

    Band Gap Configuration

    The band gap can be defined in two ways:

    • Fixed number: A constant absolute value.
    • Percentage: A percentage of the previous value. For example, if the last sent value was 100 and the deadband is set to 10%, the next value must be at least 110 to pass. The subsequent value must then be at least 121 (110 + 10%) to pass.