diff --git a/tasmota/xdrv_10_rules.ino b/tasmota/xdrv_10_rules.ino index 47c789935..c2c9af422 100644 --- a/tasmota/xdrv_10_rules.ino +++ b/tasmota/xdrv_10_rules.ino @@ -497,25 +497,30 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule) rule_name = rule_name.substring(0, pos); // "SUBTYPE1#CURRENT" } - StaticJsonBuffer<1024> jsonBuf; + StaticJsonBuffer<1280> jsonBuf; // Was 1024 until 20200811 JsonObject &root = jsonBuf.parseObject(event); - if (!root.success()) { return false; } // No valid JSON data + if (!root.success()) { + AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event too long (%d)"), event.length()); + return false; + } // No valid JSON data JsonObject *obj = &root; String subtype; uint32_t i = 0; while ((pos = rule_name.indexOf("#")) > 0) { // "SUBTYPE1#SUBTYPE2#CURRENT" subtype = rule_name.substring(0, pos); const JsonVariant & val = GetCaseInsensitive(*obj, subtype.c_str()); - if (nullptr == &val) { return false; } // not found + if (nullptr == &val) { return false; } // not found obj = &(val.as()); - if (!obj->success()) { return false; } // not a JsonObject + if (!obj->success()) { return false; } // not a JsonObject rule_name = rule_name.substring(pos +1); if (i++ > 10) { return false; } // Abandon possible loop + + yield(); } const JsonVariant & val = GetCaseInsensitive(*obj, rule_name.c_str()); - if (nullptr == &val) { return false; } // last level not found + if (nullptr == &val) { return false; } // last level not found const char* str_value; if (rule_name_idx) { str_value = (*obj)[rule_name][rule_name_idx -1]; // "CURRENT[1]"