mirror of https://github.com/arendst/Tasmota.git
Fix rule trigger support for status 11
Fix rule trigger support for status 11 (#9053)
This commit is contained in:
parent
89e7822975
commit
ecd06b6c83
|
@ -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<JsonObject>());
|
||||
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]"
|
||||
|
|
Loading…
Reference in New Issue