mirror of
https://github.com/esphome/esphome.git
synced 2026-05-27 20:53:46 +08:00
[tuya] Avoid heap allocation in text sensor enum publish (#13056)
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user