7static const char *
const TAG =
"text_sensor";
31 ESP_LOGV(TAG,
"'%s': Received new state %s", this->
name_.
c_str(), state.c_str());
43 ESP_LOGVV(TAG,
"TextSensor(%p)::add_filter(%p)",
this, filter);
48 while (last_filter->
next_ !=
nullptr)
49 last_filter = last_filter->
next_;
55 for (
Filter *filter : filters) {
65 ESP_LOGVV(TAG,
"TextSensor(%p)::clear_filters()",
this);
85 ESP_LOGD(TAG,
"'%s': Sending state '%s'", this->
name_.
c_str(), state.c_str());
StringRef get_device_class_ref() const
Get the device class as StringRef.
const StringRef & get_name() const
StringRef get_icon_ref() const
void set_has_state(bool state)
constexpr const char * c_str() const
constexpr bool empty() const
Apply a filter to text sensor values such as to_upper.
void input(const std::string &value)
virtual void initialize(TextSensor *parent, Filter *next)
Initialize this filter, please note this can be called more than once.
void internal_send_state_to_frontend(const std::string &state)
void add_filter(Filter *filter)
Add a filter to the filter chain. Will be appended to the back.
CallbackManager< void(std::string)> callback_
Storage for filtered state callbacks.
std::unique_ptr< CallbackManager< void(std::string)> > raw_callback_
Storage for raw state callbacks (lazy allocated).
void clear_filters()
Clear the entire filter chain.
void add_filters(const std::vector< Filter * > &filters)
Add a list of vectors to the back of the filter chain.
std::string get_state() const
Getter-syntax for .state.
Filter * filter_list_
Store all active filters.
void add_on_raw_state_callback(std::function< void(std::string)> callback)
Add a callback that will be called every time the sensor sends a raw value.
void set_filters(const std::vector< Filter * > &filters)
Clear the filters and replace them by filters.
void add_on_state_callback(std::function< void(std::string)> callback)
std::string get_raw_state() const
Getter-syntax for .raw_state.
void publish_state(const std::string &state)
void log_text_sensor(const char *tag, const char *prefix, const char *type, TextSensor *obj)
Providing packet encoding functions for exchanging data with a remote host.