csuermann/node-red-contrib-suncron

Latest version seems to no longer emit preceding events at startup

Closed this issue · 5 comments

I rarely restart my Node Red, so I did not notice this issue before.
After a restart the suncron node no longer emits the preceding event.
Also, when using an inject node with 'true' on the suncron node, no output is generated.

The defined crons still fire ok.
After the first cron has fired, an inject node with 'true' produces the expected output.
However, between startup and first programmed cron my flows do no longer work correctly.

Regard, ahartman, Belgium

May I ask which event was missing? My suspicion is that the event you're expecting simply does not exist for that day, due to the position of the sun with respect to your lat/lon location. Mind you, the node only outputs events for the current day, so if you restart Node-RED in the morning, it would not output e.g. "Night" as a preceding event, even if that was the last event that the node emitted before the restart.

Hi @ahartman,

I skimmed the code yet again and still believe the behaviour you're observing must be a logical timing issue. My assumption is that the suncron node will indeed emit the previous event on startup, but only if the startup happens after sunrise (in your case). If you restart Node-RED before sunrise, there wouldn't be a previous sun-event to replay for the current date. Could that be the case?

Dear Cornelius,
Your assumption is right. After the first cron of the day has fired, in my case 'nautical dawn', your node does emit the previous event at startup. For me, this is no longer very relevant as I have found out how to use contextStorage to the file system. Before that, I would lose the sun position at every restart. That is why I contacted you in 2019 and you out it 'emit preceding event'. With the contextStorage, I will only very rarely need 'emit preceding event' any longer.

Thank you.
ahartman, belgium

Thanks for confirming, @ahartman!