From e5a8fd7be47a4bf8f2b7868364d2c869c8cc592b Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Tue, 25 Jun 2024 15:28:05 +0200 Subject: [PATCH 1/4] german translation #1800 --- interface/src/i18n/de/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/i18n/de/index.ts b/interface/src/i18n/de/index.ts index 992cce5f5..fbbcc2328 100644 --- a/interface/src/i18n/de/index.ts +++ b/interface/src/i18n/de/index.ts @@ -53,7 +53,7 @@ const de: Translation = { UPDATE_OF: '{0} Aktualisieren', REMOVED_OF: '{0} Entfernt', DELETION_OF: '{0} Löschung', - OFFSET: 'Addition', + OFFSET: 'Position', FACTOR: 'Faktor', FREQ: 'Frequenz', DUTY_CYCLE: 'Duty Cycle', From 03513be144a4e27be6a68735e122d4a5187fd06d Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Thu, 27 Jun 2024 08:26:16 +0200 Subject: [PATCH 2/4] add heatingactive/tapwateractive to onChange #1806 --- src/devices/boiler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index e78bbf567..14fcd8789 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -1079,7 +1079,7 @@ void Boiler::check_active() { b = ((boilerState_ & 0x09) == 0x09); val = b ? EMS_VALUE_BOOL_ON : EMS_VALUE_BOOL_OFF; if (heatingActive_ != val) { - heatingActive_ = val; + has_update(heatingActive_, val); char s[12]; Mqtt::queue_publish(F_(heating_active), Helpers::render_boolean(s, b)); } @@ -1103,7 +1103,7 @@ void Boiler::check_active() { val = b ? EMS_VALUE_BOOL_ON : EMS_VALUE_BOOL_OFF; if (tapwaterActive_ != val) { - tapwaterActive_ = val; + has_update(tapwaterActive_, val); char s[12]; Mqtt::queue_publish(F_(tapwater_active), Helpers::render_boolean(s, b)); // if (flowsensor) { From a46b9c60ddff269714cd242be6b905fb2f131cfe Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Thu, 27 Jun 2024 08:27:16 +0200 Subject: [PATCH 3/4] allow multiple onChange schedules with same trigger #1806 --- src/web/WebSchedulerService.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/web/WebSchedulerService.cpp b/src/web/WebSchedulerService.cpp index 1a0a86c6e..fb03487cb 100644 --- a/src/web/WebSchedulerService.cpp +++ b/src/web/WebSchedulerService.cpp @@ -371,16 +371,17 @@ bool WebSchedulerService::command(const char * cmd, const char * data) { #include "shuntingYard.hpp" bool WebSchedulerService::onChange(const char * cmd) { + bool cmd_ok = false; for (const ScheduleItem & scheduleItem : *scheduleItems_) { if (scheduleItem.active && scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_ONCHANGE && Helpers::toLower(scheduleItem.time).find(Helpers::toLower(cmd)) != std::string::npos) { #ifdef EMESESP_DEBUG // emsesp::EMSESP::logger().debug(scheduleItem.cmd.c_str()); #endif - return command(scheduleItem.cmd.c_str(), compute(scheduleItem.value).c_str()); + cmd_ok |= command(scheduleItem.cmd.c_str(), compute(scheduleItem.value).c_str()); } } - return false; + return cmd_ok; } void WebSchedulerService::condition() { From 266a7a4e9b9c3275f22b9d97ca444d9c5e0705aa Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Thu, 27 Jun 2024 08:28:38 +0200 Subject: [PATCH 4/4] allow multiple instances of "?:" in a schedule --- src/web/shuntingYard.hpp | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/web/shuntingYard.hpp b/src/web/shuntingYard.hpp index 208297878..83a44bdf2 100644 --- a/src/web/shuntingYard.hpp +++ b/src/web/shuntingYard.hpp @@ -558,16 +558,33 @@ std::string calculate(const std::string & expr) { } return stack.back(); } -// check for ? : + +// check for multiple instances of ? : std::string compute(const std::string & expr) { - auto q = expr.find_first_of("?"); - auto p = expr.find_first_of(":", q); - if (p != std::string::npos && q != std::string::npos) { - if (calculate(expr.substr(0, q))[0] == '1') { - return calculate(expr.substr(q + 1, p - q - 1)); - } else { - return calculate(expr.substr(p + 1)); + auto expr_new = expr; + // positions: q-questionmark, c-colon + auto q = expr_new.find_first_of("?"); + while (q != std::string::npos) { + // find corresponding colon + auto c1 = expr_new.find_first_of(":", q + 1); + auto q1 = expr_new.find_first_of("?", q + 1); + while (q1 < c1 && q1 != std::string::npos && c1 != std::string::npos) { + q1 = expr_new.find_first_of("?", q1 + 1); + c1 = expr_new.find_first_of(":", c1 + 1); } + if (c1 == std::string::npos) { + return ""; // error: missing colon + } + std::string cond = calculate(expr_new.substr(0, q)); + if (cond[0] == '1') { + expr_new.erase(c1); // remove second expression after colon + expr_new.erase(0, q + 1); // remove condition before questionmark + } else if (cond[0] == '0') { + expr_new.erase(0, c1 + 1); // remove condition and first expression + } else { + return ""; // error + } + q = expr_new.find_first_of("?"); // search next instance } - return calculate(expr); + return calculate(expr_new); }