{"id":27990,"library":"node-red-contrib-toggle","title":"node-red-contrib-toggle","description":"Toggle switch node for Node-RED that stores state and provides ON/OFF/toggle operations without function nodes or flow variables. Version 0.1.1 is current. Configuration supports string, number, or boolean payloads, optional topic filtering, and three pass-through modes: never, on change, or always. Output msg forwards on valid command with state indicated by node status (green/red dot). Compatible with Node-RED 1.x+. Differentiators: no coding required, state persistence across flows, simple visual interface.","status":"active","version":"0.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/eschava/node-red-contrib-toggle","tags":["javascript","node","node-red","toggle","switch","power"],"install":[{"cmd":"npm install node-red-contrib-toggle","lang":"bash","label":"npm"},{"cmd":"yarn add node-red-contrib-toggle","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-red-contrib-toggle","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: requires Node-RED runtime to install and run nodes.","package":"node-red","optional":false}],"imports":[{"note":"Node-RED nodes are CommonJS modules; ESM import may not work depending on Node-RED version.","wrong":"const toggle = require('node-red-contrib-toggle');","symbol":"default","correct":"import toggle from 'node-red-contrib-toggle';"},{"note":"Node-RED runtime object required for node registration.","wrong":"","symbol":"RED","correct":"const RED = require('node-red');"},{"note":"Node-RED uses CommonJS and registerType, not ES modules.","wrong":"export function toggleNode() {}","symbol":"toggleNode","correct":"RED.nodes.registerType('toggle', toggleNode);"}],"quickstart":{"code":"// Example: Create a flow using node-red-contrib-toggle\n// 1. Install: npm install node-red-contrib-toggle\n// 2. In Node-RED UI, drag a 'toggle' node onto canvas\n// 3. Configure: set ON value to true, OFF value to false, Toggle value to 'toggle'\n// 4. Connect an inject node (msg.payload = true) to turn on\n// 5. Connect another inject node (msg.payload = 'toggle') to toggle\n// 6. Deploy and see green dot when on, red when off.","lang":"javascript","description":"Basic installation and usage of toggle node with inject nodes."},"warnings":[{"fix":"Ensure msg.topic matches the 'On/Off topic' or 'Toggle topic' if configured, or leave topic fields empty.","message":"Node only processes messages if msg.topic matches configured topic (if set). Incoming messages without matching topic are ignored silently.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always configure both ON and OFF values if you need both operations.","message":"If ON value or OFF value is not set, the corresponding command is ignored. Node will not switch to that state.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"","message":"No known deprecations in version 0.1.1.","severity":"deprecated","affected_versions":"0.1.1"},{"fix":"Check release notes or source history for changes.","message":"Breaking changes between versions may exist but are undocumented due to early stage.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Choose pass-through mode based on desired behavior: use 'Always' for immediate feedback, 'If changed' for state change only, 'No' for toggle-only.","message":"Pass-through modes: 'No' only outputs on toggle; 'If changed' outputs ON/OFF only if state changes; 'Always' outputs every valid input. Misunderstanding leads to missing outputs.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"cd ~/.node-red && npm install node-red-contrib-toggle","cause":"Package not installed in Node-RED user directory (~/.node-red) or global.","error":"Error: Cannot find module 'node-red-contrib-toggle'"},{"fix":"Ensure node is loaded within Node-RED via standard node discovery; do not require() from standalone script.","cause":"Node-RED runtime not initialized before attempting to register node.","error":"TypeError: Cannot read property 'registerType' of undefined"},{"fix":"Restart Node-RED; verify package.json has 'node-red' in 'keywords' or 'node-red' section.","cause":"Node-RED not restarted or dependencies missing.","error":"Node not appearing in palette after install"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}