ESPHome  2024.2.1
Public Member Functions | Protected Attributes
esphome::sensor::QuantileFilter Class Reference

Simple quantile filter. More...

#include <filter.h>

Inheritance diagram for esphome::sensor::QuantileFilter:

Public Member Functions

 QuantileFilter (size_t window_size, size_t send_every, size_t send_first_at, float quantile)
 Construct a QuantileFilter. More...
optional< float > new_value (float value) override
void set_send_every (size_t send_every)
void set_window_size (size_t window_size)
void set_quantile (float quantile)
- Public Member Functions inherited from esphome::sensor::Filter
virtual void initialize (Sensor *parent, Filter *next)
 Initialize this filter, please note this can be called more than once. More...
void input (float value)
void output (float value)

Protected Attributes

std::deque< float > queue_
size_t send_every_
size_t send_at_
size_t window_size_
float quantile_
- Protected Attributes inherited from esphome::sensor::Filter
friend Sensor
Filternext_ {nullptr}
Sensorparent_ {nullptr}

Detailed Description

Simple quantile filter.

Takes the quantile of the last <send_every> values and pushes it out every <send_every>.

Definition at line 50 of file filter.h.

Constructor & Destructor Documentation

◆ QuantileFilter()

esphome::sensor::QuantileFilter::QuantileFilter ( size_t  window_size,
size_t  send_every,
size_t  send_first_at,
float  quantile 

Construct a QuantileFilter.

window_sizeThe number of values that should be used in quantile calculation.
send_everyAfter how many sensor values should a new one be pushed out.
send_first_atAfter how many values to forward the very first value. Defaults to the first value on startup being published on the first raw value, so with no filter applied. Must be less than or equal to send_every.
quantilefloat 0..1 to pick the requested quantile. Defaults to 0.9.

Definition at line 91 of file filter.cpp.

Member Function Documentation

◆ new_value()

optional< float > esphome::sensor::QuantileFilter::new_value ( float  value)

Implements esphome::sensor::Filter.

Definition at line 96 of file filter.cpp.

◆ set_quantile()

void esphome::sensor::QuantileFilter::set_quantile ( float  quantile)

Definition at line 95 of file filter.cpp.

◆ set_send_every()

void esphome::sensor::QuantileFilter::set_send_every ( size_t  send_every)

Definition at line 93 of file filter.cpp.

◆ set_window_size()

void esphome::sensor::QuantileFilter::set_window_size ( size_t  window_size)

Definition at line 94 of file filter.cpp.

Field Documentation

◆ quantile_

float esphome::sensor::QuantileFilter::quantile_

Definition at line 74 of file filter.h.

◆ queue_

std::deque<float> esphome::sensor::QuantileFilter::queue_

Definition at line 70 of file filter.h.

◆ send_at_

size_t esphome::sensor::QuantileFilter::send_at_

Definition at line 72 of file filter.h.

◆ send_every_

size_t esphome::sensor::QuantileFilter::send_every_

Definition at line 71 of file filter.h.

◆ window_size_

size_t esphome::sensor::QuantileFilter::window_size_

Definition at line 73 of file filter.h.

The documentation for this class was generated from the following files: