From 44b26f9b227ef9b24818ff43f78c658f971b68a3 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Mon, 27 Jul 2020 23:04:05 +0200 Subject: [PATCH] Parse attribute payload to JSON if possible. https://github.com/Koenkk/zigbee-herdsman-converters/pull/1427 --- lib/extension/publish.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/extension/publish.js b/lib/extension/publish.js index 39eb33d62..866f611df 100644 --- a/lib/extension/publish.js +++ b/lib/extension/publish.js @@ -102,7 +102,11 @@ class EntityPublish extends Extension { // Convert the MQTT message to a Zigbee message. let json = {}; if (topic.hasOwnProperty('attribute') && topic.attribute) { - json[topic.attribute] = message; + try { + json[topic.attribute] = JSON.parse(message); + } catch (e) { + json[topic.attribute] = message; + } } else { try { json = JSON.parse(message);