ESPHome  2022.5.1
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
esphome::text_sensor::TextSensor Class Reference

#include <text_sensor.h>

Inheritance diagram for esphome::text_sensor::TextSensor:
esphome::EntityBase esphome::ble_client::BLETextSensor esphome::ble_scanner::BLEScanner esphome::copy::CopyTextSensor esphome::demo::DemoTextSensor esphome::homeassistant::HomeassistantTextSensor esphome::modbus_controller::ModbusTextSensor esphome::mqtt_subscribe::MQTTSubscribeTextSensor esphome::nextion::NextionTextSensor esphome::sml::SmlTextSensor esphome::sun::SunTextSensor esphome::teleinfo::TeleInfoTextSensor esphome::template_::TemplateTextSensor esphome::tuya::TuyaTextSensor esphome::version::VersionTextSensor esphome::wifi_info::BSSIDWiFiInfo esphome::wifi_info::IPAddressWiFiInfo esphome::wifi_info::MacAddressWifiInfo esphome::wifi_info::ScanResultsWiFiInfo esphome::wifi_info::SSIDWiFiInfo

Public Member Functions

 TextSensor ()
 TextSensor (const std::string &name)
std::string get_state () const
 Getter-syntax for .state. More...
std::string get_raw_state () const
 Getter-syntax for .raw_state. More...
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. More...
void add_filters (const std::vector< Filter *> &filters)
 Add a list of vectors to the back of the filter chain. More...
void set_filters (const std::vector< Filter *> &filters)
 Clear the filters and replace them by filters. More...
void clear_filters ()
 Clear the entire filter chain. More...
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. More...
virtual std::string unique_id ()
bool has_state ()
void internal_send_state_to_frontend (const std::string &state)
- Public Member Functions inherited from esphome::EntityBase
 EntityBase ()
 EntityBase (std::string name)
const std::string & get_name () const
void set_name (const std::string &name)
const std::string & get_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)
const std::string & get_icon () const
void set_icon (const std::string &name)

Data Fields

std::string state
std::string raw_state

Protected Member Functions

uint32_t hash_base () override
- Protected Member Functions inherited from esphome::EntityBase
void calc_object_id_ ()

Protected Attributes

CallbackManager< void(std::string)> raw_callback_
 Storage for raw state callbacks. More...
CallbackManager< void(std::string)> callback_
 Storage for filtered state callbacks. More...
Filterfilter_list_ {nullptr}
 Store all active filters. More...
bool has_state_ {false}
- Protected Attributes inherited from esphome::EntityBase
std::string name_
std::string object_id_
std::string icon_
uint32_t object_id_hash_
bool internal_ {false}
bool disabled_by_default_ {false}
EntityCategory entity_category_ {ENTITY_CATEGORY_NONE}

Detailed Description

Definition at line 22 of file text_sensor.h.

Constructor & Destructor Documentation

◆ TextSensor() [1/2]

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

Definition at line 9 of file text_sensor.cpp.

◆ TextSensor() [2/2]

esphome::text_sensor::TextSensor::TextSensor ( const std::string &  name)

Definition at line 10 of file text_sensor.cpp.

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 25 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 39 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 58 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 55 of file text_sensor.cpp.

◆ clear_filters()

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

Clear the entire filter chain.

Definition at line 48 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 63 of file text_sensor.cpp.

◆ get_state()

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

Getter-syntax for .state.

Definition at line 62 of file text_sensor.cpp.

◆ has_state()

bool esphome::text_sensor::TextSensor::has_state ( )

Definition at line 72 of file text_sensor.cpp.

◆ hash_base()

uint32_t esphome::text_sensor::TextSensor::hash_base ( )

Implements esphome::EntityBase.

Definition at line 73 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 64 of file text_sensor.cpp.

◆ publish_state()

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

Definition at line 12 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 44 of file text_sensor.cpp.

◆ unique_id()

std::string esphome::text_sensor::TextSensor::unique_id ( )

Field Documentation

◆ callback_

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

Storage for filtered state callbacks.

Definition at line 65 of file text_sensor.h.

◆ filter_list_

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

Store all active filters.

Definition at line 67 of file text_sensor.h.

◆ has_state_

bool esphome::text_sensor::TextSensor::has_state_ {false}

Definition at line 69 of file text_sensor.h.

◆ raw_callback_

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

Storage for raw state callbacks.

Definition at line 64 of file text_sensor.h.

◆ raw_state

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

Definition at line 51 of file text_sensor.h.

◆ state

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

Definition at line 50 of file text_sensor.h.

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