Timer in node-red

Hi all,

I would like introduce a timer which run when an input occurs.
I'd like also that other commands runs while timer is running. For example while timer is running, if a gpio input turn on, I would stop, reset and change other paramenter of timer. this is possibile?
and I would like that other global var is set true or false when timer ends.

Maybe the dalay could be set externally from a dashboard input?

Many thanks

Om the surface what you are asking seems possible. Perhaps just a little more information? What are you trying to do, just a little more specific. What have you tried up to this point?

Thank you for your answer. I will add more informations.

I have a raspberry and I need read an input many times. the input is a series of pulse with a define timestep between them and after many pulses there a pause and then the train of pulses restart.

so my intention is:

  1. when I read the first pulse I start a countdown and if before countdown ends another pulse arrives, I reset countdown and restart it.
  2. when a train of pulse ends, the countdown arrives to 0 so I understand that the train of pulses is finished.
  3. I start now a new countdown relative the pause between trains of pulses. If countdown ends before the first pulse of the following train of pulses, an error message will be shown.

I hope is clearer than before. So I need start/stop/reset the timers externally (maybe by functions too or python-functions too) and I would like to set the timer duration from a dashboard input.

Many thanks

A Trigger node can do that.
Send nothing, then wait for msg.delay milliseconds.
Extend delay if new message arrives.
Reset by sending msg.reset or if msg.payload == 0

So nothing will be sent by the trigger unless the timeout expires.

How are you reading the pulses?

So play around with the ideas and try to build a flow, if you need more help come back and ask more questions

I'm using the MyTimeOut node for a long time as it is fully customizable

  • "on" or 1 - which turns on the timer and uses the default settings in the node (and issues an "on" on the output)
  • "off" or 0 - which turns off the timer (and issues an "off" on the output)
  • "stop" - which stops the timer (and issues a "stop" on the output)
  • "cancel" - which cancels the timer (and does not send any output)
  • Anything not listed above will be considered an on condition (a kicker or reset if you will)

i use it to manage my lights:

  • ON/OFF switch from my external trigger
  • Motion sensor will send "MOTION" to this timer. Command is umnknown and timer will reset/start
  • msg.timeout is specifiying the timer-duration which I adjust with a normal slider node

have fun trying out :wink:

Many thanks

I read pulse with gpio library and when inlet signal is true and when it turns false I would like start timer and if it turns true again before timer ends I would like stop timer and reset it. If timer end before next pulse I would send a message

Thank you nexus I try

Do you mean you use the standard GPIO In node which sends a message each time the input changes? If so then you are not strictly reading the pulses. Using the word 'read' implies that you take some action to fetch the value, whereas the pulse messages will be sent out of the GPIO node when they happen, not when you choose to read them.

exactly, I'm really sorry for using incorrect word.
I would like catch messages when pin status change and when it happens start or stop or reset timers.

I hope now it is clearer than before what I need to do.
Many thanks for your patient

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