diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index bc6b2dab0..7b60285d3 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -19,6 +19,9 @@ For more details go to [emsesp.org](https://emsesp.org/). - fix setting date/time on Junkers thermostats - offset of hpminflowtemp [#3144](https://github.com/emsesp/EMS-ESP32/issues/3144) - water circulation command [#3149](https://github.com/emsesp/EMS-ESP32/pull/3149) +- start scheduler after customEntities, delay scheduler loop after startup, handling of `system/restart` command [#3146](https://github.com/emsesp/EMS-ESP32/issues/3146) +- possible memory leaks fixed. +- repeated startup schedules compute value ## Changed @@ -27,4 +30,5 @@ For more details go to [emsesp.org](https://emsesp.org/). - network fallback to AP only after start [#3090](https://github.com/emsesp/EMS-ESP32/issues/3090) - replaced Web async-validator with custom validator and toast with native snackbar to reduce bundle size - Dewtemperature for Easycontrol calculated by ems-esp [#3135](https://github.com/emsesp/EMS-ESP32/issues/3135) -- add option for sync thermostat to ntp, allow different time zones [#3148](https://github.com/emsesp/EMS-ESP32/discussions/3148), **defaults to no sync**. +- add option for sync thermostat to ntp, allow different time zones [#3148](https://github.com/emsesp/EMS-ESP32/discussions/3148), **defaults to sync**. +- block too many GET requests [mentioned in #3104](https://github.com/emsesp/EMS-ESP32/issues/3104) diff --git a/src/core/analogsensor.cpp b/src/core/analogsensor.cpp index 44893d958..3fe91a4fa 100644 --- a/src/core/analogsensor.cpp +++ b/src/core/analogsensor.cpp @@ -537,11 +537,13 @@ bool AnalogSensor::update(uint8_t gpio, const char * org_name, double offset, do if (deleted) { LOG_DEBUG("Removing analog sensor GPIO %02d", gpio); EMSESP::system_.remove_gpio(gpio); // remove from used list only - EMSESP::nvs_.remove(AnalogCustomization.name); + if (EMSESP::nvs_.isKey(AnalogCustomization.name)) { + EMSESP::nvs_.remove(AnalogCustomization.name); + } settings.analogCustomizations.remove(AnalogCustomization); } else { // update existing record - if (!strcmp(name, AnalogCustomization.name)) { + if (!strcmp(name, AnalogCustomization.name) && EMSESP::nvs_.isKey(AnalogCustomization.name)) { EMSESP::nvs_.remove(AnalogCustomization.name); } strlcpy(AnalogCustomization.name, name, sizeof(AnalogCustomization.name)); diff --git a/src/core/emsesp.cpp b/src/core/emsesp.cpp index 9c75566bc..a117f0cfe 100644 --- a/src/core/emsesp.cpp +++ b/src/core/emsesp.cpp @@ -1799,8 +1799,8 @@ void EMSESP::start() { // this will also handle any MQTT subscriptions webCustomizationService.begin(); // load the customizations webCommandService.begin(); // load the user commands - webSchedulerService.begin(); // load the scheduler events webCustomEntityService.begin(); // load the custom telegram reads + webSchedulerService.begin(); // load the scheduler events // perform any system upgrades if (!factory_settings) { diff --git a/src/core/shuntingYard.cpp b/src/core/shuntingYard.cpp index 95cdeb26d..3cd0593f1 100644 --- a/src/core/shuntingYard.cpp +++ b/src/core/shuntingYard.cpp @@ -862,6 +862,7 @@ std::string compute(const std::string & expr) { } result = json.as(); } + expr_new.replace(f, e - f, result.c_str()); } } expr_new.replace(f, e - f, result); diff --git a/src/core/system.cpp b/src/core/system.cpp index 4a01ee7e7..97d90a487 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -1958,7 +1958,9 @@ bool System::get_value_info(JsonObject output, const char * cmd) { LOG_ERROR("empty system command"); return false; } - + if (!strcmp(cmd, "restart")) { // restart is a command, not an entity + return false; + } // check for hardcoded "info"/"value" if (!strcmp(cmd, F_(info)) || !strcmp(cmd, F_(values))) { return command_info("", 0, output); diff --git a/src/web/WebCustomEntityService.cpp b/src/web/WebCustomEntityService.cpp index a5ae53aa3..ee8be06e9 100644 --- a/src/web/WebCustomEntityService.cpp +++ b/src/web/WebCustomEntityService.cpp @@ -77,7 +77,9 @@ StateUpdateResult WebCustomEntity::update(JsonObject root, WebCustomEntity & web if (entityItem.ram == 2) { // NVS char key[sizeof(entityItem.name) + 2]; snprintf(key, sizeof(key), "c:%s", entityItem.name); - EMSESP::nvs_.remove(key); + if (EMSESP::nvs_.isKey(key)) { + EMSESP::nvs_.remove(key); + } } if (entityItem.ram) { // save name/value pairs for change checking doc[entityItem.name] = entityItem.value; diff --git a/src/web/WebSchedulerService.cpp b/src/web/WebSchedulerService.cpp index d788e0768..920a080ba 100644 --- a/src/web/WebSchedulerService.cpp +++ b/src/web/WebSchedulerService.cpp @@ -370,6 +370,10 @@ void WebSchedulerService::loop() { if (scheduleItems_->empty()) { return; } + // do not execute any command in the first 60 secondes + if (uuid::get_uptime_sec() < 60) { + return; + } // check if we have onChange events while (!cmd_changed_.empty()) {