csuermann/node-red-contrib-suncron

Startup behaviour

Closed this issue · 13 comments

I find your module simple and powerful at the same time and I want to use it in a system controlling lighting to determine the lights scene depending on the time of the day.

However, I am missing initialisation when node-red starts up. That is essential since without that the system is in an undetermined state until the first event has fired.
In my view, easiest would be to have an input that reacts on any message with emitting the msg object. User that want that can connect that input to a startup inject node.

Regards, André Hartman, Belgium

Hi @ahartman, thanks for your feedback! I'm not quite sure I fully understand your request yet. Which msg object should the node emit on startup?

In my opinion, the node should emit the payload of the current timespan, example:

The user has defined payloads for "sunrise", not for "sunrise end" and for "solarNoon". When startup then is between "sunrise end" and "solarNoon", the node should emit the payload for "sunrise" as that is the "currently valid" payload. Additionally, it could emit the msg.schedule and you could put msg.topic like "Suncron startup".

Regards, André Hartman

feature added in v1.2.0
image

Wonderful, I will test it and let you know.
Many thanks for the quick follow up.

Hi @ahartman, did you have the time to validate the new feature you suggested?

Dear Cornelius,
I had time to validate the new behaviour and that works as expected.
For a restart this is perfect. However, take following example:
Node-RED stops shortly after sunrise, for whatever reason and is started shortly after sunset.
The string 'Replay last event' suggest, the node will emit the 'sunrise' event, although the 'sunset' event is the correct one in this case. Is that correct?
The word 'replay' is not appropriate in the case above as the 'sunset' event has never been played - Node-RED was down - and can't be 'replayed'.
I would suggest labeling the checkbox 'Emit the applicable event at startup'. for me that is a clearer message.

Thank you for the good work, this saves me extra steps in Node-RED to guarantee an orderly startup.

Regards, ahartman, belgium

The node will emit the message on startup that represents the previous event in the current schedule. Not the previous message that actually got emitted while node-red was on.

If the term "replay" is misleading, how about changing the label of the checkbox to "Emit preceding event on startup" ?

That message would be perfect and decidedly better. I think you can close this thread with success, thank you.

regards, ahartman, belgium

Perfect. Fixed in v.1.2.2

Dear csuermann,

The startup behaviour stopped working; this might be caused by my recent update to Node-Red 1.0.3.

regards, ahartman

Hi @ahartman, I tried to verify this but could not reproduce your issue. Any additional info to debug this further would be appreciated. Thank you!

I restarted Node-Red with 'trace' debug level, nothing from suncron.
Deleted the node, put a new instance in the flow, configured it, problem solved!

regards, ahartman

Thank you for the update. Glad to hear it's working again, although the solution is somewhat unsatisfactory.