ESPHome  2024.6.1
Public Member Functions | Protected Attributes
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:

Public Member Functions

 LambdaFilter (lambda_filter_t lambda_filter)
optional< std::string > 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. More...
void input (const std::string &value)
void output (const 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>. 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 56 of file filter.h.

Constructor & Destructor Documentation

◆ LambdaFilter()

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

Definition at line 34 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 35 of file filter.cpp.

◆ new_value()

optional< std::string > esphome::text_sensor::LambdaFilter::new_value ( std::string  value)

Implements esphome::text_sensor::Filter.

Definition at line 38 of file filter.cpp.

◆ set_lambda_filter()

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

Definition at line 36 of file filter.cpp.

Field Documentation

◆ lambda_filter_

lambda_filter_t esphome::text_sensor::LambdaFilter::lambda_filter_

Definition at line 66 of file filter.h.

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