ESPHome  2024.10.3
Public Member Functions | Protected Attributes
esphome::sensor::LambdaFilter Class Reference

This class allows for creation of simple template filters. More...

#include <filter.h>

Inheritance diagram for esphome::sensor::LambdaFilter:
esphome::sensor::Filter

Public Member Functions

 LambdaFilter (lambda_filter_t lambda_filter)
 
optional< float > new_value (float value) override
 
const lambda_filter_tget_lambda_filter () const
 
void set_lambda_filter (const lambda_filter_t &lambda_filter)
 
- 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

lambda_filter_t lambda_filter_
 
- Protected Attributes inherited from esphome::sensor::Filter
friend Sensor
 
Filternext_ {nullptr}
 
Sensorparent_ {nullptr}
 

Detailed Description

This class allows for creation of simple template filters.

The constructor accepts a lambda of the form float -> optional<float>. It will be called with each new value in the filter chain and returns the modified value that shall be passed down the filter chain. Returning an empty Optional means that the value shall be discarded.

Definition at line 260 of file filter.h.

Constructor & Destructor Documentation

◆ LambdaFilter()

esphome::sensor::LambdaFilter::LambdaFilter ( lambda_filter_t  lambda_filter)
explicit

Definition at line 280 of file filter.cpp.

Member Function Documentation

◆ get_lambda_filter()

const lambda_filter_t & esphome::sensor::LambdaFilter::get_lambda_filter ( ) const

Definition at line 281 of file filter.cpp.

◆ new_value()

optional< float > esphome::sensor::LambdaFilter::new_value ( float  value)
overridevirtual

Implements esphome::sensor::Filter.

Definition at line 284 of file filter.cpp.

◆ set_lambda_filter()

void esphome::sensor::LambdaFilter::set_lambda_filter ( const lambda_filter_t lambda_filter)

Definition at line 282 of file filter.cpp.

Field Documentation

◆ lambda_filter_

lambda_filter_t esphome::sensor::LambdaFilter::lambda_filter_
protected

Definition at line 270 of file filter.h.


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