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

Thanks for the info - it is now fixed and published :slight_smile:

Fortunately, the bug was cosmetic (for updating node status) so operationally, there was no problem.

PS, your test flow can be simplified to this (apologies if i'm teaching you to suck eggs)...

CbjwKdI64f

[{"id":"bcda75bf.c394a8","type":"inject","z":"21106466.70e60c","name":"remove-all","topic":"remove-all","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":980,"y":280,"wires":[["a2299126.371a3"]]},{"id":"a2299126.371a3","type":"cronplus","z":"21106466.70e60c","name":"","outputField":"payload","timeZone":"","persistDynamic":true,"commandResponseMsgOutput":"output1","outputs":1,"options":[],"x":1200,"y":280,"wires":[["9aacf955.869d18"]]},{"id":"b4d98f36.29cea","type":"inject","z":"21106466.70e60c","name":"add 2 schedules","topic":"","payload":"[{\"command\":\"add\",\"name\":\"every 6\",\"expression\":\"*/6 * * * * * *\",\"expressionType\":\"cron\",\"payloadType\":\"default\",\"limit\":3},{\"command\":\"add\",\"name\":\"alarm1\",\"expressionType\":\"solar\",\"solarType\":\"selected\",\"solarEvents\":\"sunset\",\"location\":\"54.999320540937035 -1.417407989501953\",\"offset\":\"-60\",\"payloadType\":\"str\",\"payload\":\"In 60 mins, it will be a great time to take photographs\",\"limit\":null}]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1000,"y":240,"wires":[["a2299126.371a3"]]},{"id":"85038c59.6f9e3","type":"inject","z":"21106466.70e60c","name":"status-all","topic":"status-all","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":980,"y":320,"wires":[["a2299126.371a3"]]},{"id":"9aacf955.869d18","type":"debug","z":"21106466.70e60c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1330,"y":280,"wires":[]}]
1 Like

Thanks a lot for the quick fix.

Yeah for some reason I use function nodes far more often than necessary, always happy about tips to simplify stuff :smiley:

1 Like

@Steve-Mcl Hi Steve, I just upgraded to latest cron+ from pre 1.0, and I should have written down the previous version but obviously didn't... Viewing the editor on Firefox 76 (I know, I should update to latest firefox) on macbook pro, resolution about 1400xsomething I forgot what exactly. Tried to do a couple quick updates to a flow so it could better support me during my sickness. Turns out that was too easily thought...


The new arrow for example schedules is falling to the next line, as you can see better in the second image:

Thing is, this node is showing as having configuration issues, but nothing on the configuration screen shows as having errors. I've several cron+ nodes in my flow, and this is the only one saying it has configuration problems. There's no dynamic schedules enabled on it, and I can't spot the error.

Redacting the schedule names, here's the misbehaving node instance:

[{"id":"a104913f.0bb62","type":"cronplus","z":"d83aa04f.39ec3","name":"Reminders","outputField":"payload","timeZone":"Europe/Amsterdam","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"drink_water","topic":"drink_water","payloadType":"json","payload":"{\"notificationName\":\"DrinkWater\",\"status\":\"NEW\"}","expressionType":"cron","expression":"0 0 9,11,13,15,17,19,21 * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"medication_foo","topic":"medication_foo","payloadType":"json","payload":"{\"notificationName\":\"medication\",\"status\":\"NEW\"}","expressionType":"cron","expression":"0 0 9 * * 3 *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"medication_foo","topic":"medication_foo","payloadType":"json","payload":"{\"notificationName\":\"medication\",\"status\":\"NEW\"}","expressionType":"cron","expression":"0 0 19 * * 6 *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"schedule4","topic":"medication_bar","payloadType":"json","payload":"{\"notificationName\":\"medication\",\"status\":\"NEW\"}","expressionType":"cron","expression":"0 0 9 * * * * ","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":150,"y":180,"wires":[["4e0abfe4.031448"]]}]

Only thing I can think of is that there's two schedules with the same name and topic in there, with a different cron schedule. It's for a set of medication that has to be taken at two moments a week, one day in the morning, the other in the evening. I seem to remember that in the first versions of this flow I had the names marked with a day-of-week suffix, but I don't see them in this export nor in the flow. As for the last one, the name showing up in the editor is not schedule4, but medication_bar, so that's odd too. Otherwise I don't know what's going on.

Oh, running on NR 1.1.2, Node v10 LTS, Pi 3B+ Buster
After fixing the scheme names to have them back at the dow suffix the error is gone, but nothing showed in the editor that there was an error in the first place.

1 Like

Hi Lena.

Yeah, its on my todo list :frowning: - well, actually, its OK on my installation so I might have it resolved already. Please just close your eyes and pretend you didnt see it :grimacing:

Close - its the names on multiple schedules that must be unique. This uniqueness is required for permitting a dynamic modification (NOTE: the topic can be duplicated). It was actually a long standing bug (you could have 2 names the same but not addresses the 2nd one via dynamic control) so it was necessary to have name and topic separate things (separate name/topic was also a request by xxx (i forget))

Yeah - not ideal (there is a console warning) but I haven't found a nice easy way of marking the editableList items as having validation issues.

Will try to remember this next time I am amongst the code (or if you could raise an issue?)

1 Like

Lena, I have pushed an update (V1.0.7) to the flows library that slightly improves the situation.

There are a few other UI tweaks to try and be more in line with core nodes.

EDIT: Note the cron expression widget is now fixed too (must go back and check node-red version before the typedInput resizing method was changed as this now looks OK in V1 - but suspect it might be messed up in older node-red versions)

1 Like

Just published Update V1.2.1

Notable additions since last publish...

  • Added a cron expression builder to aid those not proficient with cron expressions
  • Handle system time changes (recalculates schedules upon detecting system time change)
  • Fix builtin demo flows

easy-expr-builder

9 Likes

So amazing!!!!

3 Likes

Is there a way to have cron plus start on a date range from sunrise to sunset? I see that I can choose cron or solar. What I would like to do is create holiday lights. So, for Christmas, have my lights only be active from say 12/1/2020 to 1/1/2021 but actually turn on from sunset to sunrise during this time.

Any help is greatly appreciated.

How I handle that is to add another global variable based on Seasons (I change mine manually but you could do it based on date). My flows then have season checkpoints so I can have different timing for Christmas vs. summer vs other specific times of the year.

That is quite simple in many different ways. Here is a very basic way...

[{"id":"d84f7031.2e962","type":"cronplus","z":"c40b7683.6e65e8","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"schedule1","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"54.99911630747018 -1.4171075820922852","offset":"0","solarType":"selected","solarEvents":"sunrise,sunset"}],"x":230,"y":160,"wires":[["ce8af392.f8ffb"]]},{"id":"ce8af392.f8ffb","type":"function","z":"c40b7683.6e65e8","name":"is december?","func":"var now = new Date();\nif(now.getMonth() == 11) {\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":160,"wires":[["557a65c9.a5c49c"]]},{"id":"557a65c9.a5c49c","type":"debug","z":"c40b7683.6e65e8","name":"do stuff with xmas lights","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":690,"y":160,"wires":[]}]
1 Like

Thank you for your help. I am new to node red and coding. I never thought to use a function node. I used your function node to learn a little more about Javascript. I have also learned more about function nodes too. I was able to get it to work. Out of curiosity, why are you not able to use the cron settings and solar selections at the same time?

1 Like

I have been playing with that in my head for some time however, i always ends up at the same conclusion...

  • The highly flexible nature of the cron-plus node means it is pretty much possible to achieve whatever the user wants - usually without any extra nodes, sometimes with one extra node, sometimes with 2 cron-plus nodes - however the point being, i havent yet found a simple enough solution to bake these extra bells and whistles into cron-plus that doesnt cause more trouble than it is worth.
  • A wiser man than I told me to not over complicate something already complicated but make it as simple as possible. Hopefully, with all the built in help and dropdowns and helpers and tooltips - most people would agree the not-so-friendly subject of CRON and solar coordinates / events etc have been greatly simplified in CRON-PLUS? I think the node is at a good solid place and I dont want to break that fine balance (atm).
2 Likes

Late to the party, but if you need another vote, for the @sunrise and @sunset logic or feature... I could really use that for some of the stuff I am doing with various sensors. Just as capturing the light level locally at the actual projected sunrise and sunset. Also, triggering irrigation at sunrise and/or sunset for example.

Thats entirely possible as is though isnt it?

  • sensor value --> store somewhere ready for capture
  • cron [sunrise, at-your-coords] --> get sensor values --> store values

image


OR if a sensor value can be requested...

image


I dont doubt there are improvements to be made but as it stands there is very little you cannot do & I dont want to add even more complexity.

1 Like

Just to mention, if the need is to do everything in one single node, we also have the BigTimer able to do what was originally requested. In the settings you can configure actions for sunset/sunrise and in addition configure the active months. As well as week days and much more

But as you say, over-reaching is no good

I am not suggesting that cron plus read any sensors.... not sure how that was introduced, it was just an example of how such could be done, and is often done, in some projects.

May intent was to have cron-plus have a defined trigger for @sunset and @sunrise. It would be nice to just have the feature, @sunrise do Y, and @sunset do X type of thing as part of the cron plus. Thus the operator would not have to develop any flow logic or such on their own to have such triggers, or even pull in yet another node, i.e. big timer, when cron-plus is already desired..

I solved the need by doing a query to weather report source, which I already had logic for already, grabbed the sunrise and sunset values from said report, was easy to do... but not as easy as if cron plus node did it, hiding the complexity of such.

Since you asked for input, that was what I thought would be useful, as a future feature of cron-plus, at least to me, if not others. :slight_smile:

There are already several suncalc specific nodes. Why does this need to be added to this one ? You would need to configure it with location adding yet more ui.

I'm not sure who misunderstood who here but just for clarity, there is already sunse, sunset, dusk, dawn etc that can trigger whatever you want. And it doesn't need to go out to the internet as it is calculated internally, and my response was based on your question about "triggering irrigation at sunrise and/or sunset for example."

The prior poster was asking about the ability to limit solar events between dates and asked for it to be built in to which I said I was open to suggestions.

So either I misunderstood you (and thus suggested what you suggested was already possible) or you misunderstood that solar events are already entirely possible.

Either way, I hope you don't miss the point that I am grateful of your input and suggestions regardless of who is misunderstanding who :grinning_face_with_smiling_eyes:

2 Likes

I was beginning to think that the recent discussion was about a totally different node....

3 Likes

At the risk of generating one "ask" too many, I've been looking at using solar events in cron-plus to replace node-red-node-suncalc, bigtimer and schedex, and I have run into three features I would miss.

  1. Enabling or disabling events on specific days of the week.
  2. An option to randomize offsets between zero and the value entered.
  3. Setting the location from environmental or global variables.

The first two might not be hard to implement or over-complicate the ui -- not sure about the last. What do you think?