Skip to content

Commit bfd97ba

Browse files
authored
Merge pull request #4945 from TD-er/bugfix/ClearCSE_pulse
[P077_CSE] Fix cseclearpulses command
2 parents e015d1b + 6fe27c8 commit bfd97ba

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

docs/source/Plugin/P077_commands.repl

+1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@
3030
","
3131
(Added: 2024-01-16)
3232
Will reset the CF-pulse counter.
33+
N.B. this also clears the kWh counter as it is derived from the CF-pulse counter.
3334
"

src/_P077_CSE7766.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ boolean Plugin_077(uint8_t function, struct EventStruct *event, String& string)
113113
const float value = P077_data->getValue(query);
114114
int nrDecimals = 2;
115115

116-
if ((query == P077_query::P077_QUERY_PULSES)) {
116+
if (query == P077_query::P077_QUERY_PULSES) {
117117
nrDecimals = 0;
118-
} else if ((query == P077_query::P077_QUERY_KWH)) {
118+
} else if (query == P077_query::P077_QUERY_KWH) {
119119
nrDecimals = 3;
120120
}
121121

src/src/PluginStructs/P077_data_struct.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,11 @@ bool P077_data_struct::plugin_write(struct EventStruct *event,
355355
changed = true;
356356
} else if (equals(cmd, F("cseclearpulses"))) {
357357
// Clear the pulses count
358-
last_cf_pulses = 0;
359358
cf_pulses = 0;
359+
setOutputValue(event, P077_query::P077_QUERY_KWH, cf_pulses);
360+
setOutputValue(event, P077_query::P077_QUERY_PULSES, cf_pulses);
361+
Scheduler.schedule_task_device_timer(event->TaskIndex, millis() + 10);
362+
success = true;
360363
} else if (equals(cmd, F("csecalibrate"))) { // Set 1 or more calibration values, 0 will skip that value
361364
success = true;
362365
float CalibVolt = 0.0f;

0 commit comments

Comments
 (0)