diff --git a/esphome/components/pid/pid_climate.cpp b/esphome/components/pid/pid_climate.cpp index 25aae7c4cb..ba3b8ec98a 100644 --- a/esphome/components/pid/pid_climate.cpp +++ b/esphome/components/pid/pid_climate.cpp @@ -165,7 +165,7 @@ void PIDClimate::start_autotune(std::unique_ptr &&autotune) { this->autotuner_->config(min_value, max_value); char object_id_buf[OBJECT_ID_MAX_LEN]; StringRef object_id = this->get_object_id_to(object_id_buf); - this->autotuner_->set_autotuner_id(std::string(object_id.c_str())); + this->autotuner_->set_autotuner_id(object_id.str()); ESP_LOGI(TAG, "%s: Autotune has started. This can take a long time depending on the " diff --git a/esphome/components/prometheus/prometheus_handler.cpp b/esphome/components/prometheus/prometheus_handler.cpp index 95ddc87b7e..9ae4a74718 100644 --- a/esphome/components/prometheus/prometheus_handler.cpp +++ b/esphome/components/prometheus/prometheus_handler.cpp @@ -117,7 +117,7 @@ std::string PrometheusHandler::relabel_id_(EntityBase *obj) { } char object_id_buf[OBJECT_ID_MAX_LEN]; StringRef object_id = obj->get_object_id_to(object_id_buf); - return std::string(object_id.c_str()); + return object_id.str(); } std::string PrometheusHandler::relabel_name_(EntityBase *obj) {