mirror of
https://github.com/esphome/esphome.git
synced 2025-10-31 23:21:54 +00:00
Fix seeed_mr24hpc1 compilation on ESP8266 by adding USE_SELECT guards
Co-authored-by: jesserockz <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
@@ -432,6 +432,7 @@ void MR24HPC1Component::r24_frame_parse_open_underlying_information_(uint8_t *da
|
|||||||
} else if ((this->motion_threshold_number_ != nullptr) &&
|
} else if ((this->motion_threshold_number_ != nullptr) &&
|
||||||
((data[FRAME_COMMAND_WORD_INDEX] == 0x09) || (data[FRAME_COMMAND_WORD_INDEX] == 0x89))) {
|
((data[FRAME_COMMAND_WORD_INDEX] == 0x09) || (data[FRAME_COMMAND_WORD_INDEX] == 0x89))) {
|
||||||
this->motion_threshold_number_->publish_state(data[FRAME_DATA_INDEX]);
|
this->motion_threshold_number_->publish_state(data[FRAME_DATA_INDEX]);
|
||||||
|
#ifdef USE_SELECT
|
||||||
} else if ((this->existence_boundary_select_ != nullptr) &&
|
} else if ((this->existence_boundary_select_ != nullptr) &&
|
||||||
((data[FRAME_COMMAND_WORD_INDEX] == 0x0a) || (data[FRAME_COMMAND_WORD_INDEX] == 0x8a))) {
|
((data[FRAME_COMMAND_WORD_INDEX] == 0x0a) || (data[FRAME_COMMAND_WORD_INDEX] == 0x8a))) {
|
||||||
if (this->existence_boundary_select_->has_index(data[FRAME_DATA_INDEX] - 1)) {
|
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)) {
|
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]);
|
this->motion_boundary_select_->publish_state(S_BOUNDARY_STR[data[FRAME_DATA_INDEX] - 1]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else if ((this->motion_trigger_number_ != nullptr) &&
|
} else if ((this->motion_trigger_number_ != nullptr) &&
|
||||||
((data[FRAME_COMMAND_WORD_INDEX] == 0x0c) || (data[FRAME_COMMAND_WORD_INDEX] == 0x8c))) {
|
((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],
|
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) {
|
if (data[FRAME_COMMAND_WORD_INDEX] == 0x01) {
|
||||||
ESP_LOGD(TAG, "Reply: get radar init status 0x%02X", data[FRAME_DATA_INDEX]);
|
ESP_LOGD(TAG, "Reply: get radar init status 0x%02X", data[FRAME_DATA_INDEX]);
|
||||||
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x07) {
|
} 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]))) {
|
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]]);
|
this->scene_mode_select_->publish_state(S_SCENE_STR[data[FRAME_DATA_INDEX]]);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "Select has index offset %d Error", data[FRAME_DATA_INDEX]);
|
ESP_LOGD(TAG, "Select has index offset %d Error", data[FRAME_DATA_INDEX]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else if ((this->sensitivity_number_ != nullptr) &&
|
} else if ((this->sensitivity_number_ != nullptr) &&
|
||||||
((data[FRAME_COMMAND_WORD_INDEX] == 0x08) || (data[FRAME_COMMAND_WORD_INDEX] == 0x88))) {
|
((data[FRAME_COMMAND_WORD_INDEX] == 0x08) || (data[FRAME_COMMAND_WORD_INDEX] == 0x88))) {
|
||||||
// 1-3
|
// 1-3
|
||||||
@@ -537,11 +541,13 @@ void MR24HPC1Component::r24_frame_parse_work_status_(uint8_t *data) {
|
|||||||
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x81) {
|
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x81) {
|
||||||
ESP_LOGD(TAG, "Reply: get radar init status 0x%02X", data[FRAME_DATA_INDEX]);
|
ESP_LOGD(TAG, "Reply: get radar init status 0x%02X", data[FRAME_DATA_INDEX]);
|
||||||
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x87) {
|
} 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]))) {
|
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]]);
|
this->scene_mode_select_->publish_state(S_SCENE_STR[data[FRAME_DATA_INDEX]]);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "Select has index offset %d Error", data[FRAME_DATA_INDEX]);
|
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)) {
|
} 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!");
|
this->custom_mode_end_text_sensor_->publish_state("Set Success!");
|
||||||
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x89) {
|
} 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) &&
|
} else if ((this->movement_signs_sensor_ != nullptr) &&
|
||||||
((data[FRAME_COMMAND_WORD_INDEX] == 0x03) || (data[FRAME_COMMAND_WORD_INDEX] == 0x83))) {
|
((data[FRAME_COMMAND_WORD_INDEX] == 0x03) || (data[FRAME_COMMAND_WORD_INDEX] == 0x83))) {
|
||||||
this->movement_signs_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
this->movement_signs_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
||||||
|
#ifdef USE_SELECT
|
||||||
} else if ((this->unman_time_select_ != nullptr) &&
|
} else if ((this->unman_time_select_ != nullptr) &&
|
||||||
((data[FRAME_COMMAND_WORD_INDEX] == 0x0A) || (data[FRAME_COMMAND_WORD_INDEX] == 0x8A))) {
|
((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
|
// none:0x00 1s:0x01 30s:0x02 1min:0x03 2min:0x04 5min:0x05 10min:0x06 30min:0x07 1hour:0x08
|
||||||
if (data[FRAME_DATA_INDEX] < 9) {
|
if (data[FRAME_DATA_INDEX] < 9) {
|
||||||
this->unman_time_select_->publish_state(S_UNMANNED_TIME_STR[data[FRAME_DATA_INDEX]]);
|
this->unman_time_select_->publish_state(S_UNMANNED_TIME_STR[data[FRAME_DATA_INDEX]]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else if ((this->keep_away_text_sensor_ != nullptr) &&
|
} else if ((this->keep_away_text_sensor_ != nullptr) &&
|
||||||
((data[FRAME_COMMAND_WORD_INDEX] == 0x0B) || (data[FRAME_COMMAND_WORD_INDEX] == 0x8B))) {
|
((data[FRAME_COMMAND_WORD_INDEX] == 0x0B) || (data[FRAME_COMMAND_WORD_INDEX] == 0x8B))) {
|
||||||
// none:0x00 close_to:0x01 far_away:0x02
|
// none:0x00 close_to:0x01 far_away:0x02
|
||||||
|
|||||||
28
tests/components/seeed_mr24hpc1/common_no_select.yaml
Normal file
28
tests/components/seeed_mr24hpc1/common_no_select.yaml
Normal file
@@ -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
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
substitutions:
|
||||||
|
uart_tx_pin: GPIO1
|
||||||
|
uart_rx_pin: GPIO3
|
||||||
|
|
||||||
|
<<: !include common_no_select.yaml
|
||||||
5
tests/components/seeed_mr24hpc1/test.esp8266-ard.yaml
Normal file
5
tests/components/seeed_mr24hpc1/test.esp8266-ard.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
substitutions:
|
||||||
|
uart_tx_pin: GPIO1
|
||||||
|
uart_rx_pin: GPIO3
|
||||||
|
|
||||||
|
<<: !include common.yaml
|
||||||
Reference in New Issue
Block a user