Add increment and decrement counter

6.0.0a
* Add increment and decrement value to command Counter (#2838)
This commit is contained in:
Theo Arends 2018-06-26 17:17:23 +02:00
parent 6a9a996e98
commit 54ef429fdc
2 changed files with 8 additions and 2 deletions

View File

@ -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)

View File

@ -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]);
}