jensrossbach/node-red-contrib-chronos

SCHEDULER : Publish current event

xX-Nexus-Xx opened this issue · 5 comments

Hello,

thanks for providing this node, it works really well so far.

Is there a way to publish the current event?

Example: I have configured

  • SUNRISE will define DAYLIGHT as payload
  • SUNSET will define NIGHT as payload

If I restart the system at 11am, NR will not now the current event .. which is of course DAYLIGHT

Please let me know if there is a possibility to publish the current event? .. or if this can be provided in a future release

thx a lot

Hi @xX-Nexus-Xx, this is not in scope of the scheduler node.

But you could realize this easily with two inject nodes and two time filter nodes. Both inject nodes need to be configured to inject after deployment/loading (the checkbox at the bottom). The first inject node produces a message with payload DAYLIGHT and is connected to the first time filter node. The latter is configured to pass the message if ingress time is after sunrise and before sunset. The second inject node produces a message with payload NIGHT and is connected to the second time filter node. The latter is configured to pass the message if ingress time is after sunset and before sunrise.

Sorry. I was not clear enough before ... the daylight was just an example

I woul need an "UPDATE" trigger for the schedule node which is pushing thru the current event.

Another example:
I have a schedule defined from NOON time till SUNRISE start to run my Pool pump, as this is peak time for my solar panels.

In case I have to restart my stystem between NOON and SUNRISE, than my Pool pump will not start with your current scheduler. I would need to inject an UPDATE trigger to the scheduler to publish the current event and activate my Pool pump.

I have dozents of these events spcified and in normal operation the scheduler works fine, but sometimes it is necessary to publish the current event. It should be easily done internally as you already show the next event in the Node-Status.

Thanks for considering

I woul need an "UPDATE" trigger for the schedule node which is pushing thru the current event.

There is no "current" event existing. Events are single moments in time at which the node triggers something. What you request would be the last triggered event but the node does not remember events from the past, it triggers at certain moments and then forgets about the event.

I have a schedule defined from NOON time till SUNRISE start to run my Pool pump, as this is peak time for my solar panels.

As stated above, events are single moments in time and not time ranges, but I assume that you turn on your pump at noon and turn it off at sunrise (do you really mean sunrise or do you mean sunset?). So when you restart Node-RED within that time range, there shouldn't be a problem (your pump should continue to run), only if the down time of Node-RED would cover one of the time range borders.

It should be easily done internally as you already show the next event in the Node-Status.

Yes, the node knows about all upcoming events but not about past events. I don't see the point how triggering the next event could help (although implementing this would indeed be an easy thing).

I had some more thoughts about the topic and I can confirm that implementing an "UPDATE" trigger for the next upcoming event is easy to implement (as stated above), so I can add this in the next version.

But what is more or less impossible is to provide an "UPDATE" trigger for the previous event (i.e., the most recently past event). This is because scheduler node does not persist the actual time of past events (as already stated above) and it's also not possible to calculate past events (for instance because triggers could have a random offset and we do not know, what that random offset was or could have been; additionally, for crontable triggers, there is no API existing to fetch events from the past, only events from the future).

The new release 1.21.0 hopefully solves your issue. On one side, there is the new command trigger:next for scheduler node which triggers the next upcoming event. On the other hand, I added a brand new node, the so called state node, which internally maintains a state and can therefore provide the state value at any time. Feel free to try it out!