ESPHome  2024.12.0
Public Member Functions | Protected Attributes
esphome::sensor::Filter Class Referenceabstract

Apply a filter to sensor values such as moving average. More...

#include <filter.h>

Inheritance diagram for esphome::sensor::Filter:
esphome::sensor::CalibrateLinearFilter esphome::sensor::CalibratePolynomialFilter esphome::sensor::ClampFilter esphome::sensor::DebounceFilter esphome::sensor::DeltaFilter esphome::sensor::ExponentialMovingAverageFilter esphome::sensor::FilterOutValueFilter esphome::sensor::HeartbeatFilter esphome::sensor::LambdaFilter esphome::sensor::MaxFilter esphome::sensor::MedianFilter esphome::sensor::MinFilter esphome::sensor::MultiplyFilter esphome::sensor::OffsetFilter esphome::sensor::OrFilter esphome::sensor::OrFilter::PhiNode esphome::sensor::QuantileFilter esphome::sensor::RoundFilter esphome::sensor::RoundMultipleFilter esphome::sensor::SkipInitialFilter esphome::sensor::SlidingWindowMovingAverageFilter esphome::sensor::ThrottleAverageFilter esphome::sensor::ThrottleFilter esphome::sensor::TimeoutFilter

Public Member Functions

virtual optional< float > new_value (float value)=0
 This will be called every time the filter receives a new value. More...
 
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

friend Sensor
 
Filternext_ {nullptr}
 
Sensorparent_ {nullptr}
 

Detailed Description

Apply a filter to sensor values such as moving average.

This class is purposefully kept quite simple, since more complicated filters should really be done with the filter sensor in Home Assistant.

Definition at line 20 of file filter.h.

Member Function Documentation

◆ initialize()

void esphome::sensor::Filter::initialize ( Sensor parent,
Filter next 
)
virtual

Initialize this filter, please note this can be called more than once.

Reimplemented in esphome::sensor::OrFilter.

Definition at line 28 of file filter.cpp.

◆ input()

void esphome::sensor::Filter::input ( float  value)

Definition at line 13 of file filter.cpp.

◆ new_value()

virtual optional<float> esphome::sensor::Filter::new_value ( float  value)
pure virtual

◆ output()

void esphome::sensor::Filter::output ( float  value)

Definition at line 19 of file filter.cpp.

Field Documentation

◆ next_

Filter* esphome::sensor::Filter::next_ {nullptr}
protected

Definition at line 43 of file filter.h.

◆ parent_

Sensor* esphome::sensor::Filter::parent_ {nullptr}
protected

Definition at line 44 of file filter.h.

◆ Sensor

friend esphome::sensor::Filter::Sensor
protected

Definition at line 41 of file filter.h.


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