ESPHome 2025.6.0
Loading...
Searching...
No Matches
esphome::text_sensor::TextSensor Class Reference

#include <text_sensor.h>

Inheritance diagram for esphome::text_sensor::TextSensor:
esphome::EntityBase esphome::EntityBase_DeviceClass esphome::ble_client::BLETextSensor esphome::ble_scanner::BLEScanner esphome::copy::CopyTextSensor esphome::demo::DemoTextSensor esphome::ethernet_info::DNSAddressEthernetInfo esphome::ethernet_info::IPAddressEthernetInfo esphome::ethernet_info::MACAddressEthernetInfo esphome::homeassistant::HomeassistantTextSensor esphome::ld2420::LD2420TextSensor esphome::micronova::MicroNovaTextSensor esphome::modbus_controller::ModbusTextSensor esphome::mqtt_subscribe::MQTTSubscribeTextSensor esphome::nextion::NextionTextSensor esphome::openthread_info::ChannelOpenThreadInfo esphome::openthread_info::Eui64OpenThreadInfo esphome::openthread_info::ExtAddrOpenThreadInfo esphome::openthread_info::ExtPanIdOpenThreadInfo esphome::openthread_info::IPAddressOpenThreadInfo esphome::openthread_info::NetworkKeyOpenThreadInfo esphome::openthread_info::NetworkNameOpenThreadInfo esphome::openthread_info::PanIdOpenThreadInfo esphome::openthread_info::Rloc16OpenThreadInfo esphome::openthread_info::RoleOpenThreadInfo esphome::sml::SmlTextSensor esphome::sun::SunTextSensor esphome::teleinfo::TeleInfoTextSensor esphome::template_::TemplateTextSensor esphome::tuya::TuyaTextSensor esphome::uptime::UptimeTextSensor esphome::version::VersionTextSensor esphome::wifi_info::BSSIDWiFiInfo esphome::wifi_info::DNSAddressWifiInfo esphome::wifi_info::IPAddressWiFiInfo esphome::wifi_info::MacAddressWifiInfo esphome::wifi_info::SSIDWiFiInfo esphome::wifi_info::ScanResultsWiFiInfo esphome::wl_134::Wl134Component

Public Member Functions

 TextSensor ()=default
 
std::string get_state () const
 Getter-syntax for .state.
 
std::string get_raw_state () const
 Getter-syntax for .raw_state.
 
void publish_state (const std::string &state)
 
void add_filter (Filter *filter)
 Add a filter to the filter chain. Will be appended to the back.
 
void add_filters (const std::vector< Filter * > &filters)
 Add a list of vectors to the back of the filter chain.
 
void set_filters (const std::vector< Filter * > &filters)
 Clear the filters and replace them by filters.
 
void clear_filters ()
 Clear the entire filter chain.
 
void add_on_state_callback (std::function< void(std::string)> callback)
 
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.
 
virtual std::string unique_id ()
 Override this method to set the unique ID of this sensor.
 
void internal_send_state_to_frontend (const std::string &state)
 
- Public Member Functions inherited from esphome::EntityBase
const StringRefget_name () const
 
void set_name (const char *name)
 
bool has_own_name () const
 
std::string get_object_id () const
 
void set_object_id (const char *object_id)
 
uint32_t get_object_id_hash ()
 
bool is_internal () const
 
void set_internal (bool internal)
 
bool is_disabled_by_default () const
 
void set_disabled_by_default (bool disabled_by_default)
 
EntityCategory get_entity_category () const
 
void set_entity_category (EntityCategory entity_category)
 
std::string get_icon () const
 
void set_icon (const char *icon)
 
bool has_state () const
 
void set_has_state (bool state)
 
- Public Member Functions inherited from esphome::EntityBase_DeviceClass
std::string get_device_class ()
 Get the device class, using the manual override if set.
 
void set_device_class (const char *device_class)
 Manually set the device class.
 

Data Fields

std::string state
 
std::string raw_state
 

