Skip to content

Commit c42da51

Browse files
authored
Merge pull request #5453 from tonhuisman/feature/Docs-updates-and-improvements-2025-q4
[Stats] Update min/max stats values, add minp/maxp stats values
2 parents e6ab258 + 644a5c6 commit c42da51

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

docs/source/Plugin/_Plugin.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,19 @@ Enabling "Stats" on a task value also extends how task values can be addressed w
9393

9494
For example using just like normal task value data:
9595

96-
* ``[bme#temp.avg]`` Compute the average over the last N samples in the historic buffer (typically: 64 samples on ESP32, 16 on ESP8266)
96+
* ``[bme#temp.avg]`` Compute the average over the last N samples in the historic buffer (typically: 250 samples on ESP32, 16 on ESP8266)
9797
* ``[bme#temp.avgX]`` Compute the average over the last X samples (or less if there are less samples available)
98-
* ``[bme#temp.stddev]`` Compute the standard deviation over the last N samples in the historic buffer (typically: 64 samples on ESP32, 16 on ESP8266)
98+
* ``[bme#temp.stddev]`` Compute the standard deviation over the last N samples in the historic buffer (typically: 250 samples on ESP32, 16 on ESP8266)
9999
* ``[bme#temp.stddevX]`` Compute the standard deviation over the last X samples (or less if there are less samples available)
100-
* ``[bme#temp.max]`` Refer to the maximum recorded sample since the last ``resetpeaks``. N.B. Not all tasks log the min and max peaks.
101-
* ``[bme#temp.min]`` See ``[bme#temp.max]``
100+
* ``[bme#temp.max]`` Refer to the maximum recorded sample in available samples (rolling maximum)
101+
* ``[bme#temp.maxX]`` Refer to the maximum recorded sample in the last X samples (or less if there are less samples available)
102+
* ``[bme#temp.maxp]`` (max-peak) Refer to the maximum recorded sample since the last ``resetpeaks``. N.B. Not all tasks log the min and max peaks.
103+
* ``[bme#temp.min]`` Refer to the minimum recorded sample in available samples (rolling minimum)
104+
* ``[bme#temp.minX]`` Refer to the minimum recorded sample in the last X samples (or less if there are less samples available)
105+
* ``[bme#temp.minp]`` (min-peak) See ``[bme#temp.maxp]``.
102106
* ``[bme#temp.size]`` Return the number of samples in memory.
103-
* ``[bme#temp.sample]`` Access the last sample in memory.
104-
* ``[bme#temp.sampleN]`` Access the N-th last sample in memory.
107+
* ``[bme#temp.sample]`` Return the number of samples in memory. (Doc. reflects the actual code!)
108+
* ``[bme#temp.sampleN]`` Access the N-th last sample in memory, negative value accesses N-th value from the *oldest* available sample.
105109

106110

107111
Commands on "Stats" data:

src/src/DataStructs/PluginStats.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,21 +369,27 @@ bool PluginStats::plugin_get_config_value_base(struct EventStruct *event, String
369369
break;
370370
case 'm':
371371

372-
if (matchedCommand(command, F("min"), nrSamples)) {
372+
if (equals(command, F("minp"))) { // [taskname#valuename.minp] Lowest value seen since value reset
373+
value = getPeakLow();
374+
success = true;
375+
} else if (matchedCommand(command, F("min"), nrSamples)) {
373376
success = nrSamples != 0;
374377

375-
if (nrSamples < 0) { // [taskname#valuename.min] Lowest value seen since value reset
376-
value = getPeakLow();
378+
if (nrSamples < 0) { // [taskname#valuename.min] Lowest value of all recent samples
379+
value = getSampleExtreme(getNrSamples(), false);
377380
} else { // Check for "minN", where N is the number of most recent samples to use.
378381
if (nrSamples > 0) {
379382
value = getSampleExtreme(nrSamples, false);
380383
}
381384
}
385+
} else if (equals(command, F("maxp"))) { // [taskname#valuename.maxp] Highest value seen since value reset
386+
value = getPeakHigh();
387+
success = true;
382388
} else if (matchedCommand(command, F("max"), nrSamples)) {
383389
success = nrSamples != 0;
384390

385-
if (nrSamples < 0) { // [taskname#valuename.max] Highest value seen since value reset
386-
value = getPeakHigh();
391+
if (nrSamples < 0) { // [taskname#valuename.max] Highest value of all recent samples
392+
value = getSampleExtreme(getNrSamples(), true);
387393
} else { // Check for "maxN", where N is the number of most recent samples to use.
388394
if (nrSamples > 0) {
389395
value = getSampleExtreme(nrSamples, true);

0 commit comments

Comments
 (0)