add support for receving only voltage
This commit is contained in:
parent
4cee82f28d
commit
1568eec6ee
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user