Node-Red-Contrib-Timeout

I’ve just updated the node node-red-contrib-timeout. This is as always, available at https://flows.nodered.org also at https://www.npmjs.com/package/node-red-contrib-timeout

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.

tmp64E5

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

node-red-contrib-timeout

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

Facebooktwittergoogle_pluspinterestlinkedin

2 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

    Craig

Leave a Reply

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

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