Simple Gate
raw JSON → 0.5.2 verified Sat Apr 25 auth: no javascript
A Node-RED gate node that controls message flow by opening or closing a gate. Current stable version is 0.5.2, released with support for asynchronous context stores and improved persistence. Key differentiators: allows user-defined control topic and command strings, supports toggle and status commands, and can restore state from persistent context stores if available. Cannot queue messages; for queuing, use the companion node-red-contrib-queue-gate package. Compatible with Node-RED 0.18+.
Common errors
error Error: Cannot find module 'node-red-contrib-simple-gate' ↓
cause Node-RED cannot locate the package because it was not installed correctly or is in the wrong directory.
fix
Navigate to your Node-RED user directory (typically ~/.node-red) and run: npm install node-red-contrib-simple-gate
error Gate node not showing in palette ↓
cause Node-RED needs to be restarted after installation, or the palette may not be updated.
fix
Restart Node-RED and check the palette manager. If still missing, try installing via Manage Palette in the editor.
error TypeError: Cannot read property 'on' of undefined ↓
cause Node-RED version is too old (pre-0.18) and incompatible with this node.
fix
Upgrade Node-RED to version 0.18 or higher.
Warnings
breaking State persistence: versions prior to 0.5.0 used only the default context store, which might be volatile. After upgrade, if using non-default stores, persistence may fail. ↓
fix Upgrade to 0.5.0 or later and configure appropriate context store in Node-RED settings.
breaking Support for asynchronous context stores was added in 0.5.2; older versions may not work with async stores. ↓
fix Use version 0.5.2 or later.
breaking Not compatible with Node-RED version 0.18 and earlier. ↓
fix Upgrade Node-RED to 0.18+ or use a different gate node.
gotcha Messages that arrive when the gate is closed are discarded without warning; there is no queue or buffer. ↓
fix Use node-red-contrib-queue-gate if you need queuing.
gotcha Control messages with payloads that are numbers or booleans are converted to strings before comparison; this may cause unexpected behavior if command strings are numeric. ↓
fix Ensure control message payloads are strings, or verify numerical equivalence.
Install
npm install node-red-contrib-simple-gate yarn add node-red-contrib-simple-gate pnpm add node-red-contrib-simple-gate Imports
- gate wrong
Attempting to import JS module: const gate = require('node-red-contrib-simple-gate')correctInstall via npm: npm install node-red-contrib-simple-gate (then use the 'gate' node in the editor palette)
Quickstart
// No code example; this is a Node-RED node.
// To use: Install the package, then add a 'gate' node from the palette.
// Configure control topic and command strings in the node edit dialog.
// Send control messages with payload 'open', 'close', 'toggle', etc. on the control topic to change state.