9namespace seeed_mr24hpc1 {
11static const char *
const TAG =
"seeed_mr24hpc1";
16 ESP_LOGCONFIG(TAG,
"MR24HPC1:");
18 LOG_TEXT_SENSOR(
" ",
"Heartbeat Text Sensor", this->heartbeat_state_text_sensor_);
19 LOG_TEXT_SENSOR(
" ",
"Product Model Text Sensor", this->product_model_text_sensor_);
20 LOG_TEXT_SENSOR(
" ",
"Product ID Text Sensor", this->product_id_text_sensor_);
21 LOG_TEXT_SENSOR(
" ",
"Hardware Model Text Sensor", this->hardware_model_text_sensor_);
22 LOG_TEXT_SENSOR(
" ",
"Firware Verison Text Sensor", this->firware_version_text_sensor_);
23 LOG_TEXT_SENSOR(
" ",
"Keep Away Text Sensor", this->keep_away_text_sensor_);
24 LOG_TEXT_SENSOR(
" ",
"Motion Status Text Sensor", this->motion_status_text_sensor_);
25 LOG_TEXT_SENSOR(
" ",
"Custom Mode End Text Sensor", this->custom_mode_end_text_sensor_);
27#ifdef USE_BINARY_SENSOR
28 LOG_BINARY_SENSOR(
" ",
"Has Target Binary Sensor", this->has_target_binary_sensor_);
31 LOG_SENSOR(
" ",
"Custom Presence Of Detection Sensor", this->custom_presence_of_detection_sensor_);
32 LOG_SENSOR(
" ",
"Movement Signs Sensor", this->movement_signs_sensor_);
33 LOG_SENSOR(
" ",
"Custom Motion Distance Sensor", this->custom_motion_distance_sensor_);
34 LOG_SENSOR(
" ",
"Custom Spatial Static Sensor", this->custom_spatial_static_value_sensor_);
35 LOG_SENSOR(
" ",
"Custom Spatial Motion Sensor", this->custom_spatial_motion_value_sensor_);
36 LOG_SENSOR(
" ",
"Custom Motion Speed Sensor", this->custom_motion_speed_sensor_);
37 LOG_SENSOR(
" ",
"Custom Mode Num Sensor", this->custom_mode_num_sensor_);
40 LOG_SWITCH(
" ",
"Underly Open Function Switch", this->underlying_open_function_switch_);
43 LOG_BUTTON(
" ",
"Restart Button", this->restart_button_);
44 LOG_BUTTON(
" ",
"Custom Set End Button", this->custom_set_end_button_);
47 LOG_SELECT(
" ",
"Scene Mode Select", this->scene_mode_select_);
48 LOG_SELECT(
" ",
"Unman Time Select", this->unman_time_select_);
49 LOG_SELECT(
" ",
"Existence Boundary Select", this->existence_boundary_select_);
50 LOG_SELECT(
" ",
"Motion Boundary Select", this->motion_boundary_select_);
53 LOG_NUMBER(
" ",
"Sensitivity Number", this->sensitivity_number_);
54 LOG_NUMBER(
" ",
"Custom Mode Number", this->custom_mode_number_);
55 LOG_NUMBER(
" ",
"Existence Threshold Number", this->existence_threshold_number_);
56 LOG_NUMBER(
" ",
"Motion Threshold Number", this->motion_threshold_number_);
57 LOG_NUMBER(
" ",
"Motion Trigger Time Number", this->motion_trigger_number_);
58 LOG_NUMBER(
" ",
"Motion To Rest Time Number", this->motion_to_rest_number_);
59 LOG_NUMBER(
" ",
"Custom Unman Time Number", this->custom_unman_time_number_);
68 if (this->custom_mode_number_ !=
nullptr) {
69 this->custom_mode_number_->publish_state(0);
73 if (this->custom_mode_num_sensor_ !=
nullptr) {
74 this->custom_mode_num_sensor_->publish_state(0);
78 if (this->custom_mode_end_text_sensor_ !=
nullptr) {
79 this->custom_mode_end_text_sensor_->publish_state(
"Not in custom mode");
83 this->poll_time_base_func_check_ =
true;
84 this->check_dev_inf_sign_ =
true;
86 this->sg_data_len_ = 0;
87 this->sg_frame_len_ = 0;
91 memset(this->c_product_mode_, 0, PRODUCT_BUF_MAX_SIZE);
92 memset(this->c_product_id_, 0, PRODUCT_BUF_MAX_SIZE);
93 memset(this->c_firmware_version_, 0, PRODUCT_BUF_MAX_SIZE);
94 memset(this->c_hardware_model_, 0, PRODUCT_BUF_MAX_SIZE);
95 memset(this->sg_frame_prase_buf_, 0, FRAME_BUF_MAX_SIZE);
96 memset(this->sg_frame_buf_, 0, FRAME_BUF_MAX_SIZE);
102void MR24HPC1Component::update_() {
104 this->poll_time_base_func_check_ =
true;
114 this->r24_split_data_frame_(
byte);
129 if (this->poll_time_base_func_check_) {
130 switch (this->sg_start_query_data_) {
133 this->sg_start_query_data_++;
137 this->sg_start_query_data_++;
143 this->sg_start_query_data_++;
149 this->sg_start_query_data_++;
150 this->check_dev_inf_sign_ =
false;
154 this->sg_start_query_data_++;
158 this->sg_start_query_data_++;
162 this->sg_start_query_data_++;
166 this->sg_start_query_data_++;
170 this->sg_start_query_data_++;
174 this->sg_start_query_data_++;
178 this->sg_start_query_data_++;
182 this->sg_start_query_data_++;
186 this->sg_start_query_data_++;
190 this->sg_start_query_data_++;
194 this->sg_start_query_data_++;
198 this->sg_start_query_data_++;
202 this->sg_start_query_data_++;
206 this->sg_start_query_data_++;
210 this->sg_start_query_data_++;
214 this->sg_start_query_data_++;
216 this->poll_time_base_func_check_ =
false;
221 this->sg_start_query_data_++;
225 this->sg_start_query_data_++;
229 this->sg_start_query_data_++;
233 this->sg_start_query_data_++;
237 this->sg_start_query_data_++;
241 this->sg_start_query_data_++;
242 this->poll_time_base_func_check_ =
false;
251static uint8_t get_frame_crc_sum(
const uint8_t *data,
int len) {
252 unsigned int crc_sum = 0;
253 for (
int i = 0; i <
len - 3; i++) {
256 return crc_sum & 0xff;
260static int get_frame_check_status(uint8_t *data,
int len) {
261 uint8_t crc_sum = get_frame_crc_sum(data,
len);
262 uint8_t verified = data[
len - 3];
263 return (verified == crc_sum) ? 1 : 0;
267void MR24HPC1Component::r24_split_data_frame_(uint8_t value) {
268 switch (this->sg_recv_data_state_) {
270 if (FRAME_HEADER1_VALUE == value) {
275 if (FRAME_HEADER2_VALUE == value) {
276 this->sg_frame_buf_[0] = FRAME_HEADER1_VALUE;
277 this->sg_frame_buf_[1] = FRAME_HEADER2_VALUE;
281 ESP_LOGD(TAG,
"FRAME_IDLE ERROR value:%x", value);
285 this->sg_frame_buf_[2] = value;
289 this->sg_frame_buf_[3] = value;
294 this->sg_data_len_ = value * 256;
295 this->sg_frame_buf_[4] = value;
298 this->sg_data_len_ = 0;
300 ESP_LOGD(TAG,
"FRAME_DATA_LEN_H ERROR value:%x", value);
304 this->sg_data_len_ += value;
305 if (this->sg_data_len_ > 32) {
306 ESP_LOGD(TAG,
"len=%d, FRAME_DATA_LEN_L ERROR value:%x", this->sg_data_len_, value);
307 this->sg_data_len_ = 0;
310 this->sg_frame_buf_[5] = value;
311 this->sg_frame_len_ = 6;
316 this->sg_data_len_ -= 1;
317 this->sg_frame_buf_[this->sg_frame_len_++] = value;
318 if (this->sg_data_len_ <= 0) {
323 this->sg_frame_buf_[this->sg_frame_len_++] = value;
327 if (FRAME_TAIL1_VALUE == value) {
331 this->sg_frame_len_ = 0;
332 this->sg_data_len_ = 0;
333 ESP_LOGD(TAG,
"FRAME_TAIL1 ERROR value:%x", value);
337 if (FRAME_TAIL2_VALUE == value) {
338 this->sg_frame_buf_[this->sg_frame_len_++] = FRAME_TAIL1_VALUE;
339 this->sg_frame_buf_[this->sg_frame_len_++] = FRAME_TAIL2_VALUE;
340 memcpy(this->sg_frame_prase_buf_, this->sg_frame_buf_, this->sg_frame_len_);
341 if (get_frame_check_status(this->sg_frame_prase_buf_, this->sg_frame_len_)) {
342 this->r24_parse_data_frame_(this->sg_frame_prase_buf_, this->sg_frame_len_);
344 ESP_LOGD(TAG,
"frame check failer!");
347 ESP_LOGD(TAG,
"FRAME_TAIL2 ERROR value:%x", value);
349 memset(this->sg_frame_prase_buf_, 0, FRAME_BUF_MAX_SIZE);
350 memset(this->sg_frame_buf_, 0, FRAME_BUF_MAX_SIZE);
351 this->sg_frame_len_ = 0;
352 this->sg_data_len_ = 0;
361void MR24HPC1Component::r24_frame_parse_product_information_(uint8_t *data) {
362#ifdef USE_TEXT_SENSOR
363 uint16_t product_len =
encode_uint16(data[FRAME_COMMAND_WORD_INDEX + 1], data[FRAME_COMMAND_WORD_INDEX + 2]);
364 if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_PRODUCT_MODE) {
365 if ((this->product_model_text_sensor_ !=
nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
366 memset(this->c_product_mode_, 0, PRODUCT_BUF_MAX_SIZE);
367 memcpy(this->c_product_mode_, &data[FRAME_DATA_INDEX], product_len);
368 this->product_model_text_sensor_->publish_state(this->c_product_mode_);
370 ESP_LOGD(TAG,
"Reply: get product_mode error!");
372 }
else if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_PRODUCT_ID) {
373 if ((this->product_id_text_sensor_ !=
nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
374 memset(this->c_product_id_, 0, PRODUCT_BUF_MAX_SIZE);
375 memcpy(this->c_product_id_, &data[FRAME_DATA_INDEX], product_len);
376 this->product_id_text_sensor_->publish_state(this->c_product_id_);
378 ESP_LOGD(TAG,
"Reply: get productId error!");
380 }
else if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_HARDWARE_MODEL) {
381 if ((this->hardware_model_text_sensor_ !=
nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
382 memset(this->c_hardware_model_, 0, PRODUCT_BUF_MAX_SIZE);
383 memcpy(this->c_hardware_model_, &data[FRAME_DATA_INDEX], product_len);
384 this->hardware_model_text_sensor_->publish_state(this->c_hardware_model_);
385 ESP_LOGD(TAG,
"Reply: get hardware_model :%s", this->c_hardware_model_);
387 ESP_LOGD(TAG,
"Reply: get hardwareModel error!");
389 }
else if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_FIRMWARE_VERSION) {
390 if ((this->firware_version_text_sensor_ !=
nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
391 memset(this->c_firmware_version_, 0, PRODUCT_BUF_MAX_SIZE);
392 memcpy(this->c_firmware_version_, &data[FRAME_DATA_INDEX], product_len);
393 this->firware_version_text_sensor_->publish_state(this->c_firmware_version_);
395 ESP_LOGD(TAG,
"Reply: get firmwareVersion error!");
402void MR24HPC1Component::r24_frame_parse_open_underlying_information_(uint8_t *data) {
403 switch (data[FRAME_COMMAND_WORD_INDEX]) {
407 if (this->underlying_open_function_switch_ !=
nullptr) {
408 this->underlying_open_function_switch_->publish_state(data[FRAME_DATA_INDEX]);
415 if (this->custom_spatial_static_value_sensor_ !=
nullptr) {
416 this->custom_spatial_static_value_sensor_->publish_state(data[FRAME_DATA_INDEX]);
418 if (this->custom_presence_of_detection_sensor_ !=
nullptr) {
419 this->custom_presence_of_detection_sensor_->publish_state(data[FRAME_DATA_INDEX + 1] * 0.5f);
421 if (this->custom_spatial_motion_value_sensor_ !=
nullptr) {
422 this->custom_spatial_motion_value_sensor_->publish_state(data[FRAME_DATA_INDEX + 2]);
424 if (this->custom_motion_distance_sensor_ !=
nullptr) {
425 this->custom_motion_distance_sensor_->publish_state(data[FRAME_DATA_INDEX + 3] * 0.5f);
427 if (this->custom_motion_speed_sensor_ !=
nullptr) {
428 this->custom_motion_speed_sensor_->publish_state((data[FRAME_DATA_INDEX + 4] - 10) * 0.5f);
433 if (this->movement_signs_sensor_ !=
nullptr) {
434 this->movement_signs_sensor_->publish_state(data[FRAME_DATA_INDEX]);
438 if (this->custom_spatial_static_value_sensor_ !=
nullptr) {
439 this->custom_spatial_static_value_sensor_->publish_state(data[FRAME_DATA_INDEX]);
443 if (this->custom_spatial_motion_value_sensor_ !=
nullptr) {
444 this->custom_spatial_motion_value_sensor_->publish_state(data[FRAME_DATA_INDEX]);
448 if (this->custom_presence_of_detection_sensor_ !=
nullptr) {
449 this->custom_presence_of_detection_sensor_->publish_state(
450 S_PRESENCE_OF_DETECTION_RANGE_STR[data[FRAME_DATA_INDEX]]);
454 if (this->custom_motion_distance_sensor_ !=
nullptr) {
455 this->custom_motion_distance_sensor_->publish_state(data[FRAME_DATA_INDEX] * 0.5f);
459 if (this->custom_motion_speed_sensor_ !=
nullptr) {
460 this->custom_motion_speed_sensor_->publish_state((data[FRAME_DATA_INDEX] - 10) * 0.5f);
464#ifdef USE_TEXT_SENSOR
468 if ((this->keep_away_text_sensor_ !=
nullptr) && (data[FRAME_DATA_INDEX] < 3)) {
469 this->keep_away_text_sensor_->publish_state(S_KEEP_AWAY_STR[data[FRAME_DATA_INDEX]]);
476 if (this->existence_threshold_number_ !=
nullptr) {
477 this->existence_threshold_number_->publish_state(data[FRAME_DATA_INDEX]);
482 if (this->motion_threshold_number_ !=
nullptr) {
483 this->motion_threshold_number_->publish_state(data[FRAME_DATA_INDEX]);
488 if (this->motion_trigger_number_ !=
nullptr) {
490 data[FRAME_DATA_INDEX + 2], data[FRAME_DATA_INDEX + 3]);
491 this->motion_trigger_number_->publish_state(motion_trigger_time);
496 if (this->motion_to_rest_number_ !=
nullptr) {
498 data[FRAME_DATA_INDEX + 2], data[FRAME_DATA_INDEX + 3]);
499 this->motion_to_rest_number_->publish_state(move_to_rest_time);
504 if (this->custom_unman_time_number_ !=
nullptr) {
506 data[FRAME_DATA_INDEX + 2], data[FRAME_DATA_INDEX + 3]);
507 this->custom_unman_time_number_->publish_state(enter_unmanned_time / 1000.0f);
514 if (this->existence_boundary_select_ !=
nullptr) {
515 if (this->existence_boundary_select_->has_index(data[FRAME_DATA_INDEX] - 1)) {
516 this->existence_boundary_select_->publish_state(data[FRAME_DATA_INDEX] - 1);
522 if (this->motion_boundary_select_ !=
nullptr) {
523 if (this->motion_boundary_select_->has_index(data[FRAME_DATA_INDEX] - 1)) {
524 this->motion_boundary_select_->publish_state(data[FRAME_DATA_INDEX] - 1);
532void MR24HPC1Component::r24_parse_data_frame_(uint8_t *data, uint8_t
len) {
533 switch (data[FRAME_CONTROL_WORD_INDEX]) {
535 if (data[FRAME_COMMAND_WORD_INDEX] == 0x02) {
536 ESP_LOGD(TAG,
"Reply: query restart packet");
539#ifdef USE_TEXT_SENSOR
540 if (this->heartbeat_state_text_sensor_ !=
nullptr) {
541 this->heartbeat_state_text_sensor_->publish_state(
542 data[FRAME_COMMAND_WORD_INDEX] == 0x01 ?
"Equipment Normal" :
"Equipment Abnormal");
547 this->r24_frame_parse_product_information_(data);
550 this->r24_frame_parse_work_status_(data);
553 this->r24_frame_parse_open_underlying_information_(data);
556 this->r24_frame_parse_human_information_(data);
559 ESP_LOGD(TAG,
"control word:0x%02X not found", data[FRAME_CONTROL_WORD_INDEX]);
564void MR24HPC1Component::r24_frame_parse_work_status_(uint8_t *data) {
565 switch (data[FRAME_COMMAND_WORD_INDEX]) {
568 ESP_LOGD(TAG,
"Reply: get radar init status 0x%02X", data[FRAME_DATA_INDEX]);
572 if (this->custom_mode_num_sensor_ !=
nullptr) {
573 this->custom_mode_num_sensor_->publish_state(data[FRAME_DATA_INDEX]);
577 if (this->custom_mode_number_ !=
nullptr) {
578 this->custom_mode_number_->publish_state(0);
581#ifdef USE_TEXT_SENSOR
582 if (this->custom_mode_end_text_sensor_ !=
nullptr) {
583 this->custom_mode_end_text_sensor_->publish_state(
"Setup in progress");
589 if (this->custom_mode_num_sensor_ !=
nullptr) {
590 this->custom_mode_num_sensor_->publish_state(data[FRAME_DATA_INDEX]);
593 if (data[FRAME_DATA_INDEX] == 0) {
594#ifdef USE_TEXT_SENSOR
595 if (this->custom_mode_end_text_sensor_ !=
nullptr) {
596 this->custom_mode_end_text_sensor_->publish_state(
"Not in custom mode");
600 if (this->custom_mode_number_ !=
nullptr) {
601 this->custom_mode_number_->publish_state(0);
609 if ((this->scene_mode_select_ !=
nullptr) && (this->scene_mode_select_->has_index(data[FRAME_DATA_INDEX]))) {
610 this->scene_mode_select_->publish_state(data[FRAME_DATA_INDEX]);
612 ESP_LOGD(TAG,
"Select has index offset %d Error", data[FRAME_DATA_INDEX]);
619 if (this->sensitivity_number_ !=
nullptr) {
620 this->sensitivity_number_->publish_state(data[FRAME_DATA_INDEX]);
624#ifdef USE_TEXT_SENSOR
626 if (this->custom_mode_end_text_sensor_ !=
nullptr) {
627 this->custom_mode_end_text_sensor_->publish_state(
"Set Success!");
632 ESP_LOGD(TAG,
"[%s] No found COMMAND_WORD(%02X) in Frame", __FUNCTION__, data[FRAME_COMMAND_WORD_INDEX]);
637void MR24HPC1Component::r24_frame_parse_human_information_(uint8_t *data) {
638 switch (data[FRAME_COMMAND_WORD_INDEX]) {
639#ifdef USE_BINARY_SENSOR
642 if (this->has_target_binary_sensor_ !=
nullptr) {
643 this->has_target_binary_sensor_->publish_state(S_SOMEONE_EXISTS_STR[data[FRAME_DATA_INDEX]]);
650 if (this->movement_signs_sensor_ !=
nullptr) {
651 this->movement_signs_sensor_->publish_state(data[FRAME_DATA_INDEX]);
655#ifdef USE_TEXT_SENSOR
658 if ((this->motion_status_text_sensor_ !=
nullptr) && (data[FRAME_DATA_INDEX] < 3)) {
659 this->motion_status_text_sensor_->publish_state(S_MOTION_STATUS_STR[data[FRAME_DATA_INDEX]]);
665 if ((this->keep_away_text_sensor_ !=
nullptr) && (data[FRAME_DATA_INDEX] < 3)) {
666 this->keep_away_text_sensor_->publish_state(S_KEEP_AWAY_STR[data[FRAME_DATA_INDEX]]);
674 if ((this->unman_time_select_ !=
nullptr) && (data[FRAME_DATA_INDEX] < 9)) {
675 this->unman_time_select_->publish_state(data[FRAME_DATA_INDEX]);
680 ESP_LOGD(TAG,
"[%s] No found COMMAND_WORD(%02X) in Frame", __FUNCTION__, data[FRAME_COMMAND_WORD_INDEX]);
686void MR24HPC1Component::send_query_(
const uint8_t *query,
size_t string_length) {
695 this->send_query_(GET_RADAR_OUTPUT_INFORMATION_SWITCH,
sizeof(GET_RADAR_OUTPUT_INFORMATION_SWITCH));
709 this->send_query_(GET_FIRMWARE_VERSION,
sizeof(GET_FIRMWARE_VERSION));
715 this->send_query_(GET_HUMAN_MOTION_INFORMATION,
sizeof(GET_HUMAN_MOTION_INFORMATION));
719 this->send_query_(GET_BODY_MOTION_PARAMETERS,
sizeof(GET_BODY_MOTION_PARAMETERS));
733 this->send_query_(GET_EXISTENCE_BOUNDARY,
sizeof(GET_EXISTENCE_BOUNDARY));
739 this->send_query_(GET_SPATIAL_STATIC_VALUE,
sizeof(GET_SPATIAL_STATIC_VALUE));
743 this->send_query_(GET_SPATIAL_MOTION_VALUE,
sizeof(GET_SPATIAL_MOTION_VALUE));
747 this->send_query_(GET_DISTANCE_OF_STATIC_OBJECT,
sizeof(GET_DISTANCE_OF_STATIC_OBJECT));
751 this->send_query_(GET_DISTANCE_OF_MOVING_OBJECT,
sizeof(GET_DISTANCE_OF_MOVING_OBJECT));
755 this->send_query_(GET_TARGET_MOVEMENT_SPEED,
sizeof(GET_TARGET_MOVEMENT_SPEED));
759 this->send_query_(GET_EXISTENCE_THRESHOLD,
sizeof(GET_EXISTENCE_THRESHOLD));
763 this->send_query_(GET_MOTION_THRESHOLD,
sizeof(GET_MOTION_THRESHOLD));
767 this->send_query_(GET_MOTION_TRIGGER_TIME,
sizeof(GET_MOTION_TRIGGER_TIME));
771 this->send_query_(GET_MOTION_TO_REST_TIME,
sizeof(GET_MOTION_TO_REST_TIME));
775 this->send_query_(GET_CUSTOM_UNMAN_TIME,
sizeof(GET_CUSTOM_UNMAN_TIME));
782 this->send_query_(UNDERLYING_SWITCH_ON,
sizeof(UNDERLYING_SWITCH_ON));
784 this->send_query_(UNDERLYING_SWITCH_OFF,
sizeof(UNDERLYING_SWITCH_OFF));
786#ifdef USE_TEXT_SENSOR
787 if (this->keep_away_text_sensor_ !=
nullptr) {
788 this->keep_away_text_sensor_->publish_state(
"");
790 if (this->motion_status_text_sensor_ !=
nullptr) {
791 this->motion_status_text_sensor_->publish_state(
"");
795 if (this->custom_spatial_static_value_sensor_ !=
nullptr) {
796 this->custom_spatial_static_value_sensor_->publish_state(NAN);
798 if (this->custom_spatial_motion_value_sensor_ !=
nullptr) {
799 this->custom_spatial_motion_value_sensor_->publish_state(NAN);
801 if (this->custom_motion_distance_sensor_ !=
nullptr) {
802 this->custom_motion_distance_sensor_->publish_state(NAN);
804 if (this->custom_presence_of_detection_sensor_ !=
nullptr) {
805 this->custom_presence_of_detection_sensor_->publish_state(NAN);
807 if (this->custom_motion_speed_sensor_ !=
nullptr) {
808 this->custom_motion_speed_sensor_->publish_state(NAN);
814 uint8_t send_data_len = 10;
815 uint8_t send_data[10] = {0x53, 0x59, 0x05, 0x07, 0x00, 0x01, value, 0x00, 0x54, 0x43};
816 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
817 this->send_query_(send_data, send_data_len);
819 if (this->custom_mode_number_ !=
nullptr) {
820 this->custom_mode_number_->publish_state(0);
824 if (this->custom_mode_num_sensor_ !=
nullptr) {
825 this->custom_mode_num_sensor_->publish_state(0);
843 uint8_t send_data_len = 10;
844 uint8_t send_data[10] = {0x53, 0x59, 0x05, 0x08, 0x00, 0x01, value, 0x00, 0x54, 0x43};
845 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
846 this->send_query_(send_data, send_data_len);
852 this->send_query_(SET_RESTART,
sizeof(SET_RESTART));
853 this->check_dev_inf_sign_ =
true;
857 uint8_t send_data_len = 10;
858 uint8_t send_data[10] = {0x53, 0x59, 0x80, 0x0a, 0x00, 0x01, value, 0x00, 0x54, 0x43};
859 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
860 this->send_query_(send_data, send_data_len);
868 if (this->custom_mode_number_ !=
nullptr) {
869 this->custom_mode_number_->publish_state(0);
874 uint8_t send_data_len = 10;
875 uint8_t send_data[10] = {0x53, 0x59, 0x05, 0x09, 0x00, 0x01,
mode, 0x00, 0x54, 0x43};
876 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
877 this->send_query_(send_data, send_data_len);
891 uint8_t send_data_len = 10;
892 uint8_t send_data[10] = {0x53, 0x59, 0x05, 0x0a, 0x00, 0x01, 0x0F, 0xCB, 0x54, 0x43};
893 this->send_query_(send_data, send_data_len);
895 if (this->custom_mode_number_ !=
nullptr) {
896 this->custom_mode_number_->publish_state(0);
913 if ((this->custom_mode_num_sensor_ !=
nullptr) && (this->custom_mode_num_sensor_->state == 0))
916 uint8_t send_data_len = 10;
917 uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x0A, 0x00, 0x01, (uint8_t) (value + 1), 0x00, 0x54, 0x43};
918 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
919 this->send_query_(send_data, send_data_len);
925 if ((this->custom_mode_num_sensor_ !=
nullptr) && (this->custom_mode_num_sensor_->state == 0))
928 uint8_t send_data_len = 10;
929 uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x0B, 0x00, 0x01, (uint8_t) (value + 1), 0x00, 0x54, 0x43};
930 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
931 this->send_query_(send_data, send_data_len);
937 if ((this->custom_mode_num_sensor_ !=
nullptr) && (this->custom_mode_num_sensor_->state == 0))
940 uint8_t send_data_len = 10;
941 uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x08, 0x00, 0x01, value, 0x00, 0x54, 0x43};
942 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
943 this->send_query_(send_data, send_data_len);
949 if ((this->custom_mode_num_sensor_ !=
nullptr) && (this->custom_mode_num_sensor_->state == 0))
952 uint8_t send_data_len = 10;
953 uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x09, 0x00, 0x01, value, 0x00, 0x54, 0x43};
954 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
955 this->send_query_(send_data, send_data_len);
961 if ((this->custom_mode_num_sensor_ !=
nullptr) && (this->custom_mode_num_sensor_->state == 0))
964 uint8_t send_data_len = 13;
965 uint8_t send_data[13] = {0x53, 0x59, 0x08, 0x0C, 0x00, 0x04, 0x00, 0x00, 0x00, value, 0x00, 0x54, 0x43};
966 send_data[10] = get_frame_crc_sum(send_data, send_data_len);
967 this->send_query_(send_data, send_data_len);
973 if ((this->custom_mode_num_sensor_ !=
nullptr) && (this->custom_mode_num_sensor_->state == 0))
976 uint8_t h8_num = (value >> 8) & 0xff;
977 uint8_t l8_num = value & 0xff;
978 uint8_t send_data_len = 13;
979 uint8_t send_data[13] = {0x53, 0x59, 0x08, 0x0D, 0x00, 0x04, 0x00, 0x00, h8_num, l8_num, 0x00, 0x54, 0x43};
980 send_data[10] = get_frame_crc_sum(send_data, send_data_len);
981 this->send_query_(send_data, send_data_len);
987 if ((this->custom_mode_num_sensor_ !=
nullptr) && (this->custom_mode_num_sensor_->state == 0))
990 uint32_t value_ms = value * 1000;
991 uint8_t h24_num = (value_ms >> 24) & 0xff;
992 uint8_t h16_num = (value_ms >> 16) & 0xff;
993 uint8_t h8_num = (value_ms >> 8) & 0xff;
994 uint8_t l8_num = value_ms & 0xff;
995 uint8_t send_data_len = 13;
996 uint8_t send_data[13] = {0x53, 0x59, 0x08, 0x0E, 0x00, 0x04, h24_num, h16_num, h8_num, l8_num, 0x00, 0x54, 0x43};
997 send_data[10] = get_frame_crc_sum(send_data, send_data_len);
998 this->send_query_(send_data, send_data_len);
BedjetMode mode
BedJet operating mode.
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") void set_interval(const std voi set_interval)(const char *name, uint32_t interval, std::function< void()> &&f)
Set an interval function with a unique name.
void get_firmware_version()
void set_custom_unman_time(uint16_t value)
void set_underlying_open_function(bool enable)
void set_motion_trigger_time(uint8_t value)
void set_motion_boundary(uint8_t value)
void dump_config() override
void set_unman_time(uint8_t value)
void get_human_motion_info()
void set_sensitivity(uint8_t value)
void set_existence_threshold(uint8_t value)
void get_custom_unman_time()
void set_existence_boundary(uint8_t value)
void get_hardware_model()
void set_motion_threshold(uint8_t value)
void get_radar_output_information_switch()
void set_scene_mode(uint8_t value)
void get_distance_of_moving_object()
void get_motion_trigger_time()
void get_existence_boundary()
void get_motion_to_rest_time()
void get_spatial_motion_value()
void get_motion_threshold()
void get_spatial_static_value()
void set_motion_to_rest_time(uint16_t value)
void set_custom_end_mode()
void get_target_movement_speed()
void get_body_motion_params()
void get_motion_boundary()
void get_existence_threshold()
void set_custom_mode(uint8_t mode)
void get_distance_of_static_object()
void get_heartbeat_packet()
void check_uart_settings(uint32_t baud_rate, uint8_t stop_bits=1, UARTParityOptions parity=UART_CONFIG_PARITY_NONE, uint8_t data_bits=8)
Check that the configuration of the UART bus matches the provided values and otherwise print a warnin...
bool read_byte(uint8_t *data)
void write_array(const uint8_t *data, size_t len)
@ UNDERLY_FUNCTION_QUERY_HUMAN_STATUS
@ STANDARD_FUNCTION_QUERY_PRODUCT_ID
@ CUSTOM_FUNCTION_QUERY_EXISTENCE_BOUNDARY
@ STANDARD_FUNCTION_QUERY_KEEPAWAY_STATUS
@ STANDARD_FUNCTION_QUERY_BODY_MOVE_PARAMETER
@ STANDARD_FUNCTION_QUERY_HARDWARE_MODE
@ STANDARD_FUNCTION_QUERY_HUMAN_MOTION_INF
@ CUSTOM_FUNCTION_QUERY_MOTION_TRIGGER_TIME
@ STANDARD_FUNCTION_QUERY_FIRMWARE_VERSION
@ STANDARD_FUNCTION_QUERY_HUMAN_STATUS
@ CUSTOM_FUNCTION_QUERY_MOTION_BOUNDARY
@ STANDARD_FUNCTION_QUERY_UNMANNED_TIME
@ STANDARD_FUNCTION_QUERY_PRODUCT_MODE
@ CUSTOM_FUNCTION_QUERY_MOTION_THRESHOLD
@ UNDERLY_FUNCTION_QUERY_SPATIAL_MOTION_VALUE
@ CUSTOM_FUNCTION_QUERY_EXISTENCE_THRESHOLD
@ STANDARD_FUNCTION_QUERY_SCENE_MODE
@ UNDERLY_FUNCTION_QUERY_SPATIAL_STATIC_VALUE
@ STANDARD_FUNCTION_QUERY_SENSITIVITY
@ CUSTOM_FUNCTION_QUERY_TIME_OF_ENTER_UNMANNED
@ STANDARD_QUERY_CUSTOM_MODE
@ UNDERLY_FUNCTION_QUERY_TARGET_MOVEMENT_SPEED
@ UNDERLY_FUNCTION_QUERY_DISTANCE_OF_STATIC_OBJECT
@ STANDARD_FUNCTION_QUERY_HEARTBEAT_STATE
@ CUSTOM_FUNCTION_QUERY_MOTION_TO_REST_TIME
@ UNDERLY_FUNCTION_QUERY_DISTANCE_OF_MOVING_OBJECT
Providing packet encoding functions for exchanging data with a remote host.
constexpr uint32_t encode_uint32(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4)
Encode a 32-bit value given four bytes in most to least significant byte order.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.