Merge branch 'sensor-info' into dev
This commit is contained in:
commit
cc713e6c89
@ -321,6 +321,10 @@ public:
|
|||||||
} else {
|
} else {
|
||||||
infoArr.add(F("disabled"));
|
infoArr.add(F("disabled"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JsonObject sensor = root[F("sensor")];
|
||||||
|
if (sensor.isNull()) sensor = root.createNestedObject(F("sensor"));
|
||||||
|
sensor[F("motion")] = sensorPinState || offTimerStart>0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,9 +98,16 @@ class UsermodTemperature : public Usermod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void readTemperature() {
|
void readTemperature() {
|
||||||
temperature = readDallas();
|
float newTemp = readDallas();
|
||||||
lastMeasurement = millis();
|
|
||||||
waitingForConversion = false;
|
waitingForConversion = false;
|
||||||
|
if (temperature > -100.f && abs(newTemp-temperature)>10.) {
|
||||||
|
lastMeasurement = millis() - readingInterval + 5000; // speed up next reading
|
||||||
|
errorReading = true;
|
||||||
|
} else {
|
||||||
|
lastMeasurement = millis();
|
||||||
|
errorReading = false;
|
||||||
|
temperature = newTemp;
|
||||||
|
}
|
||||||
//DEBUG_PRINTF("Read temperature %2.1f.\n", temperature); // does not work properly on 8266
|
//DEBUG_PRINTF("Read temperature %2.1f.\n", temperature); // does not work properly on 8266
|
||||||
DEBUG_PRINT(F("Read temperature "));
|
DEBUG_PRINT(F("Read temperature "));
|
||||||
DEBUG_PRINTLN(temperature);
|
DEBUG_PRINTLN(temperature);
|
||||||
@ -229,7 +236,6 @@ class UsermodTemperature : public Usermod {
|
|||||||
if (user.isNull()) user = root.createNestedObject("u");
|
if (user.isNull()) user = root.createNestedObject("u");
|
||||||
|
|
||||||
JsonArray temp = user.createNestedArray(FPSTR(_name));
|
JsonArray temp = user.createNestedArray(FPSTR(_name));
|
||||||
//temp.add(F("Loaded."));
|
|
||||||
|
|
||||||
if (temperature <= -100.0f) {
|
if (temperature <= -100.0f) {
|
||||||
temp.add(0);
|
temp.add(0);
|
||||||
@ -237,9 +243,14 @@ class UsermodTemperature : public Usermod {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp.add(degC ? getTemperatureC() : getTemperatureF());
|
temp.add(degC ? temperature : (float)temperature * 1.8f + 32);
|
||||||
if (degC) temp.add(F("°C"));
|
temp.add(degC ? F("°C") : F("°F"));
|
||||||
else temp.add(F("°F"));
|
|
||||||
|
JsonObject sensor = root[F("sensor")];
|
||||||
|
if (sensor.isNull()) sensor = root.createNestedObject(F("sensor"));
|
||||||
|
temp = sensor.createNestedArray(F("temp"));
|
||||||
|
temp.add(degC ? temperature : (float)temperature * 1.8f + 32);
|
||||||
|
temp.add(degC ? F("°C") : F("°F"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user