diff --git a/esphome/components/seeed_mr24hpc1/seeed_mr24hpc1.cpp b/esphome/components/seeed_mr24hpc1/seeed_mr24hpc1.cpp index 76523ce5c0..132ceefeb5 100644 --- a/esphome/components/seeed_mr24hpc1/seeed_mr24hpc1.cpp +++ b/esphome/components/seeed_mr24hpc1/seeed_mr24hpc1.cpp @@ -432,6 +432,7 @@ void MR24HPC1Component::r24_frame_parse_open_underlying_information_(uint8_t *da } else if ((this->motion_threshold_number_ != nullptr) && ((data[FRAME_COMMAND_WORD_INDEX] == 0x09) || (data[FRAME_COMMAND_WORD_INDEX] == 0x89))) { this->motion_threshold_number_->publish_state(data[FRAME_DATA_INDEX]); +#ifdef USE_SELECT } else if ((this->existence_boundary_select_ != nullptr) && ((data[FRAME_COMMAND_WORD_INDEX] == 0x0a) || (data[FRAME_COMMAND_WORD_INDEX] == 0x8a))) { if (this->existence_boundary_select_->has_index(data[FRAME_DATA_INDEX] - 1)) { @@ -442,6 +443,7 @@ void MR24HPC1Component::r24_frame_parse_open_underlying_information_(uint8_t *da if (this->motion_boundary_select_->has_index(data[FRAME_DATA_INDEX] - 1)) { this->motion_boundary_select_->publish_state(S_BOUNDARY_STR[data[FRAME_DATA_INDEX] - 1]); } +#endif } else if ((this->motion_trigger_number_ != nullptr) && ((data[FRAME_COMMAND_WORD_INDEX] == 0x0c) || (data[FRAME_COMMAND_WORD_INDEX] == 0x8c))) { uint32_t motion_trigger_time = encode_uint32(data[FRAME_DATA_INDEX], data[FRAME_DATA_INDEX + 1], @@ -514,11 +516,13 @@ void MR24HPC1Component::r24_frame_parse_work_status_(uint8_t *data) { if (data[FRAME_COMMAND_WORD_INDEX] == 0x01) { ESP_LOGD(TAG, "Reply: get radar init status 0x%02X", data[FRAME_DATA_INDEX]); } else if (data[FRAME_COMMAND_WORD_INDEX] == 0x07) { +#ifdef USE_SELECT if ((this->scene_mode_select_ != nullptr) && (this->scene_mode_select_->has_index(data[FRAME_DATA_INDEX]))) { this->scene_mode_select_->publish_state(S_SCENE_STR[data[FRAME_DATA_INDEX]]); } else { ESP_LOGD(TAG, "Select has index offset %d Error", data[FRAME_DATA_INDEX]); } +#endif } else if ((this->sensitivity_number_ != nullptr) && ((data[FRAME_COMMAND_WORD_INDEX] == 0x08) || (data[FRAME_COMMAND_WORD_INDEX] == 0x88))) { // 1-3 @@ -537,11 +541,13 @@ void MR24HPC1Component::r24_frame_parse_work_status_(uint8_t *data) { } else if (data[FRAME_COMMAND_WORD_INDEX] == 0x81) { ESP_LOGD(TAG, "Reply: get radar init status 0x%02X", data[FRAME_DATA_INDEX]); } else if (data[FRAME_COMMAND_WORD_INDEX] == 0x87) { +#ifdef USE_SELECT if ((this->scene_mode_select_ != nullptr) && (this->scene_mode_select_->has_index(data[FRAME_DATA_INDEX]))) { this->scene_mode_select_->publish_state(S_SCENE_STR[data[FRAME_DATA_INDEX]]); } else { ESP_LOGD(TAG, "Select has index offset %d Error", data[FRAME_DATA_INDEX]); } +#endif } else if ((this->custom_mode_end_text_sensor_ != nullptr) && (data[FRAME_COMMAND_WORD_INDEX] == 0x0A)) { this->custom_mode_end_text_sensor_->publish_state("Set Success!"); } else if (data[FRAME_COMMAND_WORD_INDEX] == 0x89) { @@ -577,12 +583,14 @@ void MR24HPC1Component::r24_frame_parse_human_information_(uint8_t *data) { } else if ((this->movement_signs_sensor_ != nullptr) && ((data[FRAME_COMMAND_WORD_INDEX] == 0x03) || (data[FRAME_COMMAND_WORD_INDEX] == 0x83))) { this->movement_signs_sensor_->publish_state(data[FRAME_DATA_INDEX]); +#ifdef USE_SELECT } else if ((this->unman_time_select_ != nullptr) && ((data[FRAME_COMMAND_WORD_INDEX] == 0x0A) || (data[FRAME_COMMAND_WORD_INDEX] == 0x8A))) { // none:0x00 1s:0x01 30s:0x02 1min:0x03 2min:0x04 5min:0x05 10min:0x06 30min:0x07 1hour:0x08 if (data[FRAME_DATA_INDEX] < 9) { this->unman_time_select_->publish_state(S_UNMANNED_TIME_STR[data[FRAME_DATA_INDEX]]); } +#endif } else if ((this->keep_away_text_sensor_ != nullptr) && ((data[FRAME_COMMAND_WORD_INDEX] == 0x0B) || (data[FRAME_COMMAND_WORD_INDEX] == 0x8B))) { // none:0x00 close_to:0x01 far_away:0x02 diff --git a/tests/components/seeed_mr24hpc1/common_no_select.yaml b/tests/components/seeed_mr24hpc1/common_no_select.yaml new file mode 100644 index 0000000000..69fa483d4d --- /dev/null +++ b/tests/components/seeed_mr24hpc1/common_no_select.yaml @@ -0,0 +1,28 @@ +uart: + - id: seeed_mr24hpc1_uart + tx_pin: ${uart_tx_pin} + rx_pin: ${uart_rx_pin} + baud_rate: 115200 + parity: NONE + stop_bits: 1 + +seeed_mr24hpc1: + id: my_seeed_mr24hpc1 + uart_id: seeed_mr24hpc1_uart + +sensor: + - platform: seeed_mr24hpc1 + custom_presence_of_detection: + name: "Static Distance" + +binary_sensor: + - platform: seeed_mr24hpc1 + has_target: + name: "Presence Information" + +text_sensor: + - platform: seeed_mr24hpc1 + heart_beat: + name: "Heartbeat" + +# Note: NO select components included - this should work without compilation errors \ No newline at end of file diff --git a/tests/components/seeed_mr24hpc1/test.esp8266-ard-no-select.yaml b/tests/components/seeed_mr24hpc1/test.esp8266-ard-no-select.yaml new file mode 100644 index 0000000000..f0a04731e0 --- /dev/null +++ b/tests/components/seeed_mr24hpc1/test.esp8266-ard-no-select.yaml @@ -0,0 +1,5 @@ +substitutions: + uart_tx_pin: GPIO1 + uart_rx_pin: GPIO3 + +<<: !include common_no_select.yaml \ No newline at end of file diff --git a/tests/components/seeed_mr24hpc1/test.esp8266-ard.yaml b/tests/components/seeed_mr24hpc1/test.esp8266-ard.yaml new file mode 100644 index 0000000000..a293ffbfc0 --- /dev/null +++ b/tests/components/seeed_mr24hpc1/test.esp8266-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + uart_tx_pin: GPIO1 + uart_rx_pin: GPIO3 + +<<: !include common.yaml \ No newline at end of file