Cron-plus - dynamic schedules

I'm a big fan of the cron-plus node, and use it for all of my timing events, but probably a question for @Steve-Mcl ...

What exactly does the view dynamic schedules window show?

I understand, and use the ability to stop & start specific timers, obtain timer status, describe expressions etc. but despite loading the example flows, and reading the readme, all I seem to see in the window is "No dynamic schedules!" and I can't help but think I'm missing out on another cron-plus great feature :wink:

Ok, so importing the demo...

you get this spaghetti...

If you add some schedules dynamically (at run time) they are not really statically entered in the UI but some folk wanted a way to see what dynamic schedules are running (in the back end / runtime)

kmeMZTjJtJ

I know it needs some TLC (and perhaps a means of deleting / stopping / pausing from the UI) but it is what it is for now.

1 Like

Ah OK. and of course they can also be persisted using the checkbox.

That's a really powerful feature (and obviously the one feature I have not tried until now!).
I can already see a use for that in one of my flows, which requires different timer functions depending upon the outdoor temperature, thanks Steve.

2 Likes

I've just hit a slight problem stopping and starting dynamic schedules...

I have a number of dynamic schedules loaded, but only want one schedule to run at any one time, so PlanA was to use a trigger node, which would first send stop-all-dynamic, and then 50ms later send the original msg object (start schedule every 20).

Sounds like a good plan? well no, because to stop all dynamic I would need to send the topic stop-all-dynamic and not the payload, which I don't seem to be able to do with the trigger node (there isn't a jsonata option).
Is there an easier way to achieve this without using a number of other nodes and complicating the flow?

EDIT - The same situation arises if using remove-all-dynamic first, and then adding a dynamic schedule.

Hi Paul, there are 2 methods of control...

  • topic method (the quick and easy method (but limited) - what you are using)
  • payload method (designed for more complex situations, multiple operations, good for lots of dynamic setup and control all in one msg)
    (the info is in the built in help but TBH it could probably do with some improvement. pretty sure there is a demo in the built in examples too (i forget))

To get straight to it, send this payload...

[
    {
        "command": "stop-all-dynamic"
    },
    {
        "command": "start",
        "name": "every 20"
    }
]

here is a demo...

[{"id":"4cb3b297.b07f9c","type":"cronplus","z":"5e6c8b.7f38b374","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"every5","payloadType":"str","payload":"every 5 here boss","expressionType":"cron","expression":"0/5 * * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"schedule2","topic":"every6","payloadType":"str","payload":"every 6 ready for duty","expressionType":"cron","expression":"2/6 * * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"schedule3","topic":"every7","payloadType":"str","payload":"every 7 at your service","expressionType":"cron","expression":"4/7 * * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":588,"y":704,"wires":[["9362c1dc.f4d4d"]]},{"id":"ae17ede9.44f6b","type":"inject","z":"5e6c8b.7f38b374","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"command\":\"stop-all\"},{\"command\":\"start\",\"name\":\"schedule3\"}]","payloadType":"json","x":434,"y":704,"wires":[["4cb3b297.b07f9c"]]},{"id":"9362c1dc.f4d4d","type":"debug","z":"5e6c8b.7f38b374","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":838,"y":704,"wires":[]}]

Ah Ok, I can see how your example above works, and can now piece it together with the example/readme. Thank you.

Is there a reason why some of the payload commands also need a topic? For example;
{"command":"remove-all-dynamic"} needs topic delete-all-dynamic.

NOTE - Anyone reading this may think that the cron-plus node is difficult/confusing to use.
It's not!!
Most functions are extremely easy to setup, much easier than other timer nodes I've tried, but the node is also extremely powerful, and allows you to dig down into advanced features that are not included with any other node, but of course, only if you want to!

2 Likes

They should not Paul.

I do think tho if the topic matches, it takes precedence (something has to right? ).

Can you test with no topic and a random topic and one of the matching command topics.

I think (hope) an empty or random topic it will be ignored and the command payloads are used. However the payload command will be ignored if the topic is a matching command.

If you find something other or determine the logic is bad/nonsense, please post a demo flow for me and I'll certainly take a look / fix it up.

Ps, Cheers for the positive review.

1 Like

It only works if the topic delete-all-dynamic is present.
'no topic' - not working
'random topic' - not working

[{"id":"d52bdeb9.ecc12","type":"cronplus","z":"dbe9689e.fc98f8","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[],"x":530,"y":932,"wires":[["1ea827af.902428"]]},{"id":"1ea827af.902428","type":"debug","z":"dbe9689e.fc98f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":685,"y":930,"wires":[]},{"id":"afc4bee8.8cdf8","type":"inject","z":"dbe9689e.fc98f8","name":"add every10Min","props":[{"p":"payload","v":"{\"command\":\"add\",\"name\":\"every10\",\"topic\":\"every10\",\"type\":\"default\",\"expressionType\":\"cron\",\"expression\":\"0 0/10 * * * *\"}","vt":"json"},{"p":"topic","v":"","vt":"string"}],"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":325,"y":910,"wires":[["d52bdeb9.ecc12"]]},{"id":"1d1070b4.ed186f","type":"inject","z":"dbe9689e.fc98f8","name":"remove-all-dynamic","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"delete-all-dynamic","payload":"{\"command\":\"remove-all-dynamic\"}","payloadType":"str","x":330,"y":960,"wires":[["d52bdeb9.ecc12"]]},{"id":"b559ba7d.205128","type":"inject","z":"dbe9689e.fc98f8","name":"no topic","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"remove-all-dynamic\"}","payloadType":"str","x":290,"y":1000,"wires":[["d52bdeb9.ecc12"]]},{"id":"3d8c5d35.c510e2","type":"inject","z":"dbe9689e.fc98f8","name":"random topic","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"randomtopic","payload":"{\"command\":\"remove-all-dynamic\"}","payloadType":"str","x":310,"y":1040,"wires":[["d52bdeb9.ecc12"]]}]

That looks like a regression :frowning:

Would you be kind enough to post an issue on the repo (I am not in a position to dig into the code until later)

1 Like

Hi Paul, on a closer look, the issue is the payload in not a proper object/array.

image

The commands need to be an object or array of objects.

If I change your flow demo to use {} instead of az everything works as expected.

Hope that satisfies your requirement?

Yes, that works thanks. Actually it was copied & pasted from your node example flow, so maybe that needs updating Steve.

error

Ah, good spot.

I'll fix that up on the next update.

Cheers.

1 Like

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