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
This commit is contained in:
Andreas Brett
2019-04-22 16:29:47 +02:00
committed by Koen Kanters
parent 0eaf0ad5d6
commit 32b76edb7c
+2 -2
View File
@@ -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);
}
});
}