diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index 59cada7e3..ebb583725 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -1,4 +1,5 @@ /* 6.0.0a + * Add increment and decrement value to command Counter (#2838) * Add option 0 to command Timers disarming all timers (#2962) * Add time in minutes to rule Time#Initialized, Time#set and Time#Minute (#2669) * Add rule variables %time% for minutes since midnight, %uptime%, %sunrise% and %sunset% giving time in minutes (#2669) diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index fec987722..c2ade9636 100644 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -797,8 +797,13 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len) } else if ((CMND_COUNTER == command_code) && (index > 0) && (index <= MAX_COUNTERS)) { if ((data_len > 0) && (pin[GPIO_CNTR1 + index -1] < 99)) { - RtcSettings.pulse_counter[index -1] = payload16; - Settings.pulse_counter[index -1] = payload16; + if ((dataBuf[0] == '-') || (dataBuf[0] == '+')) { + RtcSettings.pulse_counter[index -1] += payload32; + Settings.pulse_counter[index -1] += payload32; + } else { + RtcSettings.pulse_counter[index -1] = payload32; + Settings.pulse_counter[index -1] = payload32; + } } snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_LVALUE, command, index, RtcSettings.pulse_counter[index -1]); }