- temperature default values
- IR warnings
This commit is contained in:
Blaz Kristan 2021-05-26 21:33:40 +02:00
parent 6b5c2be701
commit 2f30451067
3 changed files with 14 additions and 6 deletions

View File

@ -238,8 +238,9 @@ class UsermodTemperature : public Usermod {
// we look for JSON object: {"Temperature": {"pin": 0, "degC": true}}
JsonObject top = root[FPSTR(_name)];
int8_t newTemperaturePin = temperaturePin;
if (top.isNull()) return;
if (!top.isNull() && top["pin"] != nullptr) {
if (top["pin"] != nullptr) {
if (top[FPSTR(_enabled)].is<bool>()) {
disabled = !top[FPSTR(_enabled)].as<bool>();
} else {
@ -247,6 +248,9 @@ class UsermodTemperature : public Usermod {
disabled = (bool)(str=="off"); // off is guaranteed to be present
}
newTemperaturePin = min(39,max(-1,top["pin"].as<int>()));
}
if (top["degC"] != nullptr) {
if (top["degC"].is<bool>()) {
// reading from cfg.json
degC = top["degC"].as<bool>();
@ -255,7 +259,13 @@ class UsermodTemperature : public Usermod {
String str = top["degC"]; // checkbox -> off or on
degC = (bool)(str!="off"); // off is guaranteed to be present
}
}
if (top[FPSTR(_readInterval)] != nullptr) {
readingInterval = min(120,max(10,top[FPSTR(_readInterval)].as<int>())) * 1000; // convert to ms
}
if (top[FPSTR(_parasite)] != nullptr) {
if (top[FPSTR(_parasite)].is<bool>()) {
// reading from cfg.json
parasite = top[FPSTR(_parasite)].as<bool>();
@ -264,8 +274,6 @@ class UsermodTemperature : public Usermod {
String str = top[FPSTR(_parasite)]; // checkbox -> off or on
parasite = (bool)(str!="off"); // off is guaranteed to be present
}
} else {
DEBUG_PRINTLN(F("No config found. (Using defaults.)"));
}
if (!initDone) {

View File

@ -570,7 +570,7 @@ void decodeIRJson(uint32_t code)
JsonObject fdo;
JsonObject jsonCmdObj;
sprintf_P(objKey, PSTR("\"0x%lX\":"), code);
sprintf_P(objKey, PSTR("\"0x%lX\":"), (unsigned long)code);
errorFlag = readObjectFromFile("/ir.json", objKey, &irDoc) ? ERR_NONE : ERR_FS_PLOAD;
fdo = irDoc.as<JsonObject>();
@ -643,7 +643,7 @@ void handleIR()
{
if (results.value != 0) // only print results if anything is received ( != 0 )
{
DEBUG_PRINTF("IR recv: 0x%lX\n", (uint32_t)results.value);
DEBUG_PRINTF("IR recv: 0x%lX\n", (unsigned long)results.value);
}
decodeIR(results.value);
irrecv->resume();

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2105261
#define VERSION 2105262
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG