11 namespace text_sensor {
13 #define LOG_TEXT_SENSOR(prefix, type, obj) \ 14 if ((obj) != nullptr) { \ 15 ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \ 16 if (!(obj)->get_device_class().empty()) { \ 17 ESP_LOGCONFIG(TAG, "%s Device Class: '%s'", prefix, (obj)->get_device_class().c_str()); \ 19 if (!(obj)->get_icon().empty()) { \ 20 ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon().c_str()); \ 22 if (!(obj)->unique_id().empty()) { \ 23 ESP_LOGV(TAG, "%s Unique ID: '%s'", prefix, (obj)->unique_id().c_str()); \ 27 #define SUB_TEXT_SENSOR(name) \ 29 text_sensor::TextSensor *name##_text_sensor_{nullptr}; \ 32 void set_##name##_text_sensor(text_sensor::TextSensor *text_sensor) { this->name##_text_sensor_ = text_sensor; } 47 void add_filters(
const std::vector<Filter *> &filters);
50 void set_filters(
const std::vector<Filter *> &filters);
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 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)
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.
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.