Inject node - paste in output from debug node

I haven't found anything in the community on this so I'm either asking for pointers or making a feature request.

For debugging purposes I wanted to "replay" a couple messages from an external source. I had a debug node output the complete message, copied it, and tried several permutations of pasting it into an inject node but the message was always wrong in some way depending on the manner I tried. I got what I want by pasting the message into a function node and triggering it with an inject node but it seems to me this replaying captured messages is a common need and should be supported directly in the inject node.

Somebody enlighten me, please.

Hi, you could try storing it as a txt file and then reading it with the file node.

Sure, but what would be the point? That feels like even more of a kludge than pasting the message into a function node. Perhaps if I were wanting to replay the last message this is a better option but that's not what I want/need for this case. Thanks for the suggestion though!

Where are the messages coming from? Is there no way to send them directly to Node Red?

OwnTracks, but I don't see how that matters.

They ARE going into NR. I have a function node that extracts the portions of the messages I wish to log and it had a bug in it so I wanted to replay the message from when I was Away (from home) so I could debug my function without actually leaving.

If it is the complete msg object then you would have to use each property in that in the inject node.

Or

In a function node

msg = paste your copied object here
return msg;

example flows

[{"id":"309f3c05.abf754","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"another","v":"[1,2,3]","vt":"json"},{"p":"_msgid","v":"aa9dc125.4cb08","vt":"str"},{"p":"topic","v":"156","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"series\":[\"\"],\"data\":[[12,12,14]],\"labels\":[\"340\",\"350\",\"360\"]}]","payloadType":"json","x":150,"y":1580,"wires":[["72cdbe7f.04fa88"]]},{"id":"371715.989fc0ec","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"_msgid","v":"aa9dc125.4cb09","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":140,"y":1680,"wires":[["c8552470.4610e8"]]},{"id":"c8552470.4610e8","type":"function","z":"c791cbc0.84f648","name":"","func":"msg = {\n    \"payload\":[\n        {\n        \"series\":[\"\"],\n        \"data\":[[12,12,14]],\n        \"labels\":[\"340\",\"350\",\"360\"]\n        }\n    ],\n    \"topic\":156,\n    \"_msgid\":\"aa9dc125.4cb08\",\n    \"another\":[1,2,3]\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":1680,"wires":[["4f1482a1.8a0444"]]},{"id":"4f1482a1.8a0444","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":540,"y":1680,"wires":[]},{"id":"72cdbe7f.04fa88","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":440,"y":1580,"wires":[]}]

This is exactly the solution I said I'm using.

So it seems I'm making a feature request to add an option to the inject node to do this directly.

This is a reasonable request, imo -- the debug node can show a complete msg object, but the inject node has no way built in to set the complete msg object.

I know it's been discussed several times, and I seem to recall seeing it was added as a feature request to the trello board -- although I'm not finding it now. There are several "internal" fields that are generated and used by the core to handle message routing and synchronization, http req/res objects, and ids for the msg and client sockets. So the trick would be how to allow us to inject a complete msg object, that is potentially not valid. Maybe that's not a show stopper for your use case, since you just want to copy the whole msg object from the debug sidebar -- unless of course, the sidebar has truncated the object. So lots to think about.

1 Like

Yes and I don't claim to know any of the internals but since I can paste the "old" message into a function without any problem I'm just saying that it seems to me that I should be able to paste it into the inject and not need the function. Now that I know the workaround it's really not a burden but let me tell you I wasted WAY too much time trying to get the inject node to do it because it seemed the obvious way to go.

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