diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index 79f4bff7..017240c2 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -574,7 +574,16 @@ unsigned char _mqttBuildTree(JsonObject& root, char parent) { JsonObject& elements = root.createNestedObject(element.topic); unsigned char num = _mqttBuildTree(elements, i); if (0 == num) { - root.set(element.topic, element.message); + if (isNumber(element.message)) { + double value = atof(element.message); + if (value == int(value)) { + root.set(element.topic, int(value)); + } else { + root.set(element.topic, value); + } + } else { + root.set(element.topic, element.message); + } } } } diff --git a/code/espurna/utils.ino b/code/espurna/utils.ino index ff57da9c..1203788d 100644 --- a/code/espurna/utils.ino +++ b/code/espurna/utils.ino @@ -451,6 +451,7 @@ int __get_adc_mode() { bool isNumber(const char * s) { unsigned char len = strlen(s); + if (0 == len) return false; bool decimal = false; for (unsigned char i=0; i