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.
This commit is contained in:
Adrian Scillato 2019-11-12 15:54:29 -03:00 committed by GitHub
parent a1616b48ce
commit 6f614369c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;