1 #include "text_sensor.h" 5 namespace text_sensor {
7 static const char *
const TAG =
"text_sensor";
13 ESP_LOGV(TAG,
"'%s': Received new state %s", this->
name_.
c_str(), state.c_str());
25 ESP_LOGVV(TAG,
"TextSensor(%p)::add_filter(%p)",
this, filter);
30 while (last_filter->
next_ !=
nullptr)
31 last_filter = last_filter->
next_;
37 for (
Filter *filter : filters) {
47 ESP_LOGVV(TAG,
"TextSensor(%p)::clear_filters()",
this);
64 ESP_LOGD(TAG,
"'%s': Sending state '%s'", this->
name_.
c_str(), state.c_str());
void add_on_state_callback(std::function< void(std::string)> callback)
virtual std::string unique_id()
Override this method to set the unique ID of this sensor.
void input(const std::string &value)
void add_filters(const std::vector< Filter *> &filters)
Add a list of vectors to the back of the filter chain.
void publish_state(const std::string &state)
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 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.
void internal_send_state_to_frontend(const std::string &state)
virtual void initialize(TextSensor *parent, Filter *next)
Initialize this filter, please note this can be called more than once.
std::string get_state() const
Getter-syntax for .state.
void set_filters(const std::vector< Filter *> &filters)
Clear the filters and replace them by filters.
constexpr const char * c_str() const
Filter * filter_list_
Store all active filters.
Implementation of SPI Controller mode.
void clear_filters()
Clear the entire filter chain.
Apply a filter to text sensor values such as to_upper.
std::string get_raw_state() const
Getter-syntax for .raw_state.
CallbackManager< void(std::string)> raw_callback_
Storage for raw state callbacks.