From 32b76edb7c2a8325d7cef6fdf3d49052508a57c3 Mon Sep 17 00:00:00 2001 From: Andreas Brett Date: Mon, 22 Apr 2019 16:29:47 +0200 Subject: [PATCH] Improve non-JSON output (#1462) * Update controller.js Do not use JSON.stringify when outputting Non-JSON to MQTT. When using JSON.stringify strings are quoted in the MQTT messages but they should not be quoted (MQTT is different from JSON). * Update controller.js * Update controller.js * Update controller.js --- lib/controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/controller.js b/lib/controller.js index 65eee2d2d..27ceddc5c 100644 --- a/lib/controller.js +++ b/lib/controller.js @@ -257,10 +257,10 @@ class Controller { if (typeof messagePayload[key] == 'object') { Object.keys(messagePayload[key]).forEach((subKey) => { this.mqtt.publish(`${entity.friendlyName}/${key}-${subKey}`, - JSON.stringify(messagePayload[key][subKey]), options); + `${messagePayload[key][subKey]}`, options); }); } else { - this.mqtt.publish(`${entity.friendlyName}/${key}`, JSON.stringify(messagePayload[key]), options); + this.mqtt.publish(`${entity.friendlyName}/${key}`, `${messagePayload[key]}`, options); } }); }