Debug node - incrementing ID

I'm currently using just 15 debug nodes in my flows, but because I use a lot of debugs temporarily, testing new ideas, learning, answering forum questions, etc, I'm already up to an ID of 2482 :grin:
Is there a way to order a re-numbering of the ID's, or is that number due to rise ad infinitum?

I of course realize that I could recycle the debug nodes, but I always like to keep my workspace clear, without orphaned nodes hanging around.

debug

1 Like

It just needs someone to write a simple flow that reads the flows file, finds all Debug nnn nodes and renumbers them sequentially. Someone here should be able to knock that up in 5 minutes.

The only state that would survive a restart would be the last un-named debug node in the flow. (unless it keeps it in the .config file, but i'm 99.99% sure it's not)

So if you name all your long term debug nodes and delete the rest I "think" it will start counting again from 1

2 Likes

When I do temporary work for test etc I always start with a clean flow - node-red testxxx.json, which leads to the other problem of having test1 - test 89 and dash1 - dash108 currently, and not remembering what any of them are, only that they are all "useful" - but at least the debugs and functions all start from 1 :slight_smile:

1 Like

@hardillb You are of course correct :grinning:

debug

Thank you

Here is a flow that reads a flows file, rationalises debug nodes that are named debug nnn and writes a new flows file with the renumbered nodes. Set the input and output path in the inject node, deploy it and click the inject.

If you are brave and trusting then you can set the output path to the input path and then you just have to restart node-red. However, if you are sane, you will instead write it to a new file, rename the old one, and replace it with the new one, then restart node-red.

[{"id":"2a1220f4e0f4ad64","type":"group","z":"bdd7be38.d3b55","name":"Rationalise debug node numbering","style":{"label":true},"nodes":["4cbc1bf30977dc4d","b6c70c743e51889d","8b2ca0887d7c0a3e","5b51b44a83135ec3","fefb82892cbc35d0","e60ea84d9655fc06","f6a6e6641bad366a"],"x":174,"y":3339,"w":972,"h":202},{"id":"4cbc1bf30977dc4d","type":"inject","z":"bdd7be38.d3b55","g":"2a1220f4e0f4ad64","name":"Configure paths in here","props":[{"p":"flowfilePath","v":"/full/path/to/flows.json","vt":"str"},{"p":"outPath","v":"/full/path/to//flows.new.json","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":320,"y":3380,"wires":[["b6c70c743e51889d"]]},{"id":"b6c70c743e51889d","type":"file in","z":"bdd7be38.d3b55","g":"2a1220f4e0f4ad64","name":"Read flow file","filename":"flowfilePath","filenameType":"msg","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":550,"y":3380,"wires":[["5b51b44a83135ec3"]]},{"id":"8b2ca0887d7c0a3e","type":"debug","z":"bdd7be38.d3b55","g":"2a1220f4e0f4ad64","name":"debug 14","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":910,"y":3500,"wires":[]},{"id":"5b51b44a83135ec3","type":"json","z":"bdd7be38.d3b55","g":"2a1220f4e0f4ad64","name":"","property":"payload","action":"","pretty":false,"x":750,"y":3380,"wires":[["fefb82892cbc35d0"]]},{"id":"fefb82892cbc35d0","type":"function","z":"bdd7be38.d3b55","g":"2a1220f4e0f4ad64","name":"Rationalise debug node names","func":"// msg.payload should include a flow file as an array of objects\nlet debugNumber = 1\nmsg.payload = msg.payload.map(rationalise) \nreturn msg;\n\nfunction rationalise(item) {\n    let answer = item\n    if (item.type === \"debug\") {\n        // check for name \"debug nnn\"\n        if (item.name.match(/debug [0-9]+$/)) {\n            //node.warn(`matching debug node found: ${JSON.stringify(item)}`)\n            // Change the name to an incrementing debug number\n            answer.name = `debug ${debugNumber++}`\n            //node.warn(`changed to: ${JSON.stringify(answer)}`)\n        }\n    }\n    return answer\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":3380,"wires":[["f6a6e6641bad366a"]]},{"id":"e60ea84d9655fc06","type":"file","z":"bdd7be38.d3b55","g":"2a1220f4e0f4ad64","name":"Write flow file","filename":"outPath","filenameType":"msg","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":730,"y":3460,"wires":[["8b2ca0887d7c0a3e"]]},{"id":"f6a6e6641bad366a","type":"json","z":"bdd7be38.d3b55","g":"2a1220f4e0f4ad64","name":"","property":"payload","action":"","pretty":true,"x":550,"y":3460,"wires":[["e60ea84d9655fc06"]]}]
4 Likes

Just my 2cents :wink:

Why are you not naming the debug nodes like any other node?

I use a nomenclature Tab(flow) Name.GroupName.DebugName

In the debug panel, you set the output to show

  • All Nodes
  • Selected Nodes
  • Current Flow

You can also double-click in the debug panel message on the node name, and it will take you to that node in that flow.

Screenshot 2024-10-01 at 2.18.23 PM
Screenshot 2024-10-01 at 2.18.18 PM

1 Like

Because I'm lazy!
If I want to know where the sidebar message originated, I can click on the message and the relevant node is highlighted, that's good enough for me.
It's good that you are so organised though.

3 Likes

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