UPDATE: V1.2.1 node-red-contrib-cron-plus scheduler (incl solar events and Timezone support)

Hi all, something I am working on.

Would appreciate feedback/suggestions/criticisms please.

Features...

  • Timezone support
  • human readable descriptions of cron
  • Supports standard CRON + year

Some pictures for now (details later).

Help tab...

In action...

In action...

Timezone...
image

Timezone...
image

6 Likes

If you wish to try it out, cd into your .node-red folder then...

npm install Steve-Mcl/node-red-contrib-cron-plus

src: https://github.com/Steve-Mcl/node-red-contrib-cron-plus

Is there the ability to set Automatic for the timezone so it picks it up from the server? Possibly that should be the default.

Sure I can
var tz = Intl.DateTimeFormat().resolvedOptions().timeZone // 'Europe/London however it should be implicit (i.e. leave it blank to use system).

Is there a reason you would expect it to be populated by default?

Sorry, not sure I understand the question. I wasn't meaning it had to say "Automatic", leaving blank to use system timezone is fine.

Moved to #share-your-nodes category

  • Timezone is blank by default (when a node is dropped on editor).
  • Blank == use system :slight_smile:

Hi Steve,

Very nice and easy to use plugin. I really like the yellow info box telling what is going to happen.
I was thinking about an input on the node where you could enable/disable the cron timer. That could be quite handy?

I kind of like the node status, but it becomes quite long. If the node is used in a crowded flow it's a little overwhelming and might go on top of other nodes. Maybe an option where you can choose a short version would be useful (maybe without date and timezoneinfo?)

Like an input connection on the left so that you can send it control messages e.g. msg.topic = "stop"?

A tick box option would be possible yes. Please add an issue to the repo so it doesnt get forgotten.

That is harder than it sounds :frowning: - I could I suppose hide the date if its the same day (but then what is the same day when you're dealing with timezones aaaarrggg :exploding_head: )
This needs thought.
Perhaps the option to turn off the node status will have to do for now.

Like an input connection on the left so that you can send it control messages e.g. msg.topic = "stop" ?<

Something like that. Maybe msg.enabe would be more descriptive?

That is harder than it sounds :frowning: - I could I suppose hide the date if its the same day (but then what is the same day when you're dealing with timezones aaaarrggg :exploding_head: )<

What about an option for showing relative time? Eg:
Next Run: ~1d
Next Run: ~7h
Next Run: ~2m
Then you change the accuracy the closer you get to the trigger time.

1 Like

So Steve - looks great and a hell of a lot of effort - could you clarify for me - is this part of the system cron process and is manipulating that tables of entries or is this standalone and is only for node-red functions ? i.e. is it (essentially) cron functionality ported into node-red for scheduling - or is it node-red tapping into the cron daemon to manipulate its list of jobs ??

Craig

Hi Craig, I should probably clarify that in the readme.

Not using system Cron no. It's a node.js implementation and this simplifies operation and containment across all the various operating systems.

Would take some doing for all the different OSs and not to mention reliably hooking the trigger up.

What's your thinking?

Totally agree as to complexity etc across implementations - just wanted to make sure the way i was looking at it was correct.

regards

Craig

Nice, this node is somewhat reminiscent to the later node.

A combination of the 2 would be nice. (ie. an input).

Personally I don't see the use for the timezone, could actually become confusing once you have 5 nodes on your flow and apply individual timezones to them (although I wonder who would use it).

Ideally it would be a reusable node that holds a list with of cron-jobs, each with their own 'topic', where a schedule can be added/removed via input. Outputs a timestamp & topic.

On the other hand, the expression part would also be nice to integrate on the current inject node.

Certainly being able to select local timezone or GMT can be useful. One may want something that happens the same time every day and is not affected by DST. Being able to select a particular timezone may be useful where the server is running in a different timezone to the user (a server in the cloud for example).

That's why I said: 'personally' :wink:

I am considering the idea of adding a "cron table" (I would need some pointers with the ui elements though)

I was thinking along the lines of each node has a one timezone & each cron table entry has

  • topic (for the user to understand which job is triggering)
  • payload (what to send)
  • something else???

Design thoughts...

  • The UI could permit the user to enter the topic+schedule then an add button to add to the "cron table". Each item would be able to be selected (for editing) and removed/deleted.
  • I'd likely have to remove the inject button as i dont see how it would make any sense with a table of schedules.

Anyone got ready made a simple for making this work? The backend code will be pretty easy & quick to realise.

Comments welcomed.

1 Like

So one thought (not sure if its possible)...

  • If there is only one entry in the cron table - show the inject button.
  • If there is mode than one entry - hide the inject button.

Doable?

Yes. See email node for example (though that only has or doesn’t have an input (no button) but SMOP

Scheduling via UI (only) is not as flexible as scheduling via an input.

Eg;
{payload:’* 5 * ’,schedule:’add’,topic:’something‘}}
{payload:’
* 5 * *’,schedule:’remove’,topic:’something’}}
payload:’list’}

(Some characters falling off on mobile)