mirror of
https://github.com/esphome/esphome.git
synced 2026-01-09 11:40:50 -07:00
[tuya] Avoid heap allocation in text sensor enum publish (#13056)
This commit is contained in:
@@ -20,9 +20,10 @@ void TuyaTextSensor::setup() {
|
||||
break;
|
||||
}
|
||||
case TuyaDatapointType::ENUM: {
|
||||
std::string data = to_string(datapoint.value_enum);
|
||||
ESP_LOGD(TAG, "MCU reported text sensor %u is: %s", datapoint.id, data.c_str());
|
||||
this->publish_state(data);
|
||||
char buf[4]; // uint8_t max is 3 digits + null
|
||||
snprintf(buf, sizeof(buf), "%u", datapoint.value_enum);
|
||||
ESP_LOGD(TAG, "MCU reported text sensor %u is: %s", datapoint.id, buf);
|
||||
this->publish_state(buf);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user