Inject node - trigger programmatically?

4,157 views
Skip to first unread message

jo2

unread,
Jan 6, 2016, 7:10:44 AM1/6/16
to Node-RED
Hi!
Tried to search the group and google for this:

Is it possible to trigger / call an inject node in any other way than through the nodes UI config?!

Motivation is to avoid having e.g. credentials in inject node payload...and / or dynamically assigning through parameters...

Cheers
-jo

Nicholas O'Leary

unread,
Jan 6, 2016, 7:16:12 AM1/6/16
to Node-RED Mailing List
The editor sends an HTTP Post to trigger the node (which you can easily inspect), but the payload etc is hardcoded in the node.

If you want to dynamically trigger a flow with custom payload why not just use an HTTP In node (for example)

Nick




--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jo2

unread,
Jan 6, 2016, 7:24:00 AM1/6/16
to Node-RED
Thanks Nick!

Yes I have thought of HTTP in node. But I use the interval in the Inject node to trigger it every n minutes. I just thought about
being able to start the Inject node when desired, and provide the payload at that point in time.

Maybe there is alternative to repetitive calls?

-jo

Dave C-J

unread,
Jan 6, 2016, 7:44:23 AM1/6/16
to node...@googlegroups.com
... just wait for release 0.13 ;-)

jo2

unread,
Jan 6, 2016, 7:50:31 AM1/6/16
to Node-RED
Ok :-)

Julian Knight

unread,
Jan 6, 2016, 12:31:10 PM1/6/16
to Node-RED
You can, of course, trigger a node from more than one starting point. So why not have both an http in AND an inject node both connected to the same downstream node? I have quite a number of processes that can be triggered both by schedules, manually and by MQTT messages for example.

jo2

unread,
Jan 7, 2016, 7:14:37 AM1/7/16
to Node-RED
Hi Julian!

Yes, I could do that, and I have also done that in other flows. But in this case I just want to be able to "remote control" trigger the Inject node to start. (and
maybe also stop).
The Inject node kicks off a flow every 5 minutes to read data from a air quality sensor device (foobot). And I don't want to rely on an external (to Node-RED) component
to do the calls.

Cheers
-jo

Julian Knight

unread,
Jan 7, 2016, 4:32:34 PM1/7/16
to Node-RED
OK, no problem.

Have you checked out the "later" node? That has a trigger input and a scheduler.

Alternatively, add a function node downstream of the inject and in there check a global variable, if false don't pass on the event. Then you can control whether the event is passed on downstream from other nodes that set the same global variable.

jo2

unread,
Jan 9, 2016, 12:23:45 PM1/9/16
to Node-RED
Thanks Julian for a very good advice there on using a global variable to control things, sounds like a working alternative.

I have not heard of the 'later' node, you have the GitHub & npm link?!

Cheers
-jo

Nicholas O'Leary

unread,
Jan 9, 2016, 12:25:20 PM1/9/16
to Node-RED

You can search for it on http://flows.nodered.org

Greg EVA

unread,
Jan 11, 2016, 5:13:11 AM1/11/16
to Node-RED
@jo2 - Later.js node rules.  I use it and love it.  You just need to write in the nodes config "every 5 minutes" and it will kick off a flow (with timestamp) every 5 minutes.

Julian Knight

unread,
Jan 12, 2016, 7:15:36 AM1/12/16
to Node-RED
Yes, it is good. The only thing missing is the ability to use sunrise/set - I have asked them but they weren't willing to change it. That could be added to node-red-contrib-later though and there is an open enhancement request that Dean is going to look at when he gets time.
Reply all
Reply to author
Forward
0 new messages