Skip to content

Commit

Permalink
sns: really reset readings on cfg reload
Browse files Browse the repository at this point in the history
counter should start from scratch
amend 872f9b6
  • Loading branch information
mcspr committed Aug 7, 2024
1 parent bc6af42 commit b11071c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion code/espurna/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3867,9 +3867,12 @@ void configure_magnitude(Magnitude& magnitude) {
magnitude.filter = magnitude::makeFilter(magnitude.filter_type);
}

// Some filters must be able store up to a certain amount of readings.
// Everything filtered so far is reset, possibly updating total number of required readings.
magnitude.filter->resize(reportEvery());

// Reset internal readings counter as well.
magnitude.read_count = 0;

// process emon-specific settings first. ensure that settings use global index and we access sensor with the local one
if (isEmon(magnitude.sensor) && magnitude::traits::ratio_supported(magnitude.type)) {
auto* sensor = static_cast<BaseEmonSensor*>(magnitude.sensor.get());
Expand Down

0 comments on commit b11071c

Please sign in to comment.