mirror of
https://github.com/esphome/esphome.git
synced 2025-10-31 23:21:54 +00:00
Fix seeed_mr24hpc1 compilation by adding comprehensive entity guards and renaming test file
Co-authored-by: jesserockz <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
@@ -64,15 +64,21 @@ void MR24HPC1Component::dump_config() {
|
|||||||
void MR24HPC1Component::setup() {
|
void MR24HPC1Component::setup() {
|
||||||
this->check_uart_settings(115200);
|
this->check_uart_settings(115200);
|
||||||
|
|
||||||
|
#ifdef USE_NUMBER
|
||||||
if (this->custom_mode_number_ != nullptr) {
|
if (this->custom_mode_number_ != nullptr) {
|
||||||
this->custom_mode_number_->publish_state(0); // Zero out the custom mode
|
this->custom_mode_number_->publish_state(0); // Zero out the custom mode
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_SENSOR
|
||||||
if (this->custom_mode_num_sensor_ != nullptr) {
|
if (this->custom_mode_num_sensor_ != nullptr) {
|
||||||
this->custom_mode_num_sensor_->publish_state(0);
|
this->custom_mode_num_sensor_->publish_state(0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_TEXT_SENSOR
|
||||||
if (this->custom_mode_end_text_sensor_ != nullptr) {
|
if (this->custom_mode_end_text_sensor_ != nullptr) {
|
||||||
this->custom_mode_end_text_sensor_->publish_state("Not in custom mode");
|
this->custom_mode_end_text_sensor_->publish_state("Not in custom mode");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
this->set_custom_end_mode();
|
this->set_custom_end_mode();
|
||||||
this->poll_time_base_func_check_ = true;
|
this->poll_time_base_func_check_ = true;
|
||||||
this->check_dev_inf_sign_ = true;
|
this->check_dev_inf_sign_ = true;
|
||||||
@@ -355,6 +361,7 @@ void MR24HPC1Component::r24_split_data_frame_(uint8_t value) {
|
|||||||
void MR24HPC1Component::r24_frame_parse_product_information_(uint8_t *data) {
|
void MR24HPC1Component::r24_frame_parse_product_information_(uint8_t *data) {
|
||||||
uint16_t product_len = encode_uint16(data[FRAME_COMMAND_WORD_INDEX + 1], data[FRAME_COMMAND_WORD_INDEX + 2]);
|
uint16_t product_len = encode_uint16(data[FRAME_COMMAND_WORD_INDEX + 1], data[FRAME_COMMAND_WORD_INDEX + 2]);
|
||||||
if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_PRODUCT_MODE) {
|
if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_PRODUCT_MODE) {
|
||||||
|
#ifdef USE_TEXT_SENSOR
|
||||||
if ((this->product_model_text_sensor_ != nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
|
if ((this->product_model_text_sensor_ != nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
|
||||||
memset(this->c_product_mode_, 0, PRODUCT_BUF_MAX_SIZE);
|
memset(this->c_product_mode_, 0, PRODUCT_BUF_MAX_SIZE);
|
||||||
memcpy(this->c_product_mode_, &data[FRAME_DATA_INDEX], product_len);
|
memcpy(this->c_product_mode_, &data[FRAME_DATA_INDEX], product_len);
|
||||||
@@ -362,7 +369,9 @@ void MR24HPC1Component::r24_frame_parse_product_information_(uint8_t *data) {
|
|||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "Reply: get product_mode error!");
|
ESP_LOGD(TAG, "Reply: get product_mode error!");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_PRODUCT_ID) {
|
} else if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_PRODUCT_ID) {
|
||||||
|
#ifdef USE_TEXT_SENSOR
|
||||||
if ((this->product_id_text_sensor_ != nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
|
if ((this->product_id_text_sensor_ != nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
|
||||||
memset(this->c_product_id_, 0, PRODUCT_BUF_MAX_SIZE);
|
memset(this->c_product_id_, 0, PRODUCT_BUF_MAX_SIZE);
|
||||||
memcpy(this->c_product_id_, &data[FRAME_DATA_INDEX], product_len);
|
memcpy(this->c_product_id_, &data[FRAME_DATA_INDEX], product_len);
|
||||||
@@ -370,7 +379,9 @@ void MR24HPC1Component::r24_frame_parse_product_information_(uint8_t *data) {
|
|||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "Reply: get productId error!");
|
ESP_LOGD(TAG, "Reply: get productId error!");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_HARDWARE_MODEL) {
|
} else if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_HARDWARE_MODEL) {
|
||||||
|
#ifdef USE_TEXT_SENSOR
|
||||||
if ((this->hardware_model_text_sensor_ != nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
|
if ((this->hardware_model_text_sensor_ != nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
|
||||||
memset(this->c_hardware_model_, 0, PRODUCT_BUF_MAX_SIZE);
|
memset(this->c_hardware_model_, 0, PRODUCT_BUF_MAX_SIZE);
|
||||||
memcpy(this->c_hardware_model_, &data[FRAME_DATA_INDEX], product_len);
|
memcpy(this->c_hardware_model_, &data[FRAME_DATA_INDEX], product_len);
|
||||||
@@ -379,7 +390,9 @@ void MR24HPC1Component::r24_frame_parse_product_information_(uint8_t *data) {
|
|||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "Reply: get hardwareModel error!");
|
ESP_LOGD(TAG, "Reply: get hardwareModel error!");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_FIRMWARE_VERSION) {
|
} else if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_FIRMWARE_VERSION) {
|
||||||
|
#ifdef USE_TEXT_SENSOR
|
||||||
if ((this->firware_version_text_sensor_ != nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
|
if ((this->firware_version_text_sensor_ != nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
|
||||||
memset(this->c_firmware_version_, 0, PRODUCT_BUF_MAX_SIZE);
|
memset(this->c_firmware_version_, 0, PRODUCT_BUF_MAX_SIZE);
|
||||||
memcpy(this->c_firmware_version_, &data[FRAME_DATA_INDEX], product_len);
|
memcpy(this->c_firmware_version_, &data[FRAME_DATA_INDEX], product_len);
|
||||||
@@ -387,22 +400,26 @@ void MR24HPC1Component::r24_frame_parse_product_information_(uint8_t *data) {
|
|||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "Reply: get firmwareVersion error!");
|
ESP_LOGD(TAG, "Reply: get firmwareVersion error!");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parsing the underlying open parameters
|
// Parsing the underlying open parameters
|
||||||
void MR24HPC1Component::r24_frame_parse_open_underlying_information_(uint8_t *data) {
|
void MR24HPC1Component::r24_frame_parse_open_underlying_information_(uint8_t *data) {
|
||||||
if (data[FRAME_COMMAND_WORD_INDEX] == 0x00) {
|
if (data[FRAME_COMMAND_WORD_INDEX] == 0x00) {
|
||||||
|
#ifdef USE_SWITCH
|
||||||
if (this->underlying_open_function_switch_ != nullptr) {
|
if (this->underlying_open_function_switch_ != nullptr) {
|
||||||
this->underlying_open_function_switch_->publish_state(
|
this->underlying_open_function_switch_->publish_state(
|
||||||
data[FRAME_DATA_INDEX]); // Underlying Open Parameter Switch Status Updates
|
data[FRAME_DATA_INDEX]); // Underlying Open Parameter Switch Status Updates
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (data[FRAME_DATA_INDEX]) {
|
if (data[FRAME_DATA_INDEX]) {
|
||||||
this->s_output_info_switch_flag_ = OUTPUT_SWITCH_ON;
|
this->s_output_info_switch_flag_ = OUTPUT_SWITCH_ON;
|
||||||
} else {
|
} else {
|
||||||
this->s_output_info_switch_flag_ = OUTPUT_SWTICH_OFF;
|
this->s_output_info_switch_flag_ = OUTPUT_SWTICH_OFF;
|
||||||
}
|
}
|
||||||
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x01) {
|
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x01) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
if (this->custom_spatial_static_value_sensor_ != nullptr) {
|
if (this->custom_spatial_static_value_sensor_ != nullptr) {
|
||||||
this->custom_spatial_static_value_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
this->custom_spatial_static_value_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
||||||
}
|
}
|
||||||
@@ -418,20 +435,29 @@ void MR24HPC1Component::r24_frame_parse_open_underlying_information_(uint8_t *da
|
|||||||
if (this->custom_motion_speed_sensor_ != nullptr) {
|
if (this->custom_motion_speed_sensor_ != nullptr) {
|
||||||
this->custom_motion_speed_sensor_->publish_state((data[FRAME_DATA_INDEX + 4] - 10) * 0.5f);
|
this->custom_motion_speed_sensor_->publish_state((data[FRAME_DATA_INDEX + 4] - 10) * 0.5f);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else if ((data[FRAME_COMMAND_WORD_INDEX] == 0x06) || (data[FRAME_COMMAND_WORD_INDEX] == 0x86)) {
|
} else if ((data[FRAME_COMMAND_WORD_INDEX] == 0x06) || (data[FRAME_COMMAND_WORD_INDEX] == 0x86)) {
|
||||||
// none:0x00 close_to:0x01 far_away:0x02
|
// none:0x00 close_to:0x01 far_away:0x02
|
||||||
|
#ifdef USE_TEXT_SENSOR
|
||||||
if ((this->keep_away_text_sensor_ != nullptr) && (data[FRAME_DATA_INDEX] < 3)) {
|
if ((this->keep_away_text_sensor_ != nullptr) && (data[FRAME_DATA_INDEX] < 3)) {
|
||||||
this->keep_away_text_sensor_->publish_state(S_KEEP_AWAY_STR[data[FRAME_DATA_INDEX]]);
|
this->keep_away_text_sensor_->publish_state(S_KEEP_AWAY_STR[data[FRAME_DATA_INDEX]]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else if ((this->movement_signs_sensor_ != nullptr) &&
|
} else if ((this->movement_signs_sensor_ != nullptr) &&
|
||||||
((data[FRAME_COMMAND_WORD_INDEX] == 0x07) || (data[FRAME_COMMAND_WORD_INDEX] == 0x87))) {
|
((data[FRAME_COMMAND_WORD_INDEX] == 0x07) || (data[FRAME_COMMAND_WORD_INDEX] == 0x87))) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
this->movement_signs_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
this->movement_signs_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
||||||
|
#endif
|
||||||
} else if ((this->existence_threshold_number_ != nullptr) &&
|
} else if ((this->existence_threshold_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))) {
|
||||||
|
#ifdef USE_NUMBER
|
||||||
this->existence_threshold_number_->publish_state(data[FRAME_DATA_INDEX]);
|
this->existence_threshold_number_->publish_state(data[FRAME_DATA_INDEX]);
|
||||||
|
#endif
|
||||||
} 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))) {
|
||||||
|
#ifdef USE_NUMBER
|
||||||
this->motion_threshold_number_->publish_state(data[FRAME_DATA_INDEX]);
|
this->motion_threshold_number_->publish_state(data[FRAME_DATA_INDEX]);
|
||||||
|
#endif
|
||||||
#ifdef USE_SELECT
|
#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))) {
|
||||||
@@ -446,46 +472,65 @@ void MR24HPC1Component::r24_frame_parse_open_underlying_information_(uint8_t *da
|
|||||||
#endif
|
#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))) {
|
||||||
|
#ifdef USE_NUMBER
|
||||||
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],
|
||||||
data[FRAME_DATA_INDEX + 2], data[FRAME_DATA_INDEX + 3]);
|
data[FRAME_DATA_INDEX + 2], data[FRAME_DATA_INDEX + 3]);
|
||||||
this->motion_trigger_number_->publish_state(motion_trigger_time);
|
this->motion_trigger_number_->publish_state(motion_trigger_time);
|
||||||
|
#endif
|
||||||
} else if ((this->motion_to_rest_number_ != nullptr) &&
|
} else if ((this->motion_to_rest_number_ != nullptr) &&
|
||||||
((data[FRAME_COMMAND_WORD_INDEX] == 0x0d) || (data[FRAME_COMMAND_WORD_INDEX] == 0x8d))) {
|
((data[FRAME_COMMAND_WORD_INDEX] == 0x0d) || (data[FRAME_COMMAND_WORD_INDEX] == 0x8d))) {
|
||||||
|
#ifdef USE_NUMBER
|
||||||
uint32_t move_to_rest_time = encode_uint32(data[FRAME_DATA_INDEX], data[FRAME_DATA_INDEX + 1],
|
uint32_t move_to_rest_time = encode_uint32(data[FRAME_DATA_INDEX], data[FRAME_DATA_INDEX + 1],
|
||||||
data[FRAME_DATA_INDEX + 2], data[FRAME_DATA_INDEX + 3]);
|
data[FRAME_DATA_INDEX + 2], data[FRAME_DATA_INDEX + 3]);
|
||||||
this->motion_to_rest_number_->publish_state(move_to_rest_time);
|
this->motion_to_rest_number_->publish_state(move_to_rest_time);
|
||||||
|
#endif
|
||||||
} else if ((this->custom_unman_time_number_ != nullptr) &&
|
} else if ((this->custom_unman_time_number_ != nullptr) &&
|
||||||
((data[FRAME_COMMAND_WORD_INDEX] == 0x0e) || (data[FRAME_COMMAND_WORD_INDEX] == 0x8e))) {
|
((data[FRAME_COMMAND_WORD_INDEX] == 0x0e) || (data[FRAME_COMMAND_WORD_INDEX] == 0x8e))) {
|
||||||
|
#ifdef USE_NUMBER
|
||||||
uint32_t enter_unmanned_time = encode_uint32(data[FRAME_DATA_INDEX], data[FRAME_DATA_INDEX + 1],
|
uint32_t enter_unmanned_time = encode_uint32(data[FRAME_DATA_INDEX], data[FRAME_DATA_INDEX + 1],
|
||||||
data[FRAME_DATA_INDEX + 2], data[FRAME_DATA_INDEX + 3]);
|
data[FRAME_DATA_INDEX + 2], data[FRAME_DATA_INDEX + 3]);
|
||||||
float custom_unmanned_time = enter_unmanned_time / 1000.0;
|
float custom_unmanned_time = enter_unmanned_time / 1000.0;
|
||||||
this->custom_unman_time_number_->publish_state(custom_unmanned_time);
|
this->custom_unman_time_number_->publish_state(custom_unmanned_time);
|
||||||
|
#endif
|
||||||
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x80) {
|
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x80) {
|
||||||
if (data[FRAME_DATA_INDEX]) {
|
if (data[FRAME_DATA_INDEX]) {
|
||||||
this->s_output_info_switch_flag_ = OUTPUT_SWITCH_ON;
|
this->s_output_info_switch_flag_ = OUTPUT_SWITCH_ON;
|
||||||
} else {
|
} else {
|
||||||
this->s_output_info_switch_flag_ = OUTPUT_SWTICH_OFF;
|
this->s_output_info_switch_flag_ = OUTPUT_SWTICH_OFF;
|
||||||
}
|
}
|
||||||
|
#ifdef USE_SWITCH
|
||||||
if (this->underlying_open_function_switch_ != nullptr) {
|
if (this->underlying_open_function_switch_ != nullptr) {
|
||||||
this->underlying_open_function_switch_->publish_state(data[FRAME_DATA_INDEX]);
|
this->underlying_open_function_switch_->publish_state(data[FRAME_DATA_INDEX]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else if ((this->custom_spatial_static_value_sensor_ != nullptr) && (data[FRAME_COMMAND_WORD_INDEX] == 0x81)) {
|
} else if ((this->custom_spatial_static_value_sensor_ != nullptr) && (data[FRAME_COMMAND_WORD_INDEX] == 0x81)) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
this->custom_spatial_static_value_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
this->custom_spatial_static_value_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
||||||
|
#endif
|
||||||
} else if ((this->custom_spatial_motion_value_sensor_ != nullptr) && (data[FRAME_COMMAND_WORD_INDEX] == 0x82)) {
|
} else if ((this->custom_spatial_motion_value_sensor_ != nullptr) && (data[FRAME_COMMAND_WORD_INDEX] == 0x82)) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
this->custom_spatial_motion_value_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
this->custom_spatial_motion_value_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
||||||
|
#endif
|
||||||
} else if ((this->custom_presence_of_detection_sensor_ != nullptr) && (data[FRAME_COMMAND_WORD_INDEX] == 0x83)) {
|
} else if ((this->custom_presence_of_detection_sensor_ != nullptr) && (data[FRAME_COMMAND_WORD_INDEX] == 0x83)) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
this->custom_presence_of_detection_sensor_->publish_state(
|
this->custom_presence_of_detection_sensor_->publish_state(
|
||||||
S_PRESENCE_OF_DETECTION_RANGE_STR[data[FRAME_DATA_INDEX]]);
|
S_PRESENCE_OF_DETECTION_RANGE_STR[data[FRAME_DATA_INDEX]]);
|
||||||
|
#endif
|
||||||
} else if ((this->custom_motion_distance_sensor_ != nullptr) && (data[FRAME_COMMAND_WORD_INDEX] == 0x84)) {
|
} else if ((this->custom_motion_distance_sensor_ != nullptr) && (data[FRAME_COMMAND_WORD_INDEX] == 0x84)) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
this->custom_motion_distance_sensor_->publish_state(data[FRAME_DATA_INDEX] * 0.5f);
|
this->custom_motion_distance_sensor_->publish_state(data[FRAME_DATA_INDEX] * 0.5f);
|
||||||
|
#endif
|
||||||
} else if ((this->custom_motion_speed_sensor_ != nullptr) && (data[FRAME_COMMAND_WORD_INDEX] == 0x85)) {
|
} else if ((this->custom_motion_speed_sensor_ != nullptr) && (data[FRAME_COMMAND_WORD_INDEX] == 0x85)) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
this->custom_motion_speed_sensor_->publish_state((data[FRAME_DATA_INDEX] - 10) * 0.5f);
|
this->custom_motion_speed_sensor_->publish_state((data[FRAME_DATA_INDEX] - 10) * 0.5f);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MR24HPC1Component::r24_parse_data_frame_(uint8_t *data, uint8_t len) {
|
void MR24HPC1Component::r24_parse_data_frame_(uint8_t *data, uint8_t len) {
|
||||||
switch (data[FRAME_CONTROL_WORD_INDEX]) {
|
switch (data[FRAME_CONTROL_WORD_INDEX]) {
|
||||||
case 0x01: {
|
case 0x01: {
|
||||||
|
#ifdef USE_TEXT_SENSOR
|
||||||
if ((this->heartbeat_state_text_sensor_ != nullptr) && (data[FRAME_COMMAND_WORD_INDEX] == 0x01)) {
|
if ((this->heartbeat_state_text_sensor_ != nullptr) && (data[FRAME_COMMAND_WORD_INDEX] == 0x01)) {
|
||||||
this->heartbeat_state_text_sensor_->publish_state("Equipment Normal");
|
this->heartbeat_state_text_sensor_->publish_state("Equipment Normal");
|
||||||
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x02) {
|
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x02) {
|
||||||
@@ -493,6 +538,11 @@ void MR24HPC1Component::r24_parse_data_frame_(uint8_t *data, uint8_t len) {
|
|||||||
} else if (this->heartbeat_state_text_sensor_ != nullptr) {
|
} else if (this->heartbeat_state_text_sensor_ != nullptr) {
|
||||||
this->heartbeat_state_text_sensor_->publish_state("Equipment Abnormal");
|
this->heartbeat_state_text_sensor_->publish_state("Equipment Abnormal");
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (data[FRAME_COMMAND_WORD_INDEX] == 0x02) {
|
||||||
|
ESP_LOGD(TAG, "Reply: query restart packet");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
} break;
|
} break;
|
||||||
case 0x02: {
|
case 0x02: {
|
||||||
this->r24_frame_parse_product_information_(data);
|
this->r24_frame_parse_product_information_(data);
|
||||||
@@ -526,18 +576,26 @@ void MR24HPC1Component::r24_frame_parse_work_status_(uint8_t *data) {
|
|||||||
} 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
|
||||||
|
#ifdef USE_NUMBER
|
||||||
this->sensitivity_number_->publish_state(data[FRAME_DATA_INDEX]);
|
this->sensitivity_number_->publish_state(data[FRAME_DATA_INDEX]);
|
||||||
|
#endif
|
||||||
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x09) {
|
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x09) {
|
||||||
// 1-4
|
// 1-4
|
||||||
|
#ifdef USE_SENSOR
|
||||||
if (this->custom_mode_num_sensor_ != nullptr) {
|
if (this->custom_mode_num_sensor_ != nullptr) {
|
||||||
this->custom_mode_num_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
this->custom_mode_num_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_NUMBER
|
||||||
if (this->custom_mode_number_ != nullptr) {
|
if (this->custom_mode_number_ != nullptr) {
|
||||||
this->custom_mode_number_->publish_state(0);
|
this->custom_mode_number_->publish_state(0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_TEXT_SENSOR
|
||||||
if (this->custom_mode_end_text_sensor_ != nullptr) {
|
if (this->custom_mode_end_text_sensor_ != nullptr) {
|
||||||
this->custom_mode_end_text_sensor_->publish_state("Setup in progress");
|
this->custom_mode_end_text_sensor_->publish_state("Setup in progress");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} 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) {
|
||||||
@@ -549,22 +607,32 @@ void MR24HPC1Component::r24_frame_parse_work_status_(uint8_t *data) {
|
|||||||
}
|
}
|
||||||
#endif
|
#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)) {
|
||||||
|
#ifdef USE_TEXT_SENSOR
|
||||||
this->custom_mode_end_text_sensor_->publish_state("Set Success!");
|
this->custom_mode_end_text_sensor_->publish_state("Set Success!");
|
||||||
|
#endif
|
||||||
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x89) {
|
} else if (data[FRAME_COMMAND_WORD_INDEX] == 0x89) {
|
||||||
if (data[FRAME_DATA_INDEX] == 0) {
|
if (data[FRAME_DATA_INDEX] == 0) {
|
||||||
|
#ifdef USE_TEXT_SENSOR
|
||||||
if (this->custom_mode_end_text_sensor_ != nullptr) {
|
if (this->custom_mode_end_text_sensor_ != nullptr) {
|
||||||
this->custom_mode_end_text_sensor_->publish_state("Not in custom mode");
|
this->custom_mode_end_text_sensor_->publish_state("Not in custom mode");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_NUMBER
|
||||||
if (this->custom_mode_number_ != nullptr) {
|
if (this->custom_mode_number_ != nullptr) {
|
||||||
this->custom_mode_number_->publish_state(0);
|
this->custom_mode_number_->publish_state(0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_SENSOR
|
||||||
if (this->custom_mode_num_sensor_ != nullptr) {
|
if (this->custom_mode_num_sensor_ != nullptr) {
|
||||||
this->custom_mode_num_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
this->custom_mode_num_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
if (this->custom_mode_num_sensor_ != nullptr) {
|
if (this->custom_mode_num_sensor_ != nullptr) {
|
||||||
this->custom_mode_num_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
this->custom_mode_num_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "[%s] No found COMMAND_WORD(%02X) in Frame", __FUNCTION__, data[FRAME_COMMAND_WORD_INDEX]);
|
ESP_LOGD(TAG, "[%s] No found COMMAND_WORD(%02X) in Frame", __FUNCTION__, data[FRAME_COMMAND_WORD_INDEX]);
|
||||||
@@ -574,15 +642,21 @@ void MR24HPC1Component::r24_frame_parse_work_status_(uint8_t *data) {
|
|||||||
void MR24HPC1Component::r24_frame_parse_human_information_(uint8_t *data) {
|
void MR24HPC1Component::r24_frame_parse_human_information_(uint8_t *data) {
|
||||||
if ((this->has_target_binary_sensor_ != nullptr) &&
|
if ((this->has_target_binary_sensor_ != nullptr) &&
|
||||||
((data[FRAME_COMMAND_WORD_INDEX] == 0x01) || (data[FRAME_COMMAND_WORD_INDEX] == 0x81))) {
|
((data[FRAME_COMMAND_WORD_INDEX] == 0x01) || (data[FRAME_COMMAND_WORD_INDEX] == 0x81))) {
|
||||||
|
#ifdef USE_BINARY_SENSOR
|
||||||
this->has_target_binary_sensor_->publish_state(S_SOMEONE_EXISTS_STR[data[FRAME_DATA_INDEX]]);
|
this->has_target_binary_sensor_->publish_state(S_SOMEONE_EXISTS_STR[data[FRAME_DATA_INDEX]]);
|
||||||
|
#endif
|
||||||
} else if ((this->motion_status_text_sensor_ != nullptr) &&
|
} else if ((this->motion_status_text_sensor_ != nullptr) &&
|
||||||
((data[FRAME_COMMAND_WORD_INDEX] == 0x02) || (data[FRAME_COMMAND_WORD_INDEX] == 0x82))) {
|
((data[FRAME_COMMAND_WORD_INDEX] == 0x02) || (data[FRAME_COMMAND_WORD_INDEX] == 0x82))) {
|
||||||
|
#ifdef USE_TEXT_SENSOR
|
||||||
if (data[FRAME_DATA_INDEX] < 3) {
|
if (data[FRAME_DATA_INDEX] < 3) {
|
||||||
this->motion_status_text_sensor_->publish_state(S_MOTION_STATUS_STR[data[FRAME_DATA_INDEX]]);
|
this->motion_status_text_sensor_->publish_state(S_MOTION_STATUS_STR[data[FRAME_DATA_INDEX]]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} 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))) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
this->movement_signs_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
this->movement_signs_sensor_->publish_state(data[FRAME_DATA_INDEX]);
|
||||||
|
#endif
|
||||||
#ifdef USE_SELECT
|
#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))) {
|
||||||
@@ -594,9 +668,11 @@ void MR24HPC1Component::r24_frame_parse_human_information_(uint8_t *data) {
|
|||||||
} 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
|
||||||
|
#ifdef USE_TEXT_SENSOR
|
||||||
if (data[FRAME_DATA_INDEX] < 3) {
|
if (data[FRAME_DATA_INDEX] < 3) {
|
||||||
this->keep_away_text_sensor_->publish_state(S_KEEP_AWAY_STR[data[FRAME_DATA_INDEX]]);
|
this->keep_away_text_sensor_->publish_state(S_KEEP_AWAY_STR[data[FRAME_DATA_INDEX]]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "[%s] No found COMMAND_WORD(%02X) in Frame", __FUNCTION__, data[FRAME_COMMAND_WORD_INDEX]);
|
ESP_LOGD(TAG, "[%s] No found COMMAND_WORD(%02X) in Frame", __FUNCTION__, data[FRAME_COMMAND_WORD_INDEX]);
|
||||||
}
|
}
|
||||||
@@ -703,12 +779,15 @@ void MR24HPC1Component::set_underlying_open_function(bool enable) {
|
|||||||
} else {
|
} else {
|
||||||
this->send_query_(UNDERLYING_SWITCH_OFF, sizeof(UNDERLYING_SWITCH_OFF));
|
this->send_query_(UNDERLYING_SWITCH_OFF, sizeof(UNDERLYING_SWITCH_OFF));
|
||||||
}
|
}
|
||||||
|
#ifdef USE_TEXT_SENSOR
|
||||||
if (this->keep_away_text_sensor_ != nullptr) {
|
if (this->keep_away_text_sensor_ != nullptr) {
|
||||||
this->keep_away_text_sensor_->publish_state("");
|
this->keep_away_text_sensor_->publish_state("");
|
||||||
}
|
}
|
||||||
if (this->motion_status_text_sensor_ != nullptr) {
|
if (this->motion_status_text_sensor_ != nullptr) {
|
||||||
this->motion_status_text_sensor_->publish_state("");
|
this->motion_status_text_sensor_->publish_state("");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_SENSOR
|
||||||
if (this->custom_spatial_static_value_sensor_ != nullptr) {
|
if (this->custom_spatial_static_value_sensor_ != nullptr) {
|
||||||
this->custom_spatial_static_value_sensor_->publish_state(NAN);
|
this->custom_spatial_static_value_sensor_->publish_state(NAN);
|
||||||
}
|
}
|
||||||
@@ -724,6 +803,7 @@ void MR24HPC1Component::set_underlying_open_function(bool enable) {
|
|||||||
if (this->custom_motion_speed_sensor_ != nullptr) {
|
if (this->custom_motion_speed_sensor_ != nullptr) {
|
||||||
this->custom_motion_speed_sensor_->publish_state(NAN);
|
this->custom_motion_speed_sensor_->publish_state(NAN);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MR24HPC1Component::set_scene_mode(uint8_t value) {
|
void MR24HPC1Component::set_scene_mode(uint8_t value) {
|
||||||
@@ -731,12 +811,16 @@ void MR24HPC1Component::set_scene_mode(uint8_t value) {
|
|||||||
uint8_t send_data[10] = {0x53, 0x59, 0x05, 0x07, 0x00, 0x01, value, 0x00, 0x54, 0x43};
|
uint8_t send_data[10] = {0x53, 0x59, 0x05, 0x07, 0x00, 0x01, value, 0x00, 0x54, 0x43};
|
||||||
send_data[7] = get_frame_crc_sum(send_data, send_data_len);
|
send_data[7] = get_frame_crc_sum(send_data, send_data_len);
|
||||||
this->send_query_(send_data, send_data_len);
|
this->send_query_(send_data, send_data_len);
|
||||||
|
#ifdef USE_NUMBER
|
||||||
if (this->custom_mode_number_ != nullptr) {
|
if (this->custom_mode_number_ != nullptr) {
|
||||||
this->custom_mode_number_->publish_state(0);
|
this->custom_mode_number_->publish_state(0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_SENSOR
|
||||||
if (this->custom_mode_num_sensor_ != nullptr) {
|
if (this->custom_mode_num_sensor_ != nullptr) {
|
||||||
this->custom_mode_num_sensor_->publish_state(0);
|
this->custom_mode_num_sensor_->publish_state(0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
this->get_scene_mode();
|
this->get_scene_mode();
|
||||||
this->get_sensitivity();
|
this->get_sensitivity();
|
||||||
this->get_custom_mode();
|
this->get_custom_mode();
|
||||||
@@ -776,9 +860,11 @@ void MR24HPC1Component::set_unman_time(uint8_t value) {
|
|||||||
void MR24HPC1Component::set_custom_mode(uint8_t mode) {
|
void MR24HPC1Component::set_custom_mode(uint8_t mode) {
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
this->set_custom_end_mode(); // Equivalent to end setting
|
this->set_custom_end_mode(); // Equivalent to end setting
|
||||||
|
#ifdef USE_NUMBER
|
||||||
if (this->custom_mode_number_ != nullptr) {
|
if (this->custom_mode_number_ != nullptr) {
|
||||||
this->custom_mode_number_->publish_state(0);
|
this->custom_mode_number_->publish_state(0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t send_data_len = 10;
|
uint8_t send_data_len = 10;
|
||||||
@@ -801,9 +887,11 @@ void MR24HPC1Component::set_custom_end_mode() {
|
|||||||
uint8_t send_data_len = 10;
|
uint8_t send_data_len = 10;
|
||||||
uint8_t send_data[10] = {0x53, 0x59, 0x05, 0x0a, 0x00, 0x01, 0x0F, 0xCB, 0x54, 0x43};
|
uint8_t send_data[10] = {0x53, 0x59, 0x05, 0x0a, 0x00, 0x01, 0x0F, 0xCB, 0x54, 0x43};
|
||||||
this->send_query_(send_data, send_data_len);
|
this->send_query_(send_data, send_data_len);
|
||||||
|
#ifdef USE_NUMBER
|
||||||
if (this->custom_mode_number_ != nullptr) {
|
if (this->custom_mode_number_ != nullptr) {
|
||||||
this->custom_mode_number_->publish_state(0); // Clear setpoints
|
this->custom_mode_number_->publish_state(0); // Clear setpoints
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
this->get_existence_boundary();
|
this->get_existence_boundary();
|
||||||
this->get_motion_boundary();
|
this->get_motion_boundary();
|
||||||
this->get_existence_threshold();
|
this->get_existence_threshold();
|
||||||
@@ -817,8 +905,10 @@ void MR24HPC1Component::set_custom_end_mode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MR24HPC1Component::set_existence_boundary(uint8_t value) {
|
void MR24HPC1Component::set_existence_boundary(uint8_t value) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
if ((this->custom_mode_num_sensor_ != nullptr) && (this->custom_mode_num_sensor_->state == 0))
|
if ((this->custom_mode_num_sensor_ != nullptr) && (this->custom_mode_num_sensor_->state == 0))
|
||||||
return; // You'll have to check that you're in custom mode to set it up
|
return; // You'll have to check that you're in custom mode to set it up
|
||||||
|
#endif
|
||||||
uint8_t send_data_len = 10;
|
uint8_t send_data_len = 10;
|
||||||
uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x0A, 0x00, 0x01, (uint8_t) (value + 1), 0x00, 0x54, 0x43};
|
uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x0A, 0x00, 0x01, (uint8_t) (value + 1), 0x00, 0x54, 0x43};
|
||||||
send_data[7] = get_frame_crc_sum(send_data, send_data_len);
|
send_data[7] = get_frame_crc_sum(send_data, send_data_len);
|
||||||
@@ -827,8 +917,10 @@ void MR24HPC1Component::set_existence_boundary(uint8_t value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MR24HPC1Component::set_motion_boundary(uint8_t value) {
|
void MR24HPC1Component::set_motion_boundary(uint8_t value) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
if ((this->custom_mode_num_sensor_ != nullptr) && (this->custom_mode_num_sensor_->state == 0))
|
if ((this->custom_mode_num_sensor_ != nullptr) && (this->custom_mode_num_sensor_->state == 0))
|
||||||
return; // You'll have to check that you're in custom mode to set it up
|
return; // You'll have to check that you're in custom mode to set it up
|
||||||
|
#endif
|
||||||
uint8_t send_data_len = 10;
|
uint8_t send_data_len = 10;
|
||||||
uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x0B, 0x00, 0x01, (uint8_t) (value + 1), 0x00, 0x54, 0x43};
|
uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x0B, 0x00, 0x01, (uint8_t) (value + 1), 0x00, 0x54, 0x43};
|
||||||
send_data[7] = get_frame_crc_sum(send_data, send_data_len);
|
send_data[7] = get_frame_crc_sum(send_data, send_data_len);
|
||||||
@@ -837,8 +929,10 @@ void MR24HPC1Component::set_motion_boundary(uint8_t value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MR24HPC1Component::set_existence_threshold(uint8_t value) {
|
void MR24HPC1Component::set_existence_threshold(uint8_t value) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
if ((this->custom_mode_num_sensor_ != nullptr) && (this->custom_mode_num_sensor_->state == 0))
|
if ((this->custom_mode_num_sensor_ != nullptr) && (this->custom_mode_num_sensor_->state == 0))
|
||||||
return; // You'll have to check that you're in custom mode to set it up
|
return; // You'll have to check that you're in custom mode to set it up
|
||||||
|
#endif
|
||||||
uint8_t send_data_len = 10;
|
uint8_t send_data_len = 10;
|
||||||
uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x08, 0x00, 0x01, value, 0x00, 0x54, 0x43};
|
uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x08, 0x00, 0x01, value, 0x00, 0x54, 0x43};
|
||||||
send_data[7] = get_frame_crc_sum(send_data, send_data_len);
|
send_data[7] = get_frame_crc_sum(send_data, send_data_len);
|
||||||
@@ -847,8 +941,10 @@ void MR24HPC1Component::set_existence_threshold(uint8_t value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MR24HPC1Component::set_motion_threshold(uint8_t value) {
|
void MR24HPC1Component::set_motion_threshold(uint8_t value) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
if ((this->custom_mode_num_sensor_ != nullptr) && (this->custom_mode_num_sensor_->state == 0))
|
if ((this->custom_mode_num_sensor_ != nullptr) && (this->custom_mode_num_sensor_->state == 0))
|
||||||
return; // You'll have to check that you're in custom mode to set it up
|
return; // You'll have to check that you're in custom mode to set it up
|
||||||
|
#endif
|
||||||
uint8_t send_data_len = 10;
|
uint8_t send_data_len = 10;
|
||||||
uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x09, 0x00, 0x01, value, 0x00, 0x54, 0x43};
|
uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x09, 0x00, 0x01, value, 0x00, 0x54, 0x43};
|
||||||
send_data[7] = get_frame_crc_sum(send_data, send_data_len);
|
send_data[7] = get_frame_crc_sum(send_data, send_data_len);
|
||||||
@@ -857,8 +953,10 @@ void MR24HPC1Component::set_motion_threshold(uint8_t value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MR24HPC1Component::set_motion_trigger_time(uint8_t value) {
|
void MR24HPC1Component::set_motion_trigger_time(uint8_t value) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
if ((this->custom_mode_num_sensor_ != nullptr) && (this->custom_mode_num_sensor_->state == 0))
|
if ((this->custom_mode_num_sensor_ != nullptr) && (this->custom_mode_num_sensor_->state == 0))
|
||||||
return; // You'll have to check that you're in custom mode to set it up
|
return; // You'll have to check that you're in custom mode to set it up
|
||||||
|
#endif
|
||||||
uint8_t send_data_len = 13;
|
uint8_t send_data_len = 13;
|
||||||
uint8_t send_data[13] = {0x53, 0x59, 0x08, 0x0C, 0x00, 0x04, 0x00, 0x00, 0x00, value, 0x00, 0x54, 0x43};
|
uint8_t send_data[13] = {0x53, 0x59, 0x08, 0x0C, 0x00, 0x04, 0x00, 0x00, 0x00, value, 0x00, 0x54, 0x43};
|
||||||
send_data[10] = get_frame_crc_sum(send_data, send_data_len);
|
send_data[10] = get_frame_crc_sum(send_data, send_data_len);
|
||||||
@@ -867,8 +965,10 @@ void MR24HPC1Component::set_motion_trigger_time(uint8_t value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MR24HPC1Component::set_motion_to_rest_time(uint16_t value) {
|
void MR24HPC1Component::set_motion_to_rest_time(uint16_t value) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
if ((this->custom_mode_num_sensor_ != nullptr) && (this->custom_mode_num_sensor_->state == 0))
|
if ((this->custom_mode_num_sensor_ != nullptr) && (this->custom_mode_num_sensor_->state == 0))
|
||||||
return; // You'll have to check that you're in custom mode to set it up
|
return; // You'll have to check that you're in custom mode to set it up
|
||||||
|
#endif
|
||||||
uint8_t h8_num = (value >> 8) & 0xff;
|
uint8_t h8_num = (value >> 8) & 0xff;
|
||||||
uint8_t l8_num = value & 0xff;
|
uint8_t l8_num = value & 0xff;
|
||||||
uint8_t send_data_len = 13;
|
uint8_t send_data_len = 13;
|
||||||
@@ -879,8 +979,10 @@ void MR24HPC1Component::set_motion_to_rest_time(uint16_t value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MR24HPC1Component::set_custom_unman_time(uint16_t value) {
|
void MR24HPC1Component::set_custom_unman_time(uint16_t value) {
|
||||||
|
#ifdef USE_SENSOR
|
||||||
if ((this->custom_mode_num_sensor_ != nullptr) && (this->custom_mode_num_sensor_->state == 0))
|
if ((this->custom_mode_num_sensor_ != nullptr) && (this->custom_mode_num_sensor_->state == 0))
|
||||||
return; // You'll have to check that you're in custom mode to set it up
|
return; // You'll have to check that you're in custom mode to set it up
|
||||||
|
#endif
|
||||||
uint32_t value_ms = value * 1000;
|
uint32_t value_ms = value * 1000;
|
||||||
uint8_t h24_num = (value_ms >> 24) & 0xff;
|
uint8_t h24_num = (value_ms >> 24) & 0xff;
|
||||||
uint8_t h16_num = (value_ms >> 16) & 0xff;
|
uint8_t h16_num = (value_ms >> 16) & 0xff;
|
||||||
|
|||||||
5
tests/components/seeed_mr24hpc1/.gitignore
vendored
Normal file
5
tests/components/seeed_mr24hpc1/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Gitignore settings for ESPHome
|
||||||
|
# This is an example and may include too much for your use-case.
|
||||||
|
# You can modify this file to suit your needs.
|
||||||
|
/.esphome/
|
||||||
|
/secrets.yaml
|
||||||
@@ -1,3 +1,13 @@
|
|||||||
|
esphome:
|
||||||
|
name: test-esp8266
|
||||||
|
friendly_name: "Test ESP8266"
|
||||||
|
|
||||||
|
esp8266:
|
||||||
|
board: d1_mini
|
||||||
|
|
||||||
|
logger:
|
||||||
|
level: VERY_VERBOSE
|
||||||
|
|
||||||
uart:
|
uart:
|
||||||
- id: seeed_mr24hpc1_uart
|
- id: seeed_mr24hpc1_uart
|
||||||
tx_pin: ${uart_tx_pin}
|
tx_pin: ${uart_tx_pin}
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
esphome:
|
||||||
|
name: test-no-select-esp8266
|
||||||
|
friendly_name: "Test No Select ESP8266"
|
||||||
|
|
||||||
|
esp8266:
|
||||||
|
board: d1_mini
|
||||||
|
|
||||||
|
logger:
|
||||||
|
level: VERY_VERBOSE
|
||||||
|
|
||||||
uart:
|
uart:
|
||||||
- id: seeed_mr24hpc1_uart
|
- id: seeed_mr24hpc1_uart
|
||||||
tx_pin: ${uart_tx_pin}
|
tx_pin: ${uart_tx_pin}
|
||||||
|
|||||||
Reference in New Issue
Block a user