Cronplus node schedule(s) state at boot

hi,
the cronplus node does not retain the stop/start state of the schedules after a reboot.
i have a cronplus node set up with 3 different schedules and if i stop let's say the first then reboot the raspberry pi, all 3 schedules will run on after boot.
context memory is enabled, i followed the instructions in the documentation, also tried both "local filesystem" and "node context" from the image below (and waited for the 5 minutes for the data to be written, then reboot) but no change.
image
also tried a workaround by injecting once at boot a json with the required stop command(s) and that wasn't working either.
the syntax in the inject is correct because if i inject it manually, the schedule(s) stop.

Are these dynamic created (via a msg input) or statically entered (via the editor) schedules?

I can't remember if I implemented persistent state for static schedules but dynamic ones should definitely be persistent.

hi Steve,
thanks for responding.
yes i've created them by editing the cronplus node and adding them on the gui.
i think with some research i could redo them via an msg. if this is the issue.
but this still does not explain the situation where the inject once is not working?
thanks

Can you create a simple example flow that shows the problem and Export it and paste in here?

Are you using the latest version of the cron plus node? Also what versions of node-red and nodejs are you using?

hi Colin,
node red is 3.1.0
cronplus is latest (2.1.0)
node.js is v18.18.2

[{"id":"18793ed8252139d4","type":"inject","z":"c69525dc123ceeb4","name":"3sec","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"command\":\"start\",\"name\":\"3sec\"},{\"command\":\"stop\",\"name\":\"1min\"},{\"command\":\"stop\",\"name\":\"5min\"}]","payloadType":"json","x":730,"y":160,"wires":[["80b824f8fc3556fd"]]},{"id":"3d1fda2f9f7435c5","type":"inject","z":"c69525dc123ceeb4","name":"1min","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"command\":\"stop\",\"name\":\"3sec\"},{\"command\":\"start\",\"name\":\"1min\"},{\"command\":\"stop\",\"name\":\"5min\"}]","payloadType":"json","x":730,"y":220,"wires":[["80b824f8fc3556fd"]]},{"id":"ef81f12d71bf5ca6","type":"inject","z":"c69525dc123ceeb4","name":"5min","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"command\":\"stop\",\"name\":\"3sec\"},{\"command\":\"stop\",\"name\":\"1min\"},{\"command\":\"start\",\"name\":\"5min\"}]","payloadType":"json","x":730,"y":280,"wires":[["80b824f8fc3556fd"]]},{"id":"80b824f8fc3556fd","type":"cronplus","z":"c69525dc123ceeb4","name":"SimCron","outputField":"payload","timeZone":"","storeName":"default","commandResponseMsgOutput":"output1","defaultLocation":"","defaultLocationType":"default","outputs":1,"options":[{"name":"3sec","topic":"3sec","payloadType":"bool","payload":"true","expressionType":"cron","expression":"*/3 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"1min","topic":"1min","payloadType":"bool","payload":"true","expressionType":"cron","expression":"0 0/1 * 1/1 * ? *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"5min","topic":"5min","payloadType":"bool","payload":"true","expressionType":"cron","expression":"0 * * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":900,"y":160,"wires":[["381c6c6c9106c3cd"]]},{"id":"381c6c6c9106c3cd","type":"debug","z":"c69525dc123ceeb4","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":1070,"y":160,"wires":[]},{"id":"35cb2a363d00e7ec","type":"inject","z":"c69525dc123ceeb4","name":"ManualStop","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"command\":\"stop\",\"name\":\"3sec\"},{\"command\":\"stop\",\"name\":\"1min\"},{\"command\":\"stop\",\"name\":\"5min\"}]","payloadType":"json","x":750,"y":340,"wires":[["80b824f8fc3556fd"]]},{"id":"62aa85ea0a8c1ce6","type":"inject","z":"c69525dc123ceeb4","name":"Stop@Boot","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"3","topic":"","payload":"[{\"command\":\"stop\",\"name\":\"3sec\"},{\"command\":\"stop\",\"name\":\"1min\"},{\"command\":\"stop\",\"name\":\"5min\"}]","payloadType":"json","x":750,"y":400,"wires":[["80b824f8fc3556fd"]]}]

if you could help with any of the two approaches that would be awesome (inject "stop" at boot or making the stop/started state(s) of the schedule(s) to retain their state on reboot).
thank you kindly.

The injects in that flow seem to work for me. What is not working for you?
That is with persist set to none.

the inject node "Stop@Boot" should stop the cronplus schedule timers at reboot by injecting the stop command json once, after 3 seconds.
the inject happens because i can catch it with a debug node, but the cronplus node does not "pick it up" because all 3 timers start to work after boot ...
also i am doing this because if i stop all timers manually, they all start back after a reboot ...
i don't know the issue, this exceeds me

It works for me, I get events during the first three seconds then the status shows all stopped.

Does it stop if you manually click the stop node?

What is it showing in the persist state dropdown?
Set the persist state to none and see if anything changes.

That is weird,
Yes it stops when i stop it manually.
This is the persists state (also tried with "none"):

image

I don't know what to do ...
Here is a screen before a reboot, the cronplus node status is "All stopped" and the debug node on the inject node has nothing;

image

And here is a screenshot right after the reboot (and a 3 second delay), where the timer runs and the debug node from the inject node caught the stop msg;

image

I am officially out of ideas. I am using the cronplus node on other flows too in this same project, whenever i build a flow i dont drag the node from the toolbar, i am copying it and pasting the nodes from the canvas. Does copy pasting ruins something? Tried also longer delays at he inject once ... Please help.

What happens if you click the down arrow on the Deploy button and select Restart Flows?

The flow behaves as it should, timers start, then after 3 seconds the inject once node stops them.
But why like this and not on system reboot?

I have no idea. What OS are you running on, how did you install node-red and how are you making node-red start on boot?

setup is pretty generic, raspberry pi os (64bit) latest and installed by using that bash curl command from the manual, then i uncomment the context memory part in the config file.
i enable it with systemctl then start.
after this it runs on boot automatically.
am i doing something wrong?

Apparently not.

As an experiment, just to rule it out, comment out the context memory bit in settings and try again.

Assuming that doesn't make a difference, enable both the debug nodes and set them to output to the console. Then after boot look back at /var/log/syslog and you should see the sequence of messages and the timing. It will be interesting to see that.

If you set the inject to trigger 120 secs after start does it work?

i think the 120 sec delay did its trick.
also checked the console log and when the delay was 3 sec, the inject once command was done before the cronplus things in the log.
can it be that the cronplus thingy loads waaay after boot?
in this case i have to adjust the delay for a longer one. (i tried only up to 10 sec so that isn't enough either...)

Are you connected via wifi? I have a suspicion that I know the problem.
Please set it back to three seconds, reboot, wait a few minutes, then run this command and paste the full output here.
journalctl -b -u nodered --no-pager

yes i am on wifi.
i assume that command has to be run in terminal, but the output is really big, the output did not fit in my terminal and i doubt it will fit here.
also the lowest delay i could go was 60 seconds.
with a 60 second delay the cronplus node stops the timers and the output shows up also on the right side of the screen in the debug space ... and when the delay was lower and the timer did not stop there was no message here ... so that's weird too ...

The log should not be much bigger than 100 lines. It is no problem to post that here. However, have a look for a message like this.
[info] [cronplus:SimCron] System Time Change Detected - refreshing schedules! If the system time was not changed then this typically occurs due to blocking code elsewhere in your application
With the delay at 3 seconds does the above message appear after the boot inject output?

If so then I suspect what is happening is that node-red gets up and running before the wifi connects, so before the system time is set. The pi does not have a real time clock so the system time is not set until the internet is available. So the inject node stops the flows, possibly the time change is restarting them.

@Steve-Mcl does that seem plausible?

That may also explain why the save status is not working for you.

Very plausible.

The OP should follow one of the many existing threads Dave and others have posted about delaying start-up of node-red until the necessary OS components are up and running.

"possibly the time change is restarting them."

That might be a timing bug - but I am not certain (i have not read the whole thread)

i get much more than 100 lines, but the message with the system time change detected is there with the 3 sec delay too.
also i have a screen connected to the rpi and the wifi indeed connects really late i can see that on the desktop gui ...