mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-06-09 18:19:36 +00:00
auto-set a scheduler name if its empty
This commit is contained in:
@@ -82,7 +82,8 @@ StateUpdateResult WebScheduler::update(JsonObject root, WebScheduler & webSchedu
|
||||
EMSESP::webSchedulerService.ha_reset();
|
||||
|
||||
// build up the list of schedule items
|
||||
auto scheduleItems = root["schedule"].as<JsonArray>();
|
||||
uint8_t i = 0;
|
||||
auto scheduleItems = root["schedule"].as<JsonArray>();
|
||||
for (const JsonObject schedule : scheduleItems) {
|
||||
// create each schedule item, overwriting any previous settings
|
||||
// ignore the id (as this is only used in the web for table rendering)
|
||||
@@ -94,6 +95,10 @@ StateUpdateResult WebScheduler::update(JsonObject root, WebScheduler & webSchedu
|
||||
si.value = schedule["value"].as<std::string>();
|
||||
strlcpy(si.name, schedule["name"].as<const char *>(), sizeof(si.name));
|
||||
|
||||
if (si.name[0] == '\0') {
|
||||
snprintf(si.name, sizeof(si.name), "schedule_%d", i++); // set a default name. Before v3.9.0 we allowed empty schedule names.
|
||||
}
|
||||
|
||||
// calculated elapsed minutes
|
||||
si.elapsed_min = Helpers::string2minutes(si.time.c_str());
|
||||
si.retry_cnt = 0xFF; // no startup retries
|
||||
|
||||
Reference in New Issue
Block a user