36 void input(
float value);
89 result = std::isnan(result) ? v : (comp(v, result) ? v : result);
126 explicit QuantileFilter(
size_t window_size,
size_t send_every,
size_t send_first_at,
float quantile);
149 using SortedWindowFilter::SortedWindowFilter;
187 using MinMaxFilter::MinMaxFilter;
207 using MinMaxFilter::MinMaxFilter;
264 void setup()
override;
413 void setup()
override;
428 explicit DeltaFilter(
float delta,
bool percentage_mode);
441 explicit OrFilter(std::initializer_list<Filter *> filters);
482 ClampFilter(
float min,
float max,
bool ignore_out_of_range);
Fixed-capacity vector - allocates once at runtime, never reallocates This avoids std::vector template...
FixedVector< std::array< float, 3 > > linear_functions_
optional< float > new_value(float value) override
CalibrateLinearFilter(std::initializer_list< std::array< float, 3 > > linear_functions)
CalibratePolynomialFilter(std::initializer_list< float > coefficients)
optional< float > new_value(float value) override
FixedVector< float > coefficients_
bool ignore_out_of_range_
ClampFilter(float min, float max, bool ignore_out_of_range)
optional< float > new_value(float value) override
optional< float > new_value(float value) override
float get_setup_priority() const override
DebounceFilter(uint32_t time_period)
DeltaFilter(float delta, bool percentage_mode)
optional< float > new_value(float value) override
Simple exponential moving average filter.
void set_send_every(size_t send_every)
optional< float > new_value(float value) override
ExponentialMovingAverageFilter(float alpha, size_t send_every, size_t send_first_at)
void set_alpha(float alpha)
Apply a filter to sensor values such as moving average.
virtual optional< float > new_value(float value)=0
This will be called every time the filter receives a new value.
virtual void initialize(Sensor *parent, Filter *next)
Initialize this filter, please note this can be called more than once.
A simple filter that only forwards the filter chain if it doesn't receive value_to_filter_out.
optional< float > new_value(float value) override
FilterOutValueFilter(std::initializer_list< TemplatableValue< float > > values_to_filter_out)
HeartbeatFilter(uint32_t time_period)
optional< float > new_value(float value) override
void set_optimistic(bool optimistic)
float get_setup_priority() const override
This class allows for creation of simple template filters.
const lambda_filter_t & get_lambda_filter() const
LambdaFilter(lambda_filter_t lambda_filter)
lambda_filter_t lambda_filter_
void set_lambda_filter(const lambda_filter_t &lambda_filter)
optional< float > new_value(float value) override
float compute_result() override
float compute_result() override
Base class for Min/Max filters.
float find_extremum_()
Helper to find min or max value in window, skipping NaN values Usage: find_extremum_<std::less<float>...
A simple filter that multiplies to each value it receives by multiplier.
optional< float > new_value(float value) override
MultiplyFilter(TemplatableValue< float > multiplier)
TemplatableValue< float > multiplier_
A simple filter that adds offset to each value it receives.
optional< float > new_value(float value) override
OffsetFilter(TemplatableValue< float > offset)
TemplatableValue< float > offset_
optional< float > new_value(float value) override
PhiNode(OrFilter *or_parent)
OrFilter(std::initializer_list< Filter * > filters)
optional< float > new_value(float value) override
void initialize(Sensor *parent, Filter *next) override
FixedVector< Filter * > filters_
float compute_result() override
void set_quantile(float quantile)
QuantileFilter(size_t window_size, size_t send_every, size_t send_first_at, float quantile)
Construct a QuantileFilter.
RoundFilter(uint8_t precision)
optional< float > new_value(float value) override
optional< float > new_value(float value) override
RoundMultipleFilter(float multiple)
Base-class for all sensors.
SkipInitialFilter(size_t num_to_ignore)
Construct a SkipInitialFilter.
optional< float > new_value(float value) override
Base class for filters that use a sliding window of values.
size_t window_head_
Index where next value will be written.
size_t window_size_
Maximum window size.
optional< float > new_value(float value) final
size_t window_count_
Number of valid values in window (0 to window_size_)
FixedVector< float > window_
Access the sliding window values (ring buffer implementation) Use: for (size_t i = 0; i < window_coun...
size_t send_at_
Counter for send_every.
size_t send_every_
Send result every N values.
virtual float compute_result()=0
Called by new_value() to compute the filtered result from the current window.
SlidingWindowFilter(size_t window_size, size_t send_every, size_t send_first_at)
Simple sliding window moving average filter.
float compute_result() override
Base class for filters that need a sorted window (Median, Quantile).
FixedVector< float > get_window_values_()
Helper to get non-NaN values from the window (not sorted - caller will use nth_element) Returns empty...
Optimized lambda filter for stateless lambdas (no capture).
optional< float >(* lambda_filter_)(float)
optional< float > new_value(float value) override
StatelessLambdaFilter(optional< float >(*lambda_filter)(float))
Base class for streaming filters (batch windows where window_size == send_every).
virtual void process_value(float value)=0
Called by new_value() to process each value in the batch.
virtual float compute_batch_result()=0
Called by new_value() to compute the result after collecting window_size values.
StreamingFilter(size_t window_size, size_t send_first_at)
virtual void reset_batch()=0
Called by new_value() to reset internal state after sending a result.
optional< float > new_value(float value) final
Streaming max filter for batch windows (window_size == send_every).
void reset_batch() override
void process_value(float value) override
float compute_batch_result() override
Streaming min filter for batch windows (window_size == send_every).
void reset_batch() override
float compute_batch_result() override
void process_value(float value) override
Streaming moving average filter for batch windows (window_size == send_every).
float compute_batch_result() override
void reset_batch() override
void process_value(float value) override
Simple throttle average filter.
optional< float > new_value(float value) override
ThrottleAverageFilter(uint32_t time_period)
float get_setup_priority() const override
uint32_t min_time_between_inputs_
ThrottleFilter(uint32_t min_time_between_inputs)
optional< float > new_value(float value) override
Same as 'throttle' but will immediately publish values contained in value_to_prioritize.
optional< float > new_value(float value) override
ThrottleWithPriorityFilter(uint32_t min_time_between_inputs, std::initializer_list< TemplatableValue< float > > prioritized_values)
uint32_t min_time_between_inputs_
optional< float > new_value(float value) override
optional< TemplatableValue< float > > value_
TimeoutFilter(uint32_t time_period)
float get_setup_priority() const override
optional< float > new_value(float value) override
ToNTCResistanceFilter(double a, double b, double c)
optional< float > new_value(float value) override
ToNTCTemperatureFilter(double a, double b, double c)
Base class for filters that compare sensor values against a list of configured values.
ValueListFilter(std::initializer_list< TemplatableValue< float > > values)
FixedVector< TemplatableValue< float > > values_
bool value_matches_any_(float sensor_value)
Check if sensor value matches any configured value (with accuracy rounding)
std::function< optional< float >(float)> lambda_filter_t
Providing packet encoding functions for exchanging data with a remote host.