{"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,"search_vec":"'0.1.1':27 '1':70 'across':78 'alway':50 'boolean':35 'chang':48 'code':74 'command':56 'compat':65 'configur':30 'contrib':4 'current':29 'differenti':72 'dot':64 'filter':39 'flow':24,79 'forward':53 'function':21 'green/red':63 'indic':59 'interfac':82 'javascript':83 'mode':45 'msg':52 'never':46 'node':2,8,11,22,61,68,84,86 'node-r':10,67,85 'node-red-contrib-toggl':1 'number':33 'on/off/toggle':18 'oper':19 'option':37 'output':51 'pass':43 'pass-through':42 'payload':36 'persist':77 'power':90 'provid':17 'red':3,12,69,87 'requir':75 'simpl':80 'state':15,58,76 'status':62 'store':14 'string':32 'support':31 'switch':7,89 'three':41 'toggl':5,6,88 'topic':38 'valid':55 'variabl':25 'version':26 'visual':81 'without':20 'x':71","created_at":"2026-05-09T05:53:09.220505+00:00","updated_at":"2026-05-09T05:53:09.220505+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/eschava/node-red-contrib-toggle","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/node-red-contrib-toggle","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-09","next_check":"2026-08-07","install_tag":null}}