Inject Node - dev

Does anyone, with way more skill than me, fancy forking the inject node, and making the specific option accept a variable rather than a fixed value.
Would this even be possible?

Reason: I want to be able to reference a global variable that can be changed elsewhere so that the inject node fires based on that variable. - Hope that makes sense.
I've looked at the Cron+ node, but that's seems really complicated to get it to dynamically vary it's trigger time based on a changing variable/context.

Have a look at this node, with a bit of tweaking the open times it might do what you need:

Also perhaps look at other scheduling nodes such as CRON+ which are more likely to already accommodate your requirements. Inject is intentionally straight-forwards.

We already have a node that can handle dynamic data, so I think it's unlikely that changes such as described would be implemented.
Cron+ may seem daunting, but it's not that difficult when you start using it, and there is loads of support to help.

Check out this topic How to triggers at event time coming - #13 by Steve-Mcl

1 Like

@Paul-Reed @TotallyInformation
All of the existing nodes require intervention to change their schedule, including Cron+, as far as I can tell.

I need to trigger a message based on a time that changes dynamically that is held in a Global variable. Looking at Cron+ (I'm comfortable with setting a fixed schedule using cron) it still requires the schedule to be determined ahead of time.

I have a variable Global that is dynamically changed by another process in the format nn:nn. How do I get Cron+ or other node to both monitor the variable, and then trigger at the time contained within the variable dynamically but only once per go...?

The only option I can see at the moment is to set a repeating trigger inject node at say 10 seconds into a switch node that references the variable, but this seems wasteful on resources and will trigger the flow several times within the 60 seconds of the target time which is not desired.

Is modifying the inject node to do this difficult because it also sets a cron job based on fixed settings when being deployed?

From the node's readme:
Ability to add, remove, list, export, stop, start, pause schedules by a command payload input. Examples include...

  • add - add one or more dynamic schedules

@dougle03 Did you check the link that I posted earlier?
That is an example of how to do it.

Instead of using the global variable for the time (and having to set a repeating trigger inject), use the source of the global variable and use a link node that will then inject the time data into your Cron+ flow, every time it changes.

In fact here is a another quick example;

[{"id":"d52bdeb9.ecc12","type":"cronplus","z":"8ec88bd9c36c3f6b","name":"","outputField":"payload","timeZone":"","persistDynamic":true,"commandResponseMsgOutput":"output1","outputs":1,"options":[],"x":410,"y":945,"wires":[["1ea827af.902428"]]},{"id":"1ea827af.902428","type":"debug","z":"8ec88bd9c36c3f6b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":565,"y":943,"wires":[]},{"id":"afc4bee8.8cdf8","type":"inject","z":"8ec88bd9c36c3f6b","name":"add every10Min","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"add\",\"name\":\"every10\",\"topic\":\"every10\",\"type\":\"default\",\"expressionType\":\"cron\",\"expression\":\"0 0/10 * * * *\"}","payloadType":"json","x":235,"y":925,"wires":[["d52bdeb9.ecc12"]]},{"id":"b559ba7d.205128","type":"inject","z":"8ec88bd9c36c3f6b","name":"Remove all dynamic schedules","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"remove-all-dynamic\"}","payloadType":"json","x":190,"y":1005,"wires":[["d52bdeb9.ecc12"]]},{"id":"88836535ec67a0e9","type":"inject","z":"8ec88bd9c36c3f6b","name":"Show all dynamic schedules","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"list-all-dynamic\"}","payloadType":"json","x":200,"y":965,"wires":[["d52bdeb9.ecc12"]]},{"id":"97a5a18015642e3a","type":"inject","z":"8ec88bd9c36c3f6b","name":"Midday","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"add\",\"name\":\"midday\",\"topic\":\"midday\",\"type\":\"default\",\"expressionType\":\"cron\",\"expression\":\"0 0 12 * * *\"}","payloadType":"json","x":210,"y":890,"wires":[["d52bdeb9.ecc12"]]}]

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