From 31d27cb8dbe671a83a0b73c08f44a2fd390be23c Mon Sep 17 00:00:00 2001 From: Spencer Yan Date: Tue, 22 Oct 2024 15:54:48 +0800 Subject: [PATCH] refactor(mr60fda2): get the string from the select itself --- esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp b/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp index 411c31e118..e318ec82e0 100644 --- a/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp +++ b/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp @@ -285,17 +285,17 @@ void MR60FDA2Component::process_frame_() { float install_height_float; memcpy(&install_height_float, ¤t_install_height_int_, sizeof(float)); select_index_ = find_nearest_index_(install_height_float, INSTALL_HEIGHT, 7); - this->install_height_select_->publish_state(INSTALL_HEIGHT_STR[select_index_]); + this->install_height_select_->publish_state(this->install_height_select_.at(select_index_)); this->current_height_threshold_int_ = encode_uint32(current_data_buf_[7], current_data_buf_[6], current_data_buf_[5], current_data_buf_[4]); float height_threshold_float; memcpy(&height_threshold_float, ¤t_height_threshold_int_, sizeof(float)); select_index_ = find_nearest_index_(height_threshold_float, HEIGHT_THRESHOLD, 7); - this->height_threshold_select_->publish_state(HEIGHT_THRESHOLD_STR[select_index_]); + this->height_threshold_select_->publish_state(this->height_threshold_select_.at(select_index_)); this->current_sensitivity_ = encode_uint32(current_data_buf_[11], current_data_buf_[10], current_data_buf_[9], current_data_buf_[8]); select_index_ = find_nearest_index_(this->current_sensitivity_, SENSITIVITY, 3); - this->sensitivity_select_->publish_state(SENSITIVITY_STR[select_index_]); + this->sensitivity_select_->publish_state(this->sensitivity_select_.at(select_index_)); ESP_LOGD(TAG, "Mounting height: %.2f, Height threshold: %.2f, Sensitivity: %u", install_height_float, height_threshold_float, this->current_sensitivity_); this->current_frame_locate_ = LOCATE_FRAME_HEADER;