move id outside sensor block

This commit is contained in:
Nicu Hodos 2022-10-12 10:54:29 +02:00
parent 3b07c1c30c
commit 77c6c06a6a

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;