From 548f45cd56ca249ca47ec94091ba5256dbba7e9f Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sat, 13 Jan 2018 22:53:58 +0000 Subject: [PATCH] Publish null/undefined to mqtt as blank not toString Fixes #1521 --- nodes/core/io/10-mqtt.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nodes/core/io/10-mqtt.js b/nodes/core/io/10-mqtt.js index c98a099f9..3f39dd3c9 100644 --- a/nodes/core/io/10-mqtt.js +++ b/nodes/core/io/10-mqtt.js @@ -291,7 +291,9 @@ module.exports = function(RED) { this.publish = function (msg) { if (node.connected) { - if (!Buffer.isBuffer(msg.payload)) { + if (msg.payload === null || msg.payload === undefined) { + msg.payload = ""; + } else if (!Buffer.isBuffer(msg.payload)) { if (typeof msg.payload === "object") { msg.payload = JSON.stringify(msg.payload); } else if (typeof msg.payload !== "string") {