# Wait until certain time

**URL:** <https://discourse.nodered.org/t/wait-until-certain-time/56124>\
**Category:** General\
**Created:** [5 January 2022 06:58 UTC](https://discourse.nodered.org/t/wait-until-certain-time/56124 "2022-01-05T06:58:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)\
**Post date:** [5 January 2022 06:58 UTC](https://discourse.nodered.org/t/wait-until-certain-time/56124/1 "2022-01-05T06:58:56Z")

</div>

Hi  
I want to have a node which waits for a certain time of the day (e.g. wait until 07:15) , so similar as the "wait until" node but to be defined as time of the day and not a waiting time in sec, min or what ever.  
How could this be implemented? Tx - JJ

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [5 January 2022 07:01 UTC](https://discourse.nodered.org/t/wait-until-certain-time/56124/2 "2022-01-05T07:01:53Z")

</div>

This is my first attempt at helping with a question, so pardon me if this does not suit your purpose.

Will this do?

```auto
[{"id":"dc4b6debfedd4f51","type":"inject","z":"c83d72886d5b02c0","name":"Start","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"start","payload":"schedule1","payloadType":"str","x":170,"y":70,"wires":[["ac710bce85890ac2"]]},{"id":"ac710bce85890ac2","type":"cronplus","z":"c83d72886d5b02c0","name":"@ 07:15","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"schedule1","payloadType":"default","payload":"","expressionType":"cron","expression":"0 15 7 * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":380,"y":160,"wires":[[]]},{"id":"77049032345f5f2d","type":"inject","z":"c83d72886d5b02c0","name":"Stop","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"stop","payload":"schedule1","payloadType":"str","x":130,"y":240,"wires":[["ac710bce85890ac2"]]}]

```

> **[node-red-contrib-cron-plus](https://flows.nodered.org/node/node-red-contrib-cron-plus)**
>
> A flexible scheduler (cron, solar events, simple dates) node for Node-RED with full dynamic control and Timezone support

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [5 January 2022 07:13 UTC](https://discourse.nodered.org/t/wait-until-certain-time/56124/3 "2022-01-05T07:13:35Z")

</div>

Please define what you mean by 'wait'. What is to happen to messages received before that time? What is to happen when a message is received after that time?

---

<div class="post-metadata">

**Author:** ![deputynl](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@deputynl](https://discourse.nodered.org/u/deputynl)\
**Post date:** [5 January 2022 12:58 UTC](https://discourse.nodered.org/t/wait-until-certain-time/56124/4 "2022-01-05T12:58:35Z")

</div>

Could you use a delay node and use a function node before it to calculate the number of seconds you need the message to wait before it is time? this calculated number could then be assigned to msg.delay, which would then delay the message until the required time.

---

<div class="post-metadata">

**Author:** ![juntiedt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/juntiedt/32/58357_2.png) [@juntiedt](https://discourse.nodered.org/u/juntiedt)\
**Post date:** [5 January 2022 13:38 UTC](https://discourse.nodered.org/t/wait-until-certain-time/56124/5 "2022-01-05T13:38:40Z")

</div>

create a timestamp of your time of day with moment node.  
Then, for example, you can calculate the difference to now and use delay.

---

<div class="post-metadata">

**Author:** ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)\
**Post date:** [5 January 2022 18:43 UTC](https://discourse.nodered.org/t/wait-until-certain-time/56124/6 "2022-01-05T18:43:24Z")

</div>

thank you all for your swift replies. Appreciate it.  
Just saw a simple solution to this: using the "wait until" node and compare the state of sensor.time from HA with the requested time of the day to wait for.  
So far, this looks to be working. JJ

```auto
[{"id":"03b7a98c0c145c0d","type":"ha-wait-until","z":"7ed51af36ab4bc6e","name":"","server":"a11aa034.815b8","version":0,"outputs":2,"entityId":"sensor.time","entityIdFilterType":"exact","property":"state","comparator":"is","value":"19:39","valueType":"str","timeout":"10","timeoutType":"num","timeoutUnits":"minutes","entityLocation":"data","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":297.2000045776367,"y":578.0000333786011,"wires":[["109cf48a5bbc8a5f"],[]]},{"id":"a11aa034.815b8","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [6 March 2022 18:43 UTC](https://discourse.nodered.org/t/wait-until-certain-time/56124/7 "2022-03-06T18:43:36Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
