diff --git a/esphome/components/rc522/rc522.cpp b/esphome/components/rc522/rc522.cpp index 8f8740c925..470c50109e 100644 --- a/esphome/components/rc522/rc522.cpp +++ b/esphome/components/rc522/rc522.cpp @@ -492,7 +492,10 @@ bool RC522BinarySensor::process(std::vector &data) { this->found_ = result; return result; } -void RC522Trigger::process(std::vector &data) { this->trigger(format_hex_pretty(data, '-', false)); } +void RC522Trigger::process(std::vector &data) { + char uid_buf[format_hex_pretty_size(RC522_MAX_UID_SIZE)]; + this->trigger(format_hex_pretty_to(uid_buf, data.data(), data.size(), '-')); +} } // namespace rc522 } // namespace esphome diff --git a/esphome/components/remote_base/midea_protocol.h b/esphome/components/remote_base/midea_protocol.h index 0a5de8e9df..c3030d565e 100644 --- a/esphome/components/remote_base/midea_protocol.h +++ b/esphome/components/remote_base/midea_protocol.h @@ -29,6 +29,8 @@ class MideaData { bool is_valid() const { return this->data_[OFFSET_CS] == this->calc_cs_(); } void finalize() { this->data_[OFFSET_CS] = this->calc_cs_(); } bool is_compliment(const MideaData &rhs) const; + /// @deprecated Allocates heap memory. Use to_str() instead. Removed in 2026.7.0. + ESPDEPRECATED("Allocates heap memory. Use to_str() instead. Removed in 2026.7.0.", "2026.1.0") std::string to_string() const { return format_hex_pretty(this->data_.data(), this->data_.size()); } /// Buffer size for to_str(): 6 bytes = "AA.BB.CC.DD.EE.FF\0" static constexpr size_t TO_STR_BUFFER_SIZE = format_hex_pretty_size(6); diff --git a/esphome/components/tuya/text_sensor/tuya_text_sensor.cpp b/esphome/components/tuya/text_sensor/tuya_text_sensor.cpp index 3c492d609d..0b3e2026d8 100644 --- a/esphome/components/tuya/text_sensor/tuya_text_sensor.cpp +++ b/esphome/components/tuya/text_sensor/tuya_text_sensor.cpp @@ -14,9 +14,11 @@ void TuyaTextSensor::setup() { this->publish_state(datapoint.value_string); break; case TuyaDatapointType::RAW: { - std::string data = format_hex_pretty(datapoint.value_raw); - ESP_LOGD(TAG, "MCU reported text sensor %u is: %s", datapoint.id, data.c_str()); - this->publish_state(data); + // Text sensor state is limited to 255 bytes, use 256 byte buffer + char hex_buf[256]; + const char *formatted = format_hex_pretty_to(hex_buf, sizeof(hex_buf), datapoint.value_raw); + ESP_LOGD(TAG, "MCU reported text sensor %u is: %s", datapoint.id, formatted); + this->publish_state(formatted); break; } case TuyaDatapointType::ENUM: {