From aefb3fb9de0e2f43afd54665006009a99d030eb8 Mon Sep 17 00:00:00 2001 From: Andre Thomas <470015+andrethomas@users.noreply.github.com> Date: Sat, 28 Dec 2019 16:47:30 +0200 Subject: [PATCH 1/3] Reserve SetOption79 Used to enable resetting of the counter values to zero after telemetry data was transmitted. --- tasmota/settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/settings.h b/tasmota/settings.h index eddc4f04b..0c47e5aca 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -92,7 +92,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t bootcount_update : 1; // bit 26 (v7.0.0.4) - SetOption76 - Enable incrementing bootcount when deepsleep is enabled uint32_t slider_dimmer_stay_on : 1; // bit 27 (v7.0.0.6) - SetOption77 - Do not power off if slider moved to far left uint32_t compatibility_check : 1; // bit 28 (v7.1.2.6) - SetOption78 - Disable OTA compatibility check - uint32_t spare29 : 1; + uint32_t counter_reset_on_tele : 1; // bit 29 (v8.1.0.1) - SetOption79 - Enable resetting of counters after telemetry was sent uint32_t shutter_mode : 1; // bit 30 (v6.6.0.14) - SetOption80 - Enable shutter support uint32_t pcf8574_ports_inverted : 1; // bit 31 (v6.6.0.14) - SetOption81 - Invert all ports on PCF8574 devices }; From 436cf830b9b5690d3f41a122160352c5106d87cf Mon Sep 17 00:00:00 2001 From: Andre Thomas <470015+andrethomas@users.noreply.github.com> Date: Sat, 28 Dec 2019 16:49:57 +0200 Subject: [PATCH 2/3] Add support for resetting counters on tele_period Add support for resetting counters on tele_period if SetOption78 is enabled. --- tasmota/xsns_01_counter.ino | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasmota/xsns_01_counter.ino b/tasmota/xsns_01_counter.ino index 8ed615c86..c664ff811 100644 --- a/tasmota/xsns_01_counter.ino +++ b/tasmota/xsns_01_counter.ino @@ -150,6 +150,9 @@ void CounterShow(bool json) ResponseAppend_P(PSTR(",\"COUNTER\":{")); } ResponseAppend_P(PSTR("%s\"C%d\":%s"), (header)?",":"", i +1, counter); + if ((0 == tele_period ) && (Settings.flag3.counter_reset_on_tele)) { + RtcSettings.pulse_counter[i] = 0; + } header = true; #ifdef USE_DOMOTICZ if ((0 == tele_period) && (1 == dsxflg)) { From 4a9271acedc8cb11829d45c1632723f9c35ec5c5 Mon Sep 17 00:00:00 2001 From: Andre Thomas <470015+andrethomas@users.noreply.github.com> Date: Sat, 28 Dec 2019 17:26:15 +0200 Subject: [PATCH 3/3] Update xsns_01_counter.ino --- tasmota/xsns_01_counter.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasmota/xsns_01_counter.ino b/tasmota/xsns_01_counter.ino index c664ff811..985216392 100644 --- a/tasmota/xsns_01_counter.ino +++ b/tasmota/xsns_01_counter.ino @@ -150,9 +150,6 @@ void CounterShow(bool json) ResponseAppend_P(PSTR(",\"COUNTER\":{")); } ResponseAppend_P(PSTR("%s\"C%d\":%s"), (header)?",":"", i +1, counter); - if ((0 == tele_period ) && (Settings.flag3.counter_reset_on_tele)) { - RtcSettings.pulse_counter[i] = 0; - } header = true; #ifdef USE_DOMOTICZ if ((0 == tele_period) && (1 == dsxflg)) { @@ -160,6 +157,9 @@ void CounterShow(bool json) dsxflg++; } #endif // USE_DOMOTICZ + if ((0 == tele_period ) && (Settings.flag3.counter_reset_on_tele)) { + RtcSettings.pulse_counter[i] = 0; + } #ifdef USE_WEBSERVER } else { WSContentSend_PD(PSTR("{s}" D_COUNTER "%d{m}%s%s{e}"),