diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 1d0f2ece8..690fe4438 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,4 +1,5 @@ /* 6.1.1c + * Add option + to command Rule to concatenate new rule with existing rules (#3365) * Add initial support for sensor MPU6050 (#3352) * Add command SerialSend4 to send binary serial data (#3345) * Add rule triggers Wifi#Connected and Wifi#Disconnected (#3359) diff --git a/sonoff/xdrv_10_rules.ino b/sonoff/xdrv_10_rules.ino index cc2ec65d6..6bcfb4538 100644 --- a/sonoff/xdrv_10_rules.ino +++ b/sonoff/xdrv_10_rules.ino @@ -527,7 +527,18 @@ boolean RulesCommand() break; } } else { - strlcpy(Settings.rules[index -1], ('"' == XdrvMailbox.data[0]) ? "" : XdrvMailbox.data, sizeof(Settings.rules[index -1])); + int offset = 0; + if ('+' == XdrvMailbox.data[0]) { + offset = strlen(Settings.rules[index -1]); + if (XdrvMailbox.data_len < (sizeof(Settings.rules[index -1]) - offset -1)) { // Check free space + XdrvMailbox.data[0] = ' '; // Remove + and make sure at least one space is inserted + } else { + offset = -1; // Not enough space so skip it + } + } + if (offset != -1) { + strlcpy(Settings.rules[index -1] + offset, ('"' == XdrvMailbox.data[0]) ? "" : XdrvMailbox.data, sizeof(Settings.rules[index -1])); + } } rules_triggers[index -1] = 0; // Reset once flag }