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

cronplus.triggerTimestamp actually. I've set it up with a switch directly behind the output of the cron node, to check if it is a command output or an event it has to output.

2 Likes

Seems sensible for the configuration input.

You also need a schema to support that via msg input too I think.

Also, it is really important to be able to set an offset, plus or minus. Since it is rare that you actually want something to trigger actually at sunset/rise.

1 Like

Don't know that would matter since you are adding something rather than making other changes. Why not just add the 2nd output anyway? Just keep everything else the same.

That does seem vastly over-complex to me. CRON syntax is complex enough already and there are other ways to easily achieve that via a simple flow.

I'm not even sure what that expression actually means which seems like a sure-fire recipe for getting things seriously messed up :slight_smile:

Academic, kinda yes. Today I have solved this via a function node. I just very much like your cron implementation because cron is super flexible and was wondering if it could do eval of expressions. If yes, I would have switched to cron, if no I'm perfectly fine to continue using my today's approach.

1 Like

Don't forget - ideally nodes should do their core function well - and not try to overload them (or the user) with complexity. there are other nodes that can evaluate equations and pass the result to the cron node.

2 Likes

Good thinking batman

Agree. much easier to use from a newbie perspective.

I did look at it and had a play in a jsfiddle but my thoughts were

  • it didn't support seconds or years
  • It didn't do things like "last Friday off month" or "first Monday" and a few other things that might convince a user it can't be done?

I might offer it as a popup that populates the expression field. Perhaps include info that not all possibilities are covered?

I suppose I could add them features via PR or request via an issue?

I see your point however the initial point was how to distinguish status messages from Cron events (and I suspect the reverse would be desired) so I think something would be necessary.

Perhaps it is possible for a node to know if a wire is connected to the 2nd output?

That would mean I could redirect status replies to 2nd output when it is wired.

No, I don't believe that is possible, or even desirable.

But as the 2nd output doesn't currently exist, you could simply always send the status outputs to it and continue to send it to output 1 but maybe add a flag in the config that turned that off? That wouldn't impact any existing flows but would still enable future flows to split the outputs.

I don't think there is any real performance impact on outputting to a node output that isn't connected?

Maybe you just have to think differently, you might be able to break it up into several expressions like I did to solve the sunrise/sunset example above

Agree, offset settings +/- (settings in minutes I think will do) is a must for sunrise/sunset schedules

Also have to allow access/setting of the other typical & relevant cron settings like day of month, month, day of week, year

Don't forget that the special character options L, W, ? etc are non-standard - so does the cron library used support them ?

This lib doesn't support ? unfortunately.

But it does do L e.g...
0 12 * * MONL At 12:00 PM, on the last Monday of the month

And W...
* * 1W * * Every minute, on the first weekday of the month

Even the # option...
0 0 7 * * MON#1 * At 07:00 AM, on the first Monday of the month

@krambriw that screenshot above is from my nodes built in help, and as far as I can see, it covers what you're asking here. An I missing something?

Thanks for your valuable and always welcome feedback Julian. As you know it was more about avoiding adding another option by detecting if node had a wire on the 2nd output & redirecting the status replies there. But as you have said, that's not possible.

@dceejay Dave, is giving a node the awareness that a wire is attached to an output something you guys are considering? Or is there some pitfall I'm not considering?

Thank you everyone for your valuable feedback.

For users not familiar with cron: https://www.freeformatter.com/cron-expression-generator-quartz.html

1 Like

Just be aware that not all CRON interpreters are made equal :unamused:

I had problems to begin with when generating a pattern using a site like the one you listed that doesn't work with CRON+

I think it was the lack of the ? as Steve mentioned.

No, fine, I just wanted to be sure that the sunrise/sunset options still allowed using them

A node can interrogate it’s wires array to see if it is attached. But imho it would be clearer to the user if it was either selectable or there by default.
Maybe the old behaviour could be deprecated over time ?

( indeed that is what I did for the ui chart node to remove the second output - so any existing wires keep working but any new ones would not have the option. I think the code may still be in there)

1 Like

Bit of an interesting situation I’m seeing here. We’ve an issue at home where on humid days where when it’s dark/heavily clouded in the morning the solar panels take the power for the entire house down. I think it’s an insulation problem somewhere, with the inverter failing due to humidity. Or something. That isn’t important here. I’m running NR on a pi 3B, raspbian stretch iirc (the one before buster). It’s directly connected through an official power supply to mains, so when the power goes down, so does the pi and NR.

The situation is as follows: while the power is off, and cron+ would normally have triggered flows/actions directly added in the node configuration, they get executed rapidly after it comes back online. Should I see this as a bug or a feature? Today I had it offline for other reasons, put it back online around 10.30 pm and all notifications that normally would go out every 2 hours came in one after another


These are the 11,13,15,17,19,21 (hours) daily recurring notifications to drink water. I shut off the pi around 10.30, so it shouldn’t be like a crash recovery either. I’m just not sure what’s happening here but for me it’s just notifications. Really hope this doesn’t happen for things like feeders, blinds rapidly opening/closing after power failure, and so on.

Hmm, maybe needs an option to switch between replay after fail or delete after fail?

BTW, do yourself a favour and invest in a PC UPS. Then attach your Pi, router, AP and switch to it.