Fix addition of backlog to IF clause

Fix addition of backlog to IF clause (#7342)
This commit is contained in:
Theo Arends 2019-12-31 17:17:30 +01:00
parent 5281725b9b
commit c13b755a59
1 changed files with 9 additions and 1 deletions

View File

@ -437,8 +437,16 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
commands.trim(); commands.trim();
String ucommand = commands; String ucommand = commands;
ucommand.toUpperCase(); ucommand.toUpperCase();
// if (!ucommand.startsWith("BACKLOG")) { commands = "backlog " + commands; } // Always use Backlog to prevent power race exception // if (!ucommand.startsWith("BACKLOG")) { commands = "backlog " + commands; } // Always use Backlog to prevent power race exception
if ((ucommand.indexOf("EVENT ") != -1) && (ucommand.indexOf("BACKLOG ") == -1)) { commands = "backlog " + commands; } // Always use Backlog with event to prevent rule event loop exception
// if ((ucommand.indexOf("EVENT ") != -1) && (ucommand.indexOf("BACKLOG ") == -1)) {
// commands = "backlog " + commands; // Always use Backlog with event to prevent rule event loop exception
// }
if ((ucommand.indexOf("IF ") == -1) && (ucommand.indexOf("EVENT ") != -1) && (ucommand.indexOf("BACKLOG ") == -1)) {
commands = "backlog " + commands; // Use Backlog with event unless IF is used which uses an implicit backlog to prevent rule event loop exception
}
RulesVarReplace(commands, F("%VALUE%"), Rules.event_value); RulesVarReplace(commands, F("%VALUE%"), Rules.event_value);
for (uint32_t i = 0; i < MAX_RULE_VARS; i++) { for (uint32_t i = 0; i < MAX_RULE_VARS; i++) {