# Question on timer

**URL:** <https://discourse.nodered.org/t/question-on-timer/76098>\
**Category:** General\
**Created:** [4 March 2023 09:06 UTC](https://discourse.nodered.org/t/question-on-timer/76098 "2023-03-04T09:06:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fvsc](https://avatars.discourse-cdn.com/v4/letter/f/cab0a1/32.png) [@fvsc](https://discourse.nodered.org/u/fvsc)\
**Post date:** [4 March 2023 09:06 UTC](https://discourse.nodered.org/t/question-on-timer/76098/1 "2023-03-04T09:06:35Z")

</div>

Hello all.  
I'm new to Node Red and I have I question about timers.  
I receive several MQTT msg for different motion sensors and these control different lamps which must stay on for different times.  
My question:  
is the a timer node which can be started several times, always for a diferent time, by the incoming msg an trigger an output when time 1 triggers and again when time 2 triggers and so on.  
Or do I need to use several timer nodes?

---

<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:** [4 March 2023 09:11 UTC](https://discourse.nodered.org/t/question-on-timer/76098/2 "2023-03-04T09:11:28Z")

</div>

Hi and welcome to the forum.

Which `timer` node are you using?

If each lamp stays on for a fixed time (but each one is different) you could use the `trigger` node.

Just before the `trigger` node you would place a `change` node and set `msg.delay` to the value of milliseconds that lamp needs to be on for.

eg: If for 10 seconds you would set `msg.delay` to `10000`  
Then tick the `override with msg.delay` option.

Then in the `trigger` node send `on` then `off` to turn the lamp `on` and `off`.

---

<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:** [4 March 2023 09:44 UTC](https://discourse.nodered.org/t/question-on-timer/76098/3 "2023-03-04T09:44:46Z")

</div>

Or if the On time is always the same for a particular lamp then you can configure the time in the Trigger node for that lamp, rather than in the message.

---

<div class="post-metadata">

**Author:** ![fvsc](https://avatars.discourse-cdn.com/v4/letter/f/cab0a1/32.png) [@fvsc](https://discourse.nodered.org/u/fvsc)\
**Post date:** [4 March 2023 10:15 UTC](https://discourse.nodered.org/t/question-on-timer/76098/4 "2023-03-04T10:15:39Z")

</div>

@ Trying\_to\_learn and @ Co,lin

Thanks for the reply.

I use the countdown node.  
I'll read the description of the trigger and change node and try them out.  
I let you know the result.

---

<div class="post-metadata">

**Author:** ![fvsc](https://avatars.discourse-cdn.com/v4/letter/f/cab0a1/32.png) [@fvsc](https://discourse.nodered.org/u/fvsc)\
**Post date:** [4 March 2023 11:09 UTC](https://discourse.nodered.org/t/question-on-timer/76098/5 "2023-03-04T11:09:24Z")

</div>

As far as I understand those nodes this is not and answer on my question.

Let me try to describe my flow.

1. mqtt msg received from sensor\_1 goes
2. to function node to check for night and if other lamps already on in that room and if Ok send
3. command lamp\_1
4. the same function node is used for sensor\_2, \_3, \_4 and lamp\_2, \_3, \_4

now the question i have: is it possible with 1 node to start multiple different timers, one for each sensor / lamp combination or do I need a separate timer node for each sensor / lamp combination?

But maybe I misunderstood your answers.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [4 March 2023 11:18 UTC](https://discourse.nodered.org/t/question-on-timer/76098/6 "2023-03-04T11:18:56Z")

</div>

The trigger node can handle each property you wish as separate delays and delay times.  
e.g.

```auto
[{"id":"1f2406cc91a112ea","type":"inject","z":"65617ffeb779f51c","name":"","props":[{"p":"payload"},{"p":"delay","v":"3000","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"lamp1","payloadType":"str","x":110,"y":320,"wires":[["8734edfbf6593760"]]},{"id":"8734edfbf6593760","type":"trigger","z":"65617ffeb779f51c","name":"","op1":"on","op2":"off","op1type":"str","op2type":"str","duration":"30","extend":true,"overrideDelay":true,"units":"s","reset":"","bytopic":"topic","topic":"payload","outputs":1,"x":310,"y":380,"wires":[["752f9e00aec8eaa2"]]},{"id":"449afa77421c1947","type":"inject","z":"65617ffeb779f51c","name":"","props":[{"p":"payload"},{"p":"delay","v":"5000","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"lamp2","payloadType":"str","x":90,"y":380,"wires":[["8734edfbf6593760"]]},{"id":"faa494c287263735","type":"inject","z":"65617ffeb779f51c","name":"","props":[{"p":"payload"},{"p":"delay","v":"10000","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"lamp3","payloadType":"str","x":90,"y":440,"wires":[["8734edfbf6593760"]]},{"id":"752f9e00aec8eaa2","type":"debug","z":"65617ffeb779f51c","name":"debug 237","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":380,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![fvsc](https://avatars.discourse-cdn.com/v4/letter/f/cab0a1/32.png) [@fvsc](https://discourse.nodered.org/u/fvsc)\
**Post date:** [4 March 2023 11:42 UTC](https://discourse.nodered.org/t/question-on-timer/76098/7 "2023-03-04T11:42:59Z")

</div>

Thanks.  
And is it possible to see from which input the off msg is coming.  
I mean if the delay of lamp1 expires how can one see it is from lamp1.

Edit:  
I found it: send original msg.

It is working. thanks for the information.

---

<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:** [18 March 2023 11:43 UTC](https://discourse.nodered.org/t/question-on-timer/76098/8 "2023-03-18T11:43:13Z")

</div>

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