From b56961c528b47dbe41950ea080f86a98885c7ef4 Mon Sep 17 00:00:00 2001 From: Theo Arends Date: Mon, 16 Jul 2018 11:34:44 +0200 Subject: [PATCH] Fix rules once regression Fix rules once regression from v6.1.0 (#3198, #3226) --- sonoff/_changelog.ino | 1 + sonoff/xdrv_10_rules.ino | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index bd6c1dd18..2983ee9de 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,4 +1,5 @@ /* 6.1.1b + * Fix rules once regression from v6.1.0 (#3198, #3226) * Add default Wifi Configuration tool as define WIFI_CONFIG_NO_SSID in user_config.h if no SSID is configured (#3224) * Add user selection of Wifi Smartconfig as define USE_SMARTCONFIG in user_config.h * Add user selection of WPS as define USE_WPS in user_config.h in preparation for core v2.4.2 (#3221) diff --git a/sonoff/xdrv_10_rules.ino b/sonoff/xdrv_10_rules.ino index 1218b9854..54a04fbc6 100644 --- a/sonoff/xdrv_10_rules.ino +++ b/sonoff/xdrv_10_rules.ino @@ -253,7 +253,7 @@ bool RulesRuleMatch(byte rule_set, String &event, String &rule) } } else match = true; - if (Settings.flag.rules_once) { + if (bitRead(Settings.rule_once, rule_set)) { if (match) { // Only allow match state changes if (!bitRead(rules_triggers[rule_set], rules_trigger_count[rule_set])) { bitSet(rules_triggers[rule_set], rules_trigger_count[rule_set]); @@ -610,20 +610,21 @@ double map_double(double x, double in_min, double in_max, double out_min, double } // Function to return a substring defined by a delimiter at an index -char* subStr (char* str, const char *delim, int index) { - char *act, *sub, *ptr; +char* subStr (char* str, const char *delim, int index) +{ + char *act; + char *sub; + char *ptr; static char copy[10]; int i; // Since strtok consumes the first arg, make a copy strcpy(copy, str); - for (i = 1, act = copy; i <= index; i++, act = NULL) { - sub = strtok_r(act, delim, &ptr); - if (sub == NULL) break; + sub = strtok_r(act, delim, &ptr); + if (sub == NULL) break; } - sub = LTrim(sub); - sub = RTrim(sub); + sub = Trim(sub); return sub; }