Fix rule handling of Var or Mem using text

Fix rule handling of Var or Mem using text regression from v8.5.0.1 (#9540)
This commit is contained in:
Theo Arends 2020-10-15 14:42:46 +02:00
parent 29e73dae9b
commit 98d2dd8f39
3 changed files with 12 additions and 4 deletions

View File

@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
- Convert AdcParam parameters from versions before v9.0.0.2
- Telegram message decoding error regression from v8.5.0.1
- Correct Energy period display shortly after midnight by gominoa (#9536)
- Rule handling of Var or Mem using text regression from v8.5.0.1 (#9540)
## [9.0.0.1] - 20201010
### Added

View File

@ -90,6 +90,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
- Light wakeup exception 0 (divide by zero) when ``WakeupDuration`` is not initialised (#9466)
- Thermostat sensor status corruption regression from v8.5.0.1 (#9449)
- Telegram message decoding error regression from v8.5.0.1
- Rule handling of Var or Mem using text regression from v8.5.0.1 (#9540)
- Correct Energy period display shortly after midnight by gominoa (#9536)
### Removed

View File

@ -498,10 +498,14 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule)
}
String buf = event; // copy the string into a new buffer that will be modified
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: RulesRuleMatch |%s|"), buf.c_str());
JsonParser parser((char*)buf.c_str());
JsonParserObject obj = parser.getRootObject();
if (!obj) {
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event too long (%d)"), event.length());
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event too long (%d)"), event.length());
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: No valid JSON (%s)"), buf.c_str());
return false; // No valid JSON data
}
String subtype;
@ -771,6 +775,8 @@ bool RulesProcessEvent(char *json_event)
ShowFreeMem(PSTR("RulesProcessEvent"));
#endif
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: ProcessEvent |%s|"), json_event);
String event_saved = json_event;
// json_event = {"INA219":{"Voltage":4.494,"Current":0.020,"Power":0.089}}
// json_event = {"System":{"Boot":1}}
@ -783,7 +789,7 @@ bool RulesProcessEvent(char *json_event)
}
event_saved.toUpperCase();
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event %s"), event_saved.c_str());
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event |%s|"), event_saved.c_str());
for (uint32_t i = 0; i < MAX_RULE_SETS; i++) {
if (GetRuleLen(i) && bitRead(Settings.rule_enabled, i)) {
@ -887,7 +893,7 @@ void RulesEvery50ms(void)
for (uint32_t i = 0; i < MAX_RULE_VARS; i++) {
if (bitRead(Rules.vars_event, i)) {
bitClear(Rules.vars_event, i);
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Var%d\":{\"State\":%s}}"), i+1, rules_vars[i]);
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Var%d\":{\"State\":\"%s\"}}"), i+1, rules_vars[i]);
RulesProcessEvent(json_event);
break;
}
@ -897,7 +903,7 @@ void RulesEvery50ms(void)
for (uint32_t i = 0; i < MAX_RULE_MEMS; i++) {
if (bitRead(Rules.mems_event, i)) {
bitClear(Rules.mems_event, i);
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Mem%d\":{\"State\":%s}}"), i+1, SettingsText(SET_MEM1 +i));
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Mem%d\":{\"State\":\"%s\"}}"), i+1, SettingsText(SET_MEM1 +i));
RulesProcessEvent(json_event);
break;
}