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

In there, interested viewers will find that as well as the normal msg.payload showing the status, there is now also msg.countdown showing the remaining time in seconds.


You need to activate auto-repeat to use this new (v1.0.8) 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


3 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.

Leave a Reply

Your e-mail address will not be published. Required fields are marked *

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