diff --git a/lib/controller.js b/lib/controller.js index 3617adb41..c7a437b25 100644 --- a/lib/controller.js +++ b/lib/controller.js @@ -344,7 +344,7 @@ class Controller { async iteratePayloadAttributeOutput(topicRoot, payload, options) { for (const [key, value] of Object.entries(payload)) { let subPayload = value; - let message; + let message = null; // Special cases if (key === 'color' && utils.objectHasProperties(subPayload, ['r', 'g', 'b'])) { @@ -362,7 +362,9 @@ class Controller { message = typeof subPayload === 'string' ? subPayload : JSON.stringify(subPayload); } - await this.mqtt.publish(`${topicRoot}${key}`, message, options); + if (message !== null) { + await this.mqtt.publish(`${topicRoot}${key}`, message, options); + } } }