Node-RED Smoothing Algorithms Node
node-red-node-smooth is a Node-RED package providing a collection of simple smoothing algorithms for processing incoming numerical data. It includes functions like Minimum, Maximum, Mean, Standard Deviation, High Pass, and Low Pass smoothing. The current stable version, 0.8.0, was released approximately a year ago, indicating an active but not rapid release cadence. This node is specifically designed for the Node-RED environment, a low-code programming platform for event-driven applications, differentiating it from general-purpose JavaScript libraries. Its primary strength lies in its direct integration into Node-RED flows, allowing users to easily incorporate data smoothing into their visual programming logic without writing complex code. It operates exclusively on numerical inputs and can reset its internal state via a `msg.reset` message.
Common errors
-
Input value is not a number and cannot be processed by the smooth node.
cause The node received a message where the payload (or configured property) was not a valid number, and could not be converted to one.fixEnsure that the `msg.payload` or the property configured for smoothing is always a number. Use a 'Change' or 'Function' node upstream to convert or filter non-numeric inputs.
Warnings
- gotcha This node strictly operates only on numbers. Any non-numeric input will be internally coerced to a number if possible, and if coercion fails, the message will be rejected. Always ensure `msg.payload` (or configured property) contains a valid number.
- gotcha The 'High Pass Smoothing' and 'Low Pass Smoothing' algorithms use a 'smoothing factor' which is inversely analogous to an alpha value (α). A higher smoothing factor means more smoothing, where a factor of 10 is similar to α=0.1. This can be counter-intuitive for users familiar with alpha (0 to 1) values in exponential smoothing.
- gotcha Sending a message with `msg.reset` (with any value) to the node will clear all internal counters and intermediate values, effectively restarting the smoothing process. This is useful for re-initializing state but can lead to unexpected output if triggered unintentionally.
Install
-
npm install node-red-node-smooth -
yarn add node-red-node-smooth -
pnpm add node-red-node-smooth
Imports
- Node-RED Node (Smooth)
import { smooth } from 'node-red-node-smooth'Install via npm: npm install node-red-node-smooth Then add 'smooth' node from the palette in Node-RED editor.
- Node-RED Node Definition
require('node-red-node-smooth')// In a custom Node-RED node .js file (e.g., ~/.node-red/nodes/my-smooth-node.js) module.exports = function(RED) { function SmoothNode(config) { RED.nodes.createNode(this, config); // ... node logic ... } RED.nodes.registerType('smooth', SmoothNode); }
Quickstart
npm install node-red-node-smooth # After installation, restart Node-RED if it's running. # Open your Node-RED editor (usually at http://localhost:1880). # Drag the 'smooth' node from the palette (under 'function' or 'data-and-analytics' category) onto your flow. # Configure the node by double-clicking it, selecting a smoothing algorithm (e.g., 'Mean'), and setting parameters like window size or smoothing factor. # Connect an 'inject' node to its input to send numerical data (e.g., `msg.payload = 10`). # Connect a 'debug' node to its output to view the smoothed results. # Deploy the flow and observe the output in the debug sidebar.