From 8ade9dfc107b752bb5ac3cf03936f75bb85f5af6 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 19 Jan 2026 17:37:33 -1000 Subject: [PATCH] [shtcx] Use LogString for type to_string to save RAM on ESP8266 (#13370) --- esphome/components/shtcx/shtcx.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/esphome/components/shtcx/shtcx.cpp b/esphome/components/shtcx/shtcx.cpp index 933dd9bde9..aca305b88d 100644 --- a/esphome/components/shtcx/shtcx.cpp +++ b/esphome/components/shtcx/shtcx.cpp @@ -13,14 +13,14 @@ static const uint16_t SHTCX_COMMAND_READ_ID_REGISTER = 0xEFC8; static const uint16_t SHTCX_COMMAND_SOFT_RESET = 0x805D; static const uint16_t SHTCX_COMMAND_POLLING_H = 0x7866; -inline const char *to_string(SHTCXType type) { +static const LogString *shtcx_type_to_string(SHTCXType type) { switch (type) { case SHTCX_TYPE_SHTC3: - return "SHTC3"; + return LOG_STR("SHTC3"); case SHTCX_TYPE_SHTC1: - return "SHTC1"; + return LOG_STR("SHTC1"); default: - return "UNKNOWN"; + return LOG_STR("UNKNOWN"); } } @@ -52,7 +52,7 @@ void SHTCXComponent::dump_config() { ESP_LOGCONFIG(TAG, "SHTCx:\n" " Model: %s (%04x)", - to_string(this->type_), this->sensor_id_); + LOG_STR_ARG(shtcx_type_to_string(this->type_)), this->sensor_id_); LOG_I2C_DEVICE(this); if (this->is_failed()) { ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);