mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-12-27 07:21:08 +01:00
RBE node - let topic handling be optional (#751)
* let rbe handle topics optional and add tests * fix text formatting * Update package.json
This commit is contained in:
committed by
GitHub
parent
68e0b121ec
commit
9db89f3ea1
@@ -14,20 +14,25 @@ module.exports = function(RED) {
|
||||
}
|
||||
this.g = this.gap;
|
||||
this.property = n.property||"payload";
|
||||
this.septopics = true;
|
||||
if (n.septopics !== undefined && n.septopics === false) {
|
||||
this.septopics = false;
|
||||
}
|
||||
|
||||
var node = this;
|
||||
|
||||
node.previous = {};
|
||||
this.on("input",function(msg) {
|
||||
if (msg.hasOwnProperty("reset")) {
|
||||
if (msg.hasOwnProperty("topic") && (typeof msg.topic === "string") && (msg.topic !== "")) {
|
||||
if (node.septopics && msg.hasOwnProperty("topic") && (typeof msg.topic === "string") && (msg.topic !== "")) {
|
||||
delete node.previous[msg.topic];
|
||||
}
|
||||
else { node.previous = {}; }
|
||||
}
|
||||
var value = RED.util.getMessageProperty(msg,node.property);
|
||||
if (value !== undefined) {
|
||||
var t = msg.topic || "_no_topic";
|
||||
var t = "_no_topic";
|
||||
if (node.septopics) { t = msg.topic || t; }
|
||||
if ((this.func === "rbe") || (this.func === "rbei")) {
|
||||
var doSend = (this.func !== "rbei") || (node.previous.hasOwnProperty(t)) || false;
|
||||
if (typeof(value) === "object") {
|
||||
|
||||
Reference in New Issue
Block a user