4#ifdef USE_TEXT_SENSOR_FILTER
76 if (result.has_value()) {
77 value = std::move(*result);
200 void loop()
override;
206 void send_(
const char *text,
size_t len);
void disable_loop()
Disable this component's loop.
A simple filter that adds a string to the end of another string.
bool new_value(std::string &value) override
AppendFilter(const char *suffix)
Apply a filter to text sensor values such as to_upper.
virtual bool new_value(std::string &value)=0
This will be called every time the filter receives a new value.
void output(std::string &value)
void input(std::string value)
virtual void initialize(TextSensor *parent, Filter *next)
Initialize this filter, please note this can be called more than once.
This class allows for creation of simple template filters.
lambda_filter_t lambda_filter_
LambdaFilter(lambda_filter_t lambda_filter)
void set_lambda_filter(const lambda_filter_t &lambda_filter)
bool new_value(std::string &value) override
const lambda_filter_t & get_lambda_filter() const
A filter that maps values from one set to another.
bool new_value(std::string &value) override
const Substitution * mappings_
MapFilter(const Substitution *mappings)
A simple filter that adds a string to the start of another string.
bool new_value(std::string &value) override
PrependFilter(const char *prefix)
Optimized lambda filter for stateless lambdas (no capture).
optional< std::string >(* lambda_filter_)(std::string)
StatelessLambdaFilter(optional< std::string >(*lambda_filter)(std::string))
bool new_value(std::string &value) override
A simple filter that replaces a substring with another substring.
bool new_value(std::string &value) override
SubstituteFilter(const Substitution *substitutions)
const Substitution * substitutions_
Drops a value that comes sooner than min_time_between_inputs after the last one let through.
bool new_value(std::string &value) override
ThrottleFilter(uint32_t min_time_between_inputs)
uint32_t min_time_between_inputs_
Same as ThrottleFilter, but a value in prioritized always passes.
ThrottleWithPriorityFilter(uint32_t min_time_between_inputs, const char *const *prioritized)
bool new_value(std::string &value) override
const char *const * prioritized_
Passes every value on and, once none has come for time_period, sends one value again.
TimeoutFilterBase(uint32_t time_period)
bool new_value(std::string &value) override
float get_setup_priority() const override
uint32_t timeout_start_time_
virtual void send_timeout_value()=0
void send_(const char *text, size_t len)
Sends text; never moves a stored string on, so it keeps its buffer.
Sends the configured text.
TimeoutFilterConfigured(uint32_t time_period, const char *value)
void send_timeout_value() override
Sends the last value again.
bool new_value(std::string &value) override
TimeoutFilterLast(uint32_t time_period)
void send_timeout_value() override
Codegen use only: timeout (value last) followed by throttle_with_priority with the same period,...
void send_timeout_value() override
const char *const * prioritized_
TimeoutThrottleFilter(uint32_t time_period, const char *const *prioritized)
bool new_value(std::string &value) override
A simple filter that converts all text to lowercase.
bool new_value(std::string &value) override
A simple filter that converts all text to uppercase.
bool new_value(std::string &value) override
constexpr float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
std::function< optional< std::string >(std::string)> lambda_filter_t