ESPHome
2024.9.2
|
Apply a filter to sensor values such as moving average. More...
#include <filter.h>
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 |
Filter * | next_ {nullptr} |
Sensor * | parent_ {nullptr} |
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.
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.
void esphome::sensor::Filter::input | ( | float | value | ) |
Definition at line 13 of file filter.cpp.
|
pure virtual |
This will be called every time the filter receives a new value.
It can return an empty optional to indicate that the filter chain should stop, otherwise the value in the filter will be passed down the chain.
value | The new value. |
Implemented in esphome::sensor::RoundMultipleFilter, esphome::sensor::RoundFilter, esphome::sensor::ClampFilter, esphome::sensor::CalibratePolynomialFilter, esphome::sensor::CalibrateLinearFilter, esphome::sensor::OrFilter::PhiNode, esphome::sensor::OrFilter, esphome::sensor::DeltaFilter, esphome::sensor::HeartbeatFilter, esphome::sensor::DebounceFilter, esphome::sensor::TimeoutFilter, esphome::sensor::ThrottleFilter, esphome::sensor::FilterOutValueFilter, esphome::sensor::MultiplyFilter, esphome::sensor::OffsetFilter, esphome::sensor::LambdaFilter, esphome::sensor::ThrottleAverageFilter, esphome::sensor::ExponentialMovingAverageFilter, esphome::sensor::SlidingWindowMovingAverageFilter, esphome::sensor::MaxFilter, esphome::sensor::MinFilter, esphome::sensor::SkipInitialFilter, esphome::sensor::MedianFilter, and esphome::sensor::QuantileFilter.
void esphome::sensor::Filter::output | ( | float | value | ) |
Definition at line 19 of file filter.cpp.
|
protected |