ESPHome  2024.5.5
Public Member Functions | Protected Attributes
esphome::sensor::ExponentialMovingAverageFilter Class Reference

Simple exponential moving average filter. More...

#include <filter.h>

Inheritance diagram for esphome::sensor::ExponentialMovingAverageFilter:

Public Member Functions

 ExponentialMovingAverageFilter (float alpha, size_t send_every, size_t send_first_at)
optional< float > new_value (float value) override
void set_send_every (size_t send_every)
void set_alpha (float alpha)
- 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

bool first_value_ {true}
float accumulator_ {NAN}
size_t send_every_
size_t send_at_
float alpha_
- Protected Attributes inherited from esphome::sensor::Filter
friend Sensor
Filternext_ {nullptr}
Sensorparent_ {nullptr}

Detailed Description

Simple exponential moving average filter.

Essentially just takes the average of the last few values using exponentially decaying weights. Use alpha to adjust decay rate.

Definition at line 213 of file filter.h.

Constructor & Destructor Documentation

◆ ExponentialMovingAverageFilter()

esphome::sensor::ExponentialMovingAverageFilter::ExponentialMovingAverageFilter ( float  alpha,
size_t  send_every,
size_t  send_first_at 

Definition at line 225 of file filter.cpp.

Member Function Documentation

◆ new_value()

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

Implements esphome::sensor::Filter.

Definition at line 227 of file filter.cpp.

◆ set_alpha()

void esphome::sensor::ExponentialMovingAverageFilter::set_alpha ( float  alpha)

Definition at line 248 of file filter.cpp.

◆ set_send_every()

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

Definition at line 247 of file filter.cpp.

Field Documentation

◆ accumulator_

float esphome::sensor::ExponentialMovingAverageFilter::accumulator_ {NAN}

Definition at line 224 of file filter.h.

◆ alpha_

float esphome::sensor::ExponentialMovingAverageFilter::alpha_

Definition at line 227 of file filter.h.

◆ first_value_

bool esphome::sensor::ExponentialMovingAverageFilter::first_value_ {true}

Definition at line 223 of file filter.h.

◆ send_at_

size_t esphome::sensor::ExponentialMovingAverageFilter::send_at_

Definition at line 226 of file filter.h.

◆ send_every_

size_t esphome::sensor::ExponentialMovingAverageFilter::send_every_

Definition at line 225 of file filter.h.

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