Make MI Desk Lamp optional

Make MI Desk Lamp optional
This commit is contained in:
Theo Arends 2019-04-05 15:41:01 +02:00
parent 5e1cbcf94f
commit c673ea1728
2 changed files with 7 additions and 4 deletions

View File

@ -978,9 +978,12 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
if (strstr(dataBuf, "{") == nullptr) { // If no JSON it must be parameter
if ((payload > 0) && (payload <= MAXMODULE)) {
ModuleDefault(payload -1); // Copy template module
payload--;
if (ValidModule(payload)) {
ModuleDefault(payload); // Copy template module
if (USER_MODULE == Settings.module) { restart_flag = 2; }
}
}
else if (0 == payload) { // Copy current template to user template
if (Settings.module != USER_MODULE) {
ModuleDefault(Settings.module);

View File

@ -1023,8 +1023,8 @@ bool JsonTemplate(const char* dataBuf)
}
if (obj[D_JSON_BASE].success()) {
uint8_t base = obj[D_JSON_BASE];
if ((0 == base) || (base >= MAXMODULE)) { base = 17; } else { base--; }
Settings.user_template_base = base; // Default WEMOS
if ((0 == base) || !ValidModule(base -1)) { base = 18; }
Settings.user_template_base = base -1; // Default WEMOS
}
return true;
}