Example [email protected] flow

controltimer example flow controltimer example progress

NEW Feature

Change the type, duration and duration unit of controltimer by sending it a START message with additional data. See the example flow below for examples. All the other functionality (pausing, continuing, resetting) works as well for this.

The override options remain active until controltimer is manually stopped or it finishes itself. If it's later manually started without overriding the options again it will take the type, duration and duration unit from controltimer configuration.

You will not see the info on the node itself updated when you override it's config. Controltimer will run by your sent configuration but the visible info on the node itself will not be updated. You can ensure controltimer runs by your sent configuration if you look at the timer progress status below the node.

{
    payload: 'START',
    timerType: 'delay', // 'delay', 'loop'
    timerDuration: 3000,
    timerDurationUnit: 'millisecond', // 'millisecond', 'second', 'minute', 'hour'
}

Overview

A customizable Node-RED timer node which offers both looping and delay behaviour. The timer can be interacted with by action messages. Timer can be started, reset, stopped, paused and continued. The timer has two outputs - the first one outputs the message when timer is triggered (delay expires or interval is triggered) and the second one outputs the message when the running timer is stopped or paused.

Timer can be reset (timer will restart countdown from beginning) explicitly by the Reset action or when Is consecutive start action timer reset allowed option is enabled in addition to received Reset actions timer will be reset also every time a Start action is received. When Reset timer on receival of unknown message option is enabled the timer will be reset when it recieves an unknown message.

Timer can be paused and later continued. This applies to both looping and delay behaviour. Upon continuing it will count down the remaining duration.

For debugging or just to get an overview of timer progress you can enable Is running timer progress visible option. This will show timer progress in percentage of the total duration in the nodes status area.

You can disable specific actions for node. For example disable Reset, Pause and Continue actions. Now when a node recieves any of the aforementioned actions it will treat them as unknown messages.

[{"id":"afd749500f2d393d","type":"tab","label":"ControlTimer Example","disabled":false,"info":""},{"id":"79276f6f06e96f24","type":"inject","z":"afd749500f2d393d","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"START","payloadType":"str","x":110,"y":40,"wires":[["44e6d3eefa84eb4d"]]},{"id":"1ae1e3ee2f5250a6","type":"debug","z":"afd749500f2d393d","name":"TIMER TRIGGERED","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":680,"y":140,"wires":[]},{"id":"9711419041494ee9","type":"inject","z":"afd749500f2d393d","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"STOP","payloadType":"str","x":110,"y":80,"wires":[["44e6d3eefa84eb4d"]]},{"id":"2db5a47c85a55778","type":"inject","z":"afd749500f2d393d","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"RESET","payloadType":"str","x":110,"y":120,"wires":[["44e6d3eefa84eb4d"]]},{"id":"52882ab466bde0a2","type":"inject","z":"afd749500f2d393d","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"PAUSE","payloadType":"str","x":110,"y":160,"wires":[["44e6d3eefa84eb4d"]]},{"id":"5acb4a13897dfe33","type":"inject","z":"afd749500f2d393d","name":"CONTINUE","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"CONTINUE","payloadType":"str","x":130,"y":200,"wires":[["44e6d3eefa84eb4d"]]},{"id":"5c9aea117d0cb988","type":"debug","z":"afd749500f2d393d","name":"TIMER HALTED","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":180,"wires":[]},{"id":"bbd756d4850041fa","type":"inject","z":"afd749500f2d393d","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"UNKNOWN1","payloadType":"str","x":130,"y":240,"wires":[["44e6d3eefa84eb4d"]]},{"id":"76203a31872dca18","type":"inject","z":"afd749500f2d393d","name":"UNKNOWN2","props":[{"p":"unknown","v":"UNKNOWN2","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":280,"wires":[["44e6d3eefa84eb4d"]]},{"id":"01f89a1a0cfa1eb2","type":"inject","z":"afd749500f2d393d","name":"START (3000ms delay)","props":[{"p":"payload"},{"p":"timerType","v":"delay","vt":"str"},{"p":"timerDuration","v":"3000","vt":"num"},{"p":"timerDurationUnit","v":"millisecond","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"START","payloadType":"str","x":160,"y":320,"wires":[["44e6d3eefa84eb4d"]]},{"id":"c96f33f73a45a2a0","type":"inject","z":"afd749500f2d393d","name":"START (3000ms loop)","props":[{"p":"payload"},{"p":"timerType","v":"loop","vt":"str"},{"p":"timerDuration","v":"3000","vt":"num"},{"p":"timerDurationUnit","v":"millisecond","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"START","payloadType":"str","x":160,"y":360,"wires":[["44e6d3eefa84eb4d"]]},{"id":"44e6d3eefa84eb4d","type":"controltimer","z":"afd749500f2d393d","name":"","timerType":"delay","timerDurationUnit":"second","timerDurationType":"num","timerDuration":5,"timerLoopTimeoutUnit":"second","timerLoopTimeoutType":"num","timerLoopTimeout":0,"loopTimeoutMessageType":"str","loopTimeoutMessage":"LOOP_TIMEOUT","timerMaxLoopIterationsType":"num","timerMaxLoopIterations":0,"loopMaxIterationsMessageType":"str","loopMaxIterationsMessage":"MAX_LOOP_ITERATIONS","isConsecutiveStartActionTimerResetAllowed":false,"isRunningTimerProgressVisible":true,"outputReceivedMessageOnTimerTrigger":true,"outputReceivedMessageOnTimerHalt":false,"startTimerOnReceivalOfUnknownMessage":false,"resetTimerOnReceivalOfUnknownMessage":false,"isDebugModeEnabled":false,"timerTriggeredMessageType":"str","timerTriggeredMessage":"TIMER_TRIGGERED","timerHaltedMessageType":"str","timerHaltedMessage":"TIMER_HALTED","isStartActionEnabled":true,"isStopActionEnabled":true,"isResetActionEnabled":true,"isPauseActionEnabled":true,"isContinueActionEnabled":true,"actionPropertyNameType":"str","actionPropertyName":"payload","startActionNameType":"str","startActionName":"START","stopActionNameType":"str","stopActionName":"STOP","resetActionNameType":"str","resetActionName":"RESET","pauseActionNameType":"str","pauseActionName":"PAUSE","continueActionNameType":"str","continueActionName":"CONTINUE","x":440,"y":200,"wires":[["1ae1e3ee2f5250a6"],["5c9aea117d0cb988"]]}]

Flow Info

Created 2 years, 11 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • debug (x2)
  • inject (x9)
Other

Tags

  • timer
  • clock
  • interval
  • timeout
  • loop
  • delay
  • start
  • stop
  • pause
  • continue
  • reset
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option