Publish null/undefined to mqtt as blank not toString

Fixes #1521
pull/1551/head
Nick O'Leary 2018-01-13 22:53:58 +00:00
parent 8ffabf1813
commit 548f45cd56
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 3 additions and 1 deletions

View File

@ -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") {