I’ve just fixed a startup bug in  my node-red-contrib-timeout node for Node-Red. This is as always, available at also at

The current version then is 1.1.3 which puts out the SAFE message at start-up and starts the default count-down.

Interested viewers will find that as well as the normal msg.payload showing the status, there also exists msg.countdown showing the remaining time in seconds.


You need to activate auto-repeat to use this  (v1.0.8 or later) feature. The node is a simple countdown timer, self-documenting. Here is an extract from the readme file:

‘ After setting the topic and both safe and unsafe messages, for, for example MQTT (or simply putting 1 and 0 into the two messages) the node is triggered by any input and will send the SAFE message out. If continually triggered nothing more will happen but if allowed to timeout, the UNSAFE message will be sent. Hence this can be used as a watchdog. Options include “repeat message every second” and “auto-restart when timed out”. As well as msg.payload showing “Safe”, “Warning” or “Unsafe”, there is also msg.countdown showing the remaining time in seconds.’


See also in the above image a simple function (not related to the timeout node but exceedingly useful anyway) which can show status info including the time and any object property within the Node-Red editing screen (not to be confused with the Dashboard””) – in this case msg.payload and msg.countdown. The function displays time correctly formatted. I recommend putting this in your Node-Red snippet library.

Number.prototype.pad = function(size) {
var s = String(this);
while (s.length < (size || 2)) {s = “0” + s;}
return s;
var date=new Date();
var now=Number(date.getHours()).pad(2)+ “:” + Number(date.getMinutes()).pad(2)+”:” + Number(date.getSeconds()).pad(2);
node.status({fill:”blue”,shape:”dot”,text:now + ” ” + msg.topic+”:”+msg.payload + ” ” +  msg.countdown});

See also: node-red-contrib-bigtimer, node-red-contrib-esplogin, node-red-diode


19 thoughts on “Node-Red-Contrib-Timeout

  1. Peter – thanks for this – just wondering is there any reason you tied the countdown output into the auto activate option ? i.e. i can not get countdown without enabling auto activate – i have looked at the JS file and can not see a reason for it – but do not want to copy you work just to enable the countdown output


  2. Great work Peter and thank you. I have been trying to get something similar working but my limited knowledge (still learning @69) of Node-Red programming is nowhere near your standard. This is going to be very useful in several security projects I’m working on.

    Appreciate the efforts you and others are putting into helping the newbies get to grips with Node-Red.

  3. i just installed this node. it seems timer is also triggered on node-red restart (without any input). can you please check ?

  4. Tried with auto-restart, same issue – timeout fired at restart of node-red server (without any input given to node)

    here are versions —

    node-red-contrib-timeout – 1.1.1
    node-red – 0.19.5
    on Ubuntu 18.04.2 LTS (on a regular computer , not raspberry pi)

    1. Yes, Timeout WILL timeout on restart of Node-Red. The input STOPS the timeout. I just attached a default Timeout node to debug and tested this. After 30 seconds it timed out – that is the intended operation.


      1. my mistake.
        here is what I am trying to do — i have a garage door status hooked to node red. I want to start the timer when it gets the message that door is open. and after a set time (let’s say 30 minutes) unless timer is cancelled (by garage close notification) it will send an alert. any thoughts if I could use bigtimer or timeout node for this functionality ?

  5. Hi Peter. Really like the Timeout node but it’s not working quite the way I intend.

    Whenever I deploy a flow It’s starting up in countdown mode, not in Timeout mode. For instance I have a stobe light I want to strobe for 1 day (86400 seconds). Safe payload set to 1 and unsafe to 0. No messages. So just want it to be a toggle input/output. Countdown when it receives 1. Timeout when it receives 0.

    But on deploy it starts it’s countdown at 86400 seconds. Anyway to start it in Timeout mode?


    1. Never mind. I found that I maybe should have been using the Trigger node.

      Out of interest what advantages would your Timeout have over Trigger?

      1. 1.1.4 onwards – you can set the node to unsafe immediately at any time by injecting “unsafe” to the input. Remember also that you can view the current count at any time.

  6. Thanks Peter.
    Still would be cool to have the option to start in Timeout Mode on deploy. For my scenario it would make it a one step process so more convenient.


  7. Hello Peter,
    I have a mailbox that when mail arrives opening the flap applies power to the esp8266 sending an MQTT message that “Mail has arrived” and casts it to Google Mini, repeating the message every 15 minutes. When I pick up the mail, to save on battery life, power is removed from the esp8266. I used your “timeout node” to stop sending messages once the timeout has expired (no trigger input for 20 minutes).
    The problem his when Node Red restarts the timeout restarts also, alerting me again that “Mail has arrived” even though there is no input.
    Is there a way that “timeout” could be started in warning mode until the first trigger arrives?. Maybe a check box next to “Safe”, “Unsafe, “Warning” to select “Startup/Restart Mode”
    Thank you for all your contributions Peter, from someone who has been around the Sun 76 times and still learning.

    1. Hi – I’m wary of making changes that might affect the many existing users…. maybe a function or other node added to prevent this?

      You can guarantee that any change of behaviour will upset SOMEONE….


  8. Thank you Peter for your prompt reply. I understand there may be consequences to making changes to the code. . . I was just looking for an easy way out 🙂
    Cheers from Toronto Canada

  9. Liam, one possibility is to use a ‘flag’ stored in EEPROM on your ESP8266 to ‘remember’ if the device has been triggered on that day, assuming mail is delivered once a day. Using a simple NTP time you could inhibit the ESP8266 output once a mail delivery has arrived for that day. Then reset the EEPROM flag at the start of the next day. EEPROM’s are good for 100,000 + writes but you could use a different flag for each day if you wanted.

Leave a Reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!

This site uses Akismet to reduce spam. Learn how your comment data is processed.