move id outside sensor block
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Nicu Hodos 2022-10-12 10:54:29 +02:00
parent 38d45bf866
commit 8e7c9d336d

View File

@ -61,28 +61,28 @@ void readRcSwitch(JsonDocument& jsonDoc) {
}
if (GET_TYPE(value) == SensorType::GENERIC) {
JsonObject sensor = jsonDoc.createNestedObject("sensor");
sensor["id"] = ID(value);
jsonDoc["id"] = ID(value);
sensor["value"] = GET_VALUE(value);
sensor["voltage"] = GET_VCC(value);
return;
}
if (GET_TYPE(value) == SensorType::TEMPERATURE) {
JsonObject sensor = jsonDoc.createNestedObject("sensor");
sensor["id"] = ID(value);
jsonDoc["id"] = ID(value);
sensor["temperature"] = GET_TEMP(value);
sensor["voltage"] = GET_VCC(value);
return;
}
if (GET_TYPE(value) == SensorType::HUMIDITY) {
JsonObject sensor = jsonDoc.createNestedObject("sensor");
sensor["id"] = ID(value);
jsonDoc["id"] = ID(value);
sensor["humidity"] = GET_HUMIDITY(value);
sensor["voltage"] = GET_VCC(value);
return;
}
if (GET_TYPE(value) == SensorType::CONTACT) {
JsonObject sensor = jsonDoc.createNestedObject("contact");
sensor["id"] = ID(value);
jsonDoc["id"] = ID(value);
sensor["state"] = GET_STATE(value) ? "on" : "off";
sensor["voltage"] = GET_VCC(value);
return;