# A clock node that will emit correct payload on startup?

**URL:** https://discourse.nodered.org/t/a-clock-node-that-will-emit-correct-payload-on-startup/16712
**Category:** General
**Created:** [15 October 2019 00:43 UTC](https://discourse.nodered.org/t/a-clock-node-that-will-emit-correct-payload-on-startup/16712 "2019-10-15T00:43:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![st2000](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@st2000](https://discourse.nodered.org/u/st2000)
#### Post date: [15 October 2019 00:43 UTC](https://discourse.nodered.org/t/a-clock-node-that-will-emit-correct-payload-on-startup/16712/1 "2019-10-15T00:43:15Z")

</div>

Is there an existing clock node that will emit the correct payload (for example, "on" or "off) on start up? Specifically, is there a clock node that will GO BACKWARDS to the last event in time and correctly set the payload?

I am currently using "schedex" and it appears there is no way to prompt it to go backwards to the last event. It looks like it only knows about the next two events. So, for example, you schedule to turn on lights at sun set and turn them off at sun rise. If you start NodeRed 1 minute after sun set, the lights will not turn on for at least another 23 hours. Ideally the lights would turn on when ever it is dark and NodeRed is started.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [15 October 2019 02:12 UTC](https://discourse.nodered.org/t/a-clock-node-that-will-emit-correct-payload-on-startup/16712/2 "2019-10-15T02:12:53Z")

</div>

What you are describing here is not _that_ simple.

There is a node: `big_timer` which can do a lot of what you want.  
[Here](https://flows.nodered.org/node/node-red-contrib-bigtimer)  
It sends messages at Sunrise/Sunset.

You send that output through a `switch` node to split between rise and set.  
Then when the message is received it does what it needs to, to open/close blinds, etc.

Not only does it do sunrise/set, but it does DAWN and DUSK, and a whole lot of other stuff.

It just may be for what you are looking.

Focusing on the question you asked:  
You use the `inject` node.  
Set it from _timestamp_ to what ever you want to inject, and tick the `inject at startup`.  
Oh, ironically the `inject` node defaults to `timestamp` which is the time at that point in . . . . . time.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [15 October 2019 07:39 UTC](https://discourse.nodered.org/t/a-clock-node-that-will-emit-correct-payload-on-startup/16712/3 "2019-10-15T07:39:05Z")

</div>

The node-red-node-timeswitch has two outputs - one that only sends at the switch times and one that sends every minute of the current state... as you require.