Protected Attributes

std::unique_ptr< CallbackManager< void(std::string)> > raw_callback_
 Storage for raw state callbacks (lazy allocated).
 
CallbackManager< void(std::string)> callback_
 Storage for filtered state callbacks.
 
Filterfilter_list_ {nullptr}
 Store all active filters.
 
- Protected Attributes inherited from esphome::EntityBase
StringRef name_
 
const char * object_id_c_str_ {nullptr}
 
const char * icon_c_str_ {nullptr}
 
uint32_t object_id_hash_ {}
 
struct esphome::EntityBase::EntityFlags flags_
 
- Protected Attributes inherited from esphome::EntityBase_DeviceClass
const char * device_class_ {nullptr}
 Device class override.
 

Additional Inherited Members

- Protected Member Functions inherited from esphome::EntityBase
virtual uint32_t hash_base ()
 The hash_base() function has been deprecated.
 
void calc_object_id_ ()
 

Detailed Description

Definition at line 35 of file text_sensor.h.

Constructor & Destructor Documentation

◆ TextSensor()

esphome::text_sensor::TextSensor::TextSensor ( )
default

Member Function Documentation

◆ add_filter()

void esphome::text_sensor::TextSensor::add_filter ( Filter * filter)

Add a filter to the filter chain. Will be appended to the back.

Definition at line 24 of file text_sensor.cpp.

◆ add_filters()

void esphome::text_sensor::TextSensor::add_filters ( const std::vector< Filter * > & filters)

Add a list of vectors to the back of the filter chain.

Definition at line 38 of file text_sensor.cpp.

◆ add_on_raw_state_callback()

void esphome::text_sensor::TextSensor::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.

Definition at line 57 of file text_sensor.cpp.

◆ add_on_state_callback()

void esphome::text_sensor::TextSensor::add_on_state_callback ( std::function< void(std::string)> callback)

Definition at line 54 of file text_sensor.cpp.

◆ clear_filters()

void esphome::text_sensor::TextSensor::clear_filters ( )

Clear the entire filter chain.

Definition at line 47 of file text_sensor.cpp.

◆ get_raw_state()

std::string esphome::text_sensor::TextSensor::get_raw_state ( ) const

Getter-syntax for .raw_state.

Definition at line 65 of file text_sensor.cpp.

◆ get_state()

std::string esphome::text_sensor::TextSensor::get_state ( ) const

Getter-syntax for .state.

Definition at line 64 of file text_sensor.cpp.

◆ internal_send_state_to_frontend()

void esphome::text_sensor::TextSensor::internal_send_state_to_frontend ( const std::string & state)

Definition at line 66 of file text_sensor.cpp.

◆ publish_state()

void esphome::text_sensor::TextSensor::publish_state ( const std::string & state)

Definition at line 9 of file text_sensor.cpp.

◆ set_filters()

void esphome::text_sensor::TextSensor::set_filters ( const std::vector< Filter * > & filters)

Clear the filters and replace them by filters.

Definition at line 43 of file text_sensor.cpp.

◆ unique_id()

Field Documentation

◆ callback_

CallbackManager<void(std::string)> esphome::text_sensor::TextSensor::callback_
protected

Storage for filtered state callbacks.

Definition at line 78 of file text_sensor.h.

◆ filter_list_

Filter* esphome::text_sensor::TextSensor::filter_list_ {nullptr}
protected

Store all active filters.

Definition at line 80 of file text_sensor.h.

◆ raw_callback_

std::unique_ptr<CallbackManager<void(std::string)> > esphome::text_sensor::TextSensor::raw_callback_
protected

Storage for raw state callbacks (lazy allocated).

Definition at line 77 of file text_sensor.h.

◆ raw_state

std::string esphome::text_sensor::TextSensor::raw_state

Definition at line 63 of file text_sensor.h.

◆ state

std::string esphome::text_sensor::TextSensor::state

Definition at line 62 of file text_sensor.h.


The documentation for this class was generated from the following files: