mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
MQTT node - don't report missing topic if payload is missing...
This commit is contained in:
parent
d7bdcd69fc
commit
105d38c885
@ -106,10 +106,12 @@ module.exports = function(RED) {
|
|||||||
if (node.topic) {
|
if (node.topic) {
|
||||||
msg.topic = node.topic;
|
msg.topic = node.topic;
|
||||||
}
|
}
|
||||||
if (msg.hasOwnProperty("payload") && (msg.hasOwnProperty("topic")) && (typeof msg.topic === "string") && (msg.topic !== "")) { // topic must exist
|
if ( msg.hasOwnProperty("payload")) {
|
||||||
this.client.publish(msg); // send the message
|
if (msg.hasOwnProperty("topic") && (typeof msg.topic === "string") && (msg.topic !== "")) { // topic must exist
|
||||||
|
this.client.publish(msg); // send the message
|
||||||
|
}
|
||||||
|
else { node.warn("Invalid topic specified"); }
|
||||||
}
|
}
|
||||||
else { node.warn("Invalid topic specified"); }
|
|
||||||
});
|
});
|
||||||
this.client.on("connectionlost",function() {
|
this.client.on("connectionlost",function() {
|
||||||
node.status({fill:"red",shape:"ring",text:"disconnected"});
|
node.status({fill:"red",shape:"ring",text:"disconnected"});
|
||||||
|
Loading…
Reference in New Issue
Block a user