[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
@@ -20,9 +20,10 @@ void TuyaTextSensor::setup() {
break; break;
} }
case TuyaDatapointType::ENUM: { case TuyaDatapointType::ENUM: {
std::string data = to_string(datapoint.value_enum); char buf[4]; // uint8_t max is 3 digits + null
ESP_LOGD(TAG, "MCU reported text sensor %u is: %s", datapoint.id, data.c_str()); snprintf(buf, sizeof(buf), "%u", datapoint.value_enum);
this->publish_state(data); ESP_LOGD(TAG, "MCU reported text sensor %u is: %s", datapoint.id, buf);
this->publish_state(buf);
break; break;
} }
default: default: