Compare commits

..

1 Commits

Author SHA1 Message Date
J. Nick Koston
075364f4b4 [homeassistant] Use buf_append_printf for ESP8266 flash optimization 2026-01-16 11:32:26 -10:00
2 changed files with 2 additions and 2 deletions

View File

@@ -97,7 +97,7 @@ void HomeassistantNumber::control(float value) {
entity_value.key = VALUE_KEY;
// Stack buffer - no heap allocation; %g produces shortest representation
char value_buf[16];
snprintf(value_buf, sizeof(value_buf), "%g", value);
buf_append_printf(value_buf, sizeof(value_buf), 0, "%g", value);
entity_value.value = StringRef(value_buf);
api::global_api_server->send_homeassistant_action(resp);

View File

@@ -24,7 +24,7 @@ void TuyaTextSensor::setup() {
}
case TuyaDatapointType::ENUM: {
char buf[4]; // uint8_t max is 3 digits + null
buf_append_printf(buf, sizeof(buf), 0, "%u", datapoint.value_enum);
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;