mirror of
https://github.com/esphome/esphome.git
synced 2026-09-13 08:17:34 +00:00
[text_sensor] Convert LOG_TEXT_SENSOR macro to function to reduce flash usage (#10884)
This commit is contained in:
@@ -6,6 +6,22 @@ namespace text_sensor {
|
||||
|
||||
static const char *const TAG = "text_sensor";
|
||||
|
||||
void log_text_sensor(const char *tag, const char *prefix, const char *type, TextSensor *obj) {
|
||||
if (obj == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGCONFIG(tag, "%s%s '%s'", prefix, type, obj->get_name().c_str());
|
||||
|
||||
if (!obj->get_device_class_ref().empty()) {
|
||||
ESP_LOGCONFIG(tag, "%s Device Class: '%s'", prefix, obj->get_device_class_ref().c_str());
|
||||
}
|
||||
|
||||
if (!obj->get_icon_ref().empty()) {
|
||||
ESP_LOGCONFIG(tag, "%s Icon: '%s'", prefix, obj->get_icon_ref().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void TextSensor::publish_state(const std::string &state) {
|
||||
this->raw_state = state;
|
||||
if (this->raw_callback_) {
|
||||
|
||||
Reference in New Issue
Block a user