add reset capability to rue node

This commit is contained in:
Dave Conway-Jones
2017-12-20 16:28:32 +00:00
parent 51124f456d
commit 032a9d6435
4 changed files with 71 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
{
"name" : "node-red-node-rbe",
"version" : "0.1.13",
"version" : "0.1.14",
"description" : "A Node-RED node that provides report-by-exception (RBE) and deadband capability.",
"dependencies" : {
},

View File

@@ -41,6 +41,9 @@
<dt class="optional">topic <span class="property-type">string</span>
</dt>
<dd>if specified the function will work on a per topic basis.</dd>
<dt class="optional">reset<span class="property-type">any</span></dt>
<dd>if set clears the stored value for the specified msg.topic, or
all topics if msg.topic is not specified.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">

View File

@@ -18,6 +18,12 @@ module.exports = function(RED) {
node.previous = {};
this.on("input",function(msg) {
if (msg.hasOwnProperty("reset")) {
if (msg.hasOwnProperty("topic") && (typeof msg.topic === "string") && (msg.topic !== "")) {
delete node.previous[msg.topic];
}
else { node.previous = {}; }
}
if (msg.hasOwnProperty("payload")) {
var t = msg.topic || "_no_topic";
if ((this.func === "rbe") || (this.func === "rbei")) {