fix exec missing addpayload,

improve switch null test (to include null object)
check mqtt has payload before sending
This commit is contained in:
dceejay
2015-04-14 17:15:56 +01:00
parent 87e537da90
commit d7bdcd69fc
3 changed files with 4 additions and 3 deletions

View File

@@ -106,7 +106,7 @@ module.exports = function(RED) {
if (node.topic) {
msg.topic = node.topic;
}
if ((msg.hasOwnProperty("topic")) && (typeof msg.topic === "string") && (msg.topic !== "")) { // topic must exist
if (msg.hasOwnProperty("payload") && (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"); }