Fix rules once regression

Fix rules once regression from v6.1.0 (#3198, #3226)
This commit is contained in:
Theo Arends 2018-07-16 11:34:44 +02:00
parent ace6180e67
commit b56961c528
2 changed files with 10 additions and 8 deletions

View File

@ -1,4 +1,5 @@
/* 6.1.1b /* 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 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 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) * Add user selection of WPS as define USE_WPS in user_config.h in preparation for core v2.4.2 (#3221)

View File

@ -253,7 +253,7 @@ bool RulesRuleMatch(byte rule_set, String &event, String &rule)
} }
} else match = true; } else match = true;
if (Settings.flag.rules_once) { if (bitRead(Settings.rule_once, rule_set)) {
if (match) { // Only allow match state changes if (match) { // Only allow match state changes
if (!bitRead(rules_triggers[rule_set], rules_trigger_count[rule_set])) { if (!bitRead(rules_triggers[rule_set], rules_trigger_count[rule_set])) {
bitSet(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 // Function to return a substring defined by a delimiter at an index
char* subStr (char* str, const char *delim, int index) { char* subStr (char* str, const char *delim, int index)
char *act, *sub, *ptr; {
char *act;
char *sub;
char *ptr;
static char copy[10]; static char copy[10];
int i; int i;
// Since strtok consumes the first arg, make a copy // Since strtok consumes the first arg, make a copy
strcpy(copy, str); strcpy(copy, str);
for (i = 1, act = copy; i <= index; i++, act = NULL) { for (i = 1, act = copy; i <= index; i++, act = NULL) {
sub = strtok_r(act, delim, &ptr); sub = strtok_r(act, delim, &ptr);
if (sub == NULL) break; if (sub == NULL) break;
} }
sub = LTrim(sub); sub = Trim(sub);
sub = RTrim(sub);
return sub; return sub;
} }