Sets the delay, in milliseconds, to be applied to the message. This option only applies if the node is configured to allow the message to override the configured default delay interval. This does not apply when the node is configured to send at repeated intervals.
reset
If a message is received with this property, any timeout or repeat
currently in progress will be cleared and no message triggered.
@@ -35,6 +37,7 @@
act as a watchdog timer; only sending a message if nothing is received within the
set interval.
If set to a string type, the node supports the mustache template syntax.
+
The delay between sending messages can be overridden by msg.delay if that option is enabled in the node. The value must be provided in milliseconds.
If the node receives a message with a reset property, or a payload
that matches that configured in the node, any timeout or repeat currently in
progress will be cleared and no message triggered.
@@ -42,6 +45,6 @@
is reset by a received message.
Optionally, the node can be configured to treat messages as if they are separate streams,
using a msg property to identify each stream. Default msg.topic.
-
The status indicates the node is currently active. If multiple streams are used the status
+
The status indicates the node is currently active. If multiple streams are used the status
indicates the number of streams being held.
diff --git a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json
index e6d5da063..eb623ce20 100755
--- a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json
+++ b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json
@@ -320,6 +320,7 @@
"h": "Hours"
},
"extend": " extend delay if new message arrives",
+ "override": "override delay with msg.delay",
"second": " send second message to separate output",
"label": {
"trigger": "trigger",
diff --git a/test/nodes/core/function/89-trigger_spec.js b/test/nodes/core/function/89-trigger_spec.js
index 5502796ec..dd77b37d9 100644
--- a/test/nodes/core/function/89-trigger_spec.js
+++ b/test/nodes/core/function/89-trigger_spec.js
@@ -233,6 +233,65 @@ describe('trigger node', function() {
});
});
+ it('should ignore msg.delay if overrideDelay not set', function(done) {
+ var flow = [
+ {"id":"n1", "type":"trigger", "name":"triggerNode", duration:"50",wires:[["n2"]] },
+ {id:"n2", type:"helper"}
+ ];
+ helper.load(triggerNode, flow, function() {
+ var n1 = helper.getNode("n1");
+ var n2 = helper.getNode("n2");
+ var c = 0;
+ var firstTime;
+ n2.on("input", function(msg) {
+ if (c === 0) {
+ firstTime = Date.now();
+ } else if (c === 1) {
+ try {
+ var delta = Date.now() - firstTime;
+ delta.should.be.greaterThan(30);
+ delta.should.be.lessThan(100);
+ done();
+ } catch(err) {
+ done(err);
+ }
+ }
+ c++;
+ });
+ n1.emit("input", {payload:null, delay: 300});
+ });
+ });
+
+ it('should use msg.delay if overrideDelay is set', function(done) {
+ var flow = [
+ {"id":"n1", "type":"trigger", "name":"triggerNode", overrideDelay: true, duration:"50",wires:[["n2"]] },
+ {id:"n2", type:"helper"}
+ ];
+ helper.load(triggerNode, flow, function() {
+ var n1 = helper.getNode("n1");
+ var n2 = helper.getNode("n2");
+ var c = 0;
+ var firstTime;
+ n2.on("input", function(msg) {
+ if (c === 0) {
+ firstTime = Date.now();
+ } else if (c === 1) {
+ try {
+ var delta = Date.now() - firstTime;
+ delta.should.be.greaterThan(270);
+ delta.should.be.lessThan(380);
+ done();
+ } catch(err) {
+ done(err);
+ }
+ }
+ c++;
+ });
+ n1.emit("input", {payload:null, delay: 300});
+ });
+ });
+
+
it('should handle true and false as strings and delay of 0', function(done) {
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op1:"true",op1type:"val",op2:"false",op2type:"val",duration:"30", wires:[["n2"]] },
{id:"n2", type:"helper"} ];