ESPHome 2026.4.5
Loading...
Searching...
No Matches
esphome::text_sensor::LambdaFilter Class Reference

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

#include <filter.h>

Inheritance diagram for esphome::text_sensor::LambdaFilter:
esphome::text_sensor::Filter

Public Member Functions

 LambdaFilter (lambda_filter_t lambda_filter)
 
bool new_value (std::string &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::text_sensor::Filter
virtual void initialize (TextSensor *parent, Filter *next)
 Initialize this filter, please note this can be called more than once.
 
void input (std::string value)
 
void output (std::string &value)
 

Protected Attributes

lambda_filter_t lambda_filter_
 
- Protected Attributes inherited from esphome::text_sensor::Filter
friend TextSensor
 
Filternext_ {nullptr}
 
TextSensorparent_ {nullptr}
 

Detailed Description

This class allows for creation of simple template filters.

The constructor accepts a lambda of the form std::string -> optional<std::string>. Return a modified string to continue the chain, or return {} to stop (value will not be published).

Definition at line 54 of file filter.h.

Constructor & Destructor Documentation

◆ LambdaFilter()

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

Definition at line 35 of file filter.cpp.

Member Function Documentation

◆ get_lambda_filter()

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

Definition at line 36 of file filter.cpp.

◆ new_value()

bool esphome::text_sensor::LambdaFilter::new_value ( std::string & value)
overridevirtual

Implements esphome::text_sensor::Filter.

Definition at line 39 of file filter.cpp.

◆ set_lambda_filter()

void esphome::text_sensor::LambdaFilter::set_lambda_filter ( const lambda_filter_t & lambda_filter)

Definition at line 37 of file filter.cpp.

Field Documentation

◆ lambda_filter_

lambda_filter_t esphome::text_sensor::LambdaFilter::lambda_filter_
protected

Definition at line 64 of file filter.h.


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