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");
|
JsonObject sensor = jsonDoc.createNestedObject("sensor");
|
||||||
sensor["id"] = ID(value);
|
sensor["id"] = ID(value);
|
||||||
|
|
||||||
|
bool hasVoltage = false;
|
||||||
float voltage = (float)GET_VCC(value) / 1000;
|
float voltage = (float)GET_VCC(value) / 1000;
|
||||||
if (voltage != 0) {
|
if (voltage != 0) {
|
||||||
JsonObject diagnostic = sensor.createNestedObject("diagnostic");
|
JsonObject diagnostic = sensor.createNestedObject("diagnostic");
|
||||||
diagnostic["voltage"] = voltage;
|
diagnostic["voltage"] = voltage;
|
||||||
|
hasVoltage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (GET_TYPE(value)) {
|
switch (GET_TYPE(value)) {
|
||||||
@ -25,7 +27,7 @@ bool buildSensorJson(unsigned long value, JsonDocument& jsonDoc) {
|
|||||||
sensor["state"] = GET_STATE(value) ? "on" : "off";
|
sensor["state"] = GET_STATE(value) ? "on" : "off";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return hasVoltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user