Looking for a node with a button like the inject and debug nodes

Hello,
I'm trying to develop and debug a complex flow and am looking for a simple way to enable or disable parts of the flow (without the disable/deploy actions).

I like the UI of the Inject and Debug nodes, and want something that passes messages if the node is enabled (via a button).

Is there a similar node (with a button) that passes a message if its button is enabled?

alternate question

How can I configure a debug node passthrough a message?

Steve

Have a look at node-red-contrib-simple-gate (node) - Node-RED
This should do the trick for you.

The gate node in conjunction with two Inject nodes is the way to do it.

You can't, just wire round it.

image

Yes, but this will execute the subsequent nodes regardless of whether I'm debugging.

Yes it will.

Did you check if node-red-debugger fulfills your demands?

Thanks' edje11 , that pointed me in the right direction.

I prefer not adding nodes, but the answers here and reviewing the node helped me to find my own solution.

[{"id":"76cf0836193ab9eb","type":"group","z":"560a48e311b7eb68","name":"Block or Enable messages to flow","style":{"stroke":"#6f2fa0","fill":"#dbcbe7","label":true,"color":"#000000"},"nodes":["36cb18b26d858526","16d906f2c36a0d37","44e1f702b6d85138","126349533dc29422","401b37ac4d521152","099ae275e7016813","f3a75c2f2eecb8e5","312034a2180d9905","465f5a4e3452cd18","b31e594af6f2b7e8"],"x":154,"y":3919,"w":992,"h":222},{"id":"36cb18b26d858526","type":"inject","z":"560a48e311b7eb68","g":"76cf0836193ab9eb","name":"close","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"closed","payloadType":"str","x":250,"y":3960,"wires":[["099ae275e7016813"]]},{"id":"16d906f2c36a0d37","type":"inject","z":"560a48e311b7eb68","g":"76cf0836193ab9eb","name":"open","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"open","payloadType":"str","x":250,"y":4000,"wires":[["099ae275e7016813"]]},{"id":"44e1f702b6d85138","type":"inject","z":"560a48e311b7eb68","g":"76cf0836193ab9eb","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"class\": \"red\", \"size\": 1, \"returnable\": true}","payloadType":"json","x":250,"y":4100,"wires":[["b31e594af6f2b7e8"]]},{"id":"126349533dc29422","type":"switch","z":"560a48e311b7eb68","g":"76cf0836193ab9eb","name":"Stop when closed","property":"payload.state","propertyType":"msg","rules":[{"t":"eq","v":"closed","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":750,"y":4100,"wires":[[],["401b37ac4d521152"]]},{"id":"401b37ac4d521152","type":"debug","z":"560a48e311b7eb68","g":"76cf0836193ab9eb","name":"Debug when open","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1010,"y":4100,"wires":[]},{"id":"099ae275e7016813","type":"function","z":"560a48e311b7eb68","g":"76cf0836193ab9eb","name":"Save env.state","func":"\nflow.set('state', msg.payload);\n\nmsg.payload = flow.get('state')\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":3960,"wires":[["f3a75c2f2eecb8e5"]]},{"id":"f3a75c2f2eecb8e5","type":"debug","z":"560a48e311b7eb68","g":"76cf0836193ab9eb","name":"State","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":710,"y":3960,"wires":[]},{"id":"312034a2180d9905","type":"inject","z":"560a48e311b7eb68","g":"76cf0836193ab9eb","name":"Query state","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"${state}","payloadType":"env","x":270,"y":4040,"wires":[["465f5a4e3452cd18"]]},{"id":"465f5a4e3452cd18","type":"function","z":"560a48e311b7eb68","g":"76cf0836193ab9eb","name":"Get env.state","func":"\nmsg.payload = flow.get('state')\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":4000,"wires":[["f3a75c2f2eecb8e5"]]},{"id":"b31e594af6f2b7e8","type":"function","z":"560a48e311b7eb68","g":"76cf0836193ab9eb","name":"Inject env.state","func":"\nmsg.payload.state = flow.get('state')\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":4100,"wires":[["126349533dc29422"]]}]

thanks for the replies

You could use a flow context variable and a switch node.

Ah yes, that makes it cleaner.

[{"id":"8aad15f1d1a9acda","type":"group","z":"560a48e311b7eb68","name":"Block or Enable messages to flow","style":{"stroke":"#6f2fa0","fill":"#dbcbe7","label":true,"color":"#000000"},"nodes":["f7216dd244dbc547","862ef72ed4f658a5","79e72b836d5bbfe2","c4e8bd36d12cad8b","06645f8b54715159","3500426c63d0c9f4","1bf877be9626839f","7e142f51c44d7419","280dec3cdd28bdc2","564967cd7bd5b02c"],"x":174,"y":4339,"w":792,"h":222},{"id":"f7216dd244dbc547","type":"inject","z":"560a48e311b7eb68","g":"8aad15f1d1a9acda","name":"Debug=true","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":290,"y":4380,"wires":[["1bf877be9626839f"]]},{"id":"862ef72ed4f658a5","type":"inject","z":"560a48e311b7eb68","g":"8aad15f1d1a9acda","name":"Debug=false","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":290,"y":4420,"wires":[["7e142f51c44d7419"]]},{"id":"79e72b836d5bbfe2","type":"inject","z":"560a48e311b7eb68","g":"8aad15f1d1a9acda","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"class\": \"red\", \"size\": 1, \"returnable\": true}","payloadType":"json","x":270,"y":4520,"wires":[["c4e8bd36d12cad8b"]]},{"id":"c4e8bd36d12cad8b","type":"switch","z":"560a48e311b7eb68","g":"8aad15f1d1a9acda","name":"Pass when debugging","property":"debug","propertyType":"flow","rules":[{"t":"true"}],"checkall":"false","repair":false,"outputs":1,"x":540,"y":4520,"wires":[["280dec3cdd28bdc2"]]},{"id":"06645f8b54715159","type":"debug","z":"560a48e311b7eb68","g":"8aad15f1d1a9acda","name":"State","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"\"Debugging \" & msg.payload","statusType":"jsonata","x":770,"y":4380,"wires":[]},{"id":"3500426c63d0c9f4","type":"inject","z":"560a48e311b7eb68","g":"8aad15f1d1a9acda","name":"Query debug","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":290,"y":4460,"wires":[["564967cd7bd5b02c"]]},{"id":"1bf877be9626839f","type":"change","z":"560a48e311b7eb68","g":"8aad15f1d1a9acda","name":"","rules":[{"t":"set","p":"debug","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":4380,"wires":[["06645f8b54715159"]]},{"id":"7e142f51c44d7419","type":"change","z":"560a48e311b7eb68","g":"8aad15f1d1a9acda","name":"","rules":[{"t":"set","p":"debug","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":4420,"wires":[["06645f8b54715159"]]},{"id":"280dec3cdd28bdc2","type":"debug","z":"560a48e311b7eb68","g":"8aad15f1d1a9acda","name":"Only when flow.debug=true","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":4520,"wires":[]},{"id":"564967cd7bd5b02c","type":"change","z":"560a48e311b7eb68","g":"8aad15f1d1a9acda","name":"get flow.debug","rules":[{"t":"set","p":"payload","pt":"msg","to":"debug","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":4460,"wires":[["06645f8b54715159"]]}]

Thanks' everyone

And to tidy up debugging on your complex flow you can use a link out node.

image

If you use a global context variable the link in etc can be on a seperate tab. Then to debug at any point you just need to insert a link-out.

1 Like

Or a subflow gate that can be toggled with a control message inject node, and can be named to lock multiple with same named toggle_pass subflows environment variable at same time.
e,g,

[{"id":"2a40819a70e49c9a","type":"subflow","name":"toggle pass","info":"","category":"","in":[{"x":40,"y":160,"wires":[{"id":"9ad7eb17b887a806"}]}],"out":[{"x":740,"y":160,"wires":[{"id":"9ad7eb17b887a806","port":0}]}],"env":[{"name":"name","type":"str","value":"default","ui":{"label":{"en-US":"name"},"type":"input","opts":{"types":["str"]}}}],"meta":{},"color":"#DDAA99","status":{"x":420,"y":240,"wires":[{"id":"9ad7eb17b887a806","port":1}]}},{"id":"9ad7eb17b887a806","type":"function","z":"2a40819a70e49c9a","name":"function 152","func":"let pass = global.get(\"toggle_pass.\" + env.get(\"name\") ) ??  true\nif(msg.control){\n    if(msg.control === \"toggle\"){\n        pass = !pass;  \n    }else if(msg.control === \"startup\"){\n    }\n    msg = null;\n    global.set(\"toggle_pass.\" + env.get(\"name\"), pass);\n}\nif(!pass){\n   msg = null\n}\nlet msg1 = {\n    payload:{\n        fill: pass ? \"green\" : \"red\", \n        shape: \"dot\"\n    }\n}\nreturn [msg, msg1];","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":160,"wires":[[],[]]},{"id":"881626a80c2af3a8","type":"inject","z":"2a40819a70e49c9a","name":"","props":[{"p":"control","v":"startup","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":150,"y":80,"wires":[["9ad7eb17b887a806"]]},{"id":"2e946fdc95a718cf","type":"inject","z":"d1395164b4eec73e","name":"toggle","props":[{"p":"control","v":"toggle","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":370,"y":5280,"wires":[["c0ac81aa744bde13"]]},{"id":"2f495e9cbbb9e473","type":"debug","z":"d1395164b4eec73e","name":"debug 2476","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":5320,"wires":[]},{"id":"3e66623a917ea369","type":"inject","z":"d1395164b4eec73e","name":"message","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":5340,"wires":[["c0ac81aa744bde13","d346cae4c36d61d5","2dbea1203762970c"]]},{"id":"c0ac81aa744bde13","type":"subflow:2a40819a70e49c9a","z":"d1395164b4eec73e","name":"","x":390,"y":5320,"wires":[["2f495e9cbbb9e473"]]},{"id":"d346cae4c36d61d5","type":"subflow:2a40819a70e49c9a","z":"d1395164b4eec73e","name":"","env":[{"name":"name","value":"name1","type":"str"}],"x":410,"y":5400,"wires":[["45431aedcf78e6da"]]},{"id":"2dbea1203762970c","type":"subflow:2a40819a70e49c9a","z":"d1395164b4eec73e","name":"","x":410,"y":5460,"wires":[["4a5e3668707d90ef"]]},{"id":"5213c0261058d98d","type":"inject","z":"d1395164b4eec73e","name":"toggle","props":[{"p":"control","v":"toggle","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":430,"y":5360,"wires":[["d346cae4c36d61d5"]]},{"id":"45431aedcf78e6da","type":"debug","z":"d1395164b4eec73e","name":"debug 2477","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":5400,"wires":[]},{"id":"4a5e3668707d90ef","type":"debug","z":"d1395164b4eec73e","name":"debug 2478","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":5460,"wires":[]}]
1 Like

That's an eloquent approach :+1:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.