From 98d2dd8f3989ef1a750e484e47ff6befeda2d392 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 15 Oct 2020 14:42:46 +0200 Subject: [PATCH] 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) --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + tasmota/xdrv_10_rules.ino | 14 ++++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60aa01b6e..cf6e093e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 6223962e3..2094cae68 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -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 diff --git a/tasmota/xdrv_10_rules.ino b/tasmota/xdrv_10_rules.ino index 2938e2d41..e5a041674 100644 --- a/tasmota/xdrv_10_rules.ino +++ b/tasmota/xdrv_10_rules.ino @@ -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; }