[tuya] Avoid heap allocation in text sensor enum publish (#13056)

This commit is contained in:
J. Nick Koston
2026-01-07 08:28:14 -10:00
committed by GitHub
parent 0948e0359f
commit 815543b77e

View File

@@ -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: