diff --git a/gateway/include/TinyComponent.h b/gateway/include/TinyComponent.h index beb5c12..8625eb9 100644 --- a/gateway/include/TinyComponent.h +++ b/gateway/include/TinyComponent.h @@ -5,10 +5,12 @@ bool buildSensorJson(unsigned long value, JsonDocument& jsonDoc) { JsonObject sensor = jsonDoc.createNestedObject("sensor"); sensor["id"] = ID(value); + bool hasVoltage = false; float voltage = (float)GET_VCC(value) / 1000; if (voltage != 0) { JsonObject diagnostic = sensor.createNestedObject("diagnostic"); diagnostic["voltage"] = voltage; + hasVoltage = true; } switch (GET_TYPE(value)) { @@ -25,7 +27,7 @@ bool buildSensorJson(unsigned long value, JsonDocument& jsonDoc) { sensor["state"] = GET_STATE(value) ? "on" : "off"; break; default: - return false; + return hasVoltage; } return true;