From 6f614369c1433d13d9bf286a36b223360984413c Mon Sep 17 00:00:00 2001 From: Adrian Scillato <35405447+ascillato@users.noreply.github.com> Date: Tue, 12 Nov 2019 15:54:29 -0300 Subject: [PATCH] Fix Rules Evaluation when using break and several triggers are true When checking several triggers that were true at the same time and BREAK was being used, some rules were not executed. The rule: rule3 on system#boot do var4 0 break on tele-SI7021#temperature do var4 %value% endon on tele-SI7021#humidity do var5 %value% endon was not triggering the third statement. --- tasmota/xdrv_10_rules.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasmota/xdrv_10_rules.ino b/tasmota/xdrv_10_rules.ino index d1f8ca49a..64ae42f1c 100644 --- a/tasmota/xdrv_10_rules.ino +++ b/tasmota/xdrv_10_rules.ino @@ -425,16 +425,15 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved) if (plen == -1) { plen = 9999; } if (plen2 == -1) { plen2 = 9999; } plen = tmin(plen, plen2); - if (plen == plen2) { stop_all_rules = true; } // If BREAK was used, Stop execution of this rule set String commands = rules.substring(pevt +4, plen); // "Backlog Dimmer 10;Color 100000" - plen += 6; Rules.event_value = ""; String event = event_saved; //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event |%s|, Rule |%s|, Command(s) |%s|"), event.c_str(), event_trigger.c_str(), commands.c_str()); if (RulesRuleMatch(rule_set, event, event_trigger)) { + if (plen == plen2) { stop_all_rules = true; } // If BREAK was used on a triggered rule, Stop execution of this rule set commands.trim(); String ucommand = commands; ucommand.toUpperCase(); @@ -473,6 +472,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved) serviced = true; if (stop_all_rules) { return serviced; } // If BREAK was used, Stop execution of this rule set } + plen += 6; Rules.trigger_count[rule_set]++; } return serviced;