ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
homeassistant_text_sensor.cpp
Go to the documentation of this file.
3#include "esphome/core/log.h"
5
7
8static const char *const TAG = "homeassistant.text_sensor";
9
12 if (this->attribute_ != nullptr) {
13 ESP_LOGD(TAG, "'%s::%s': Got attribute state '%s'", this->entity_id_, this->attribute_, state.c_str());
14 } else {
15 ESP_LOGD(TAG, "'%s': Got state '%s'", this->entity_id_, state.c_str());
16 }
17 this->publish_state(state.c_str(), state.size());
18 });
19}
21 LOG_TEXT_SENSOR("", "Homeassistant Text Sensor", this);
22 ESP_LOGCONFIG(TAG, " Entity ID: '%s'", this->entity_id_);
23 if (this->attribute_ != nullptr) {
24 ESP_LOGCONFIG(TAG, " Attribute: '%s'", this->attribute_);
25 }
26}
28} // namespace esphome::homeassistant
StringRef is a reference to a string owned by something else.
Definition string_ref.h:26
constexpr const char * c_str() const
Definition string_ref.h:73
void subscribe_home_assistant_state(const char *entity_id, const char *attribute, std::function< void(StringRef)> &&f)
void publish_state(const std::string &state)
APIServer * global_api_server
constexpr float AFTER_CONNECTION
For components that should be initialized after a data connection (API/MQTT) is connected.
Definition component.h:55