ESPHome
2024.9.2
|
Apply a filter to text sensor values such as to_upper. More...
#include <filter.h>
Public Member Functions | |
virtual optional< std::string > | new_value (std::string value)=0 |
This will be called every time the filter receives a new value. More... | |
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 | |
friend | TextSensor |
Filter * | next_ {nullptr} |
TextSensor * | parent_ {nullptr} |
Apply a filter to text sensor values such as to_upper.
This class is purposefully kept quite simple, since more complicated filters should really be done with the filter sensor in Home Assistant.
|
virtual |
Initialize this filter, please note this can be called more than once.
Definition at line 27 of file filter.cpp.
void esphome::text_sensor::Filter::input | ( | const std::string & | value | ) |
Definition at line 12 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::text_sensor::MapFilter, esphome::text_sensor::SubstituteFilter, esphome::text_sensor::PrependFilter, esphome::text_sensor::AppendFilter, esphome::text_sensor::ToLowerFilter, esphome::text_sensor::ToUpperFilter, and esphome::text_sensor::LambdaFilter.
void esphome::text_sensor::Filter::output | ( | const std::string & | value | ) |
Definition at line 18 of file filter.cpp.
|
protected |
|
protected |