10static const char *
const TAG =
"seeed_mr24hpc1";
12static constexpr uint32_t STARTUP_DELAY_MS = 1000;
17 ESP_LOGCONFIG(TAG,
"MR24HPC1:");
19 LOG_TEXT_SENSOR(
" ",
"Heartbeat Text Sensor", this->heartbeat_state_text_sensor_);
20 LOG_TEXT_SENSOR(
" ",
"Product Model Text Sensor", this->product_model_text_sensor_);
21 LOG_TEXT_SENSOR(
" ",
"Product ID Text Sensor", this->product_id_text_sensor_);
22 LOG_TEXT_SENSOR(
" ",
"Hardware Model Text Sensor", this->hardware_model_text_sensor_);
23 LOG_TEXT_SENSOR(
" ",
"Firware Verison Text Sensor", this->firware_version_text_sensor_);
24 LOG_TEXT_SENSOR(
" ",
"Keep Away Text Sensor", this->keep_away_text_sensor_);
25 LOG_TEXT_SENSOR(
" ",
"Motion Status Text Sensor", this->motion_status_text_sensor_);
26 LOG_TEXT_SENSOR(
" ",
"Custom Mode End Text Sensor", this->custom_mode_end_text_sensor_);
28#ifdef USE_BINARY_SENSOR
29 LOG_BINARY_SENSOR(
" ",
"Has Target Binary Sensor", this->has_target_binary_sensor_);
32 LOG_SENSOR(
" ",
"Custom Presence Of Detection Sensor", this->custom_presence_of_detection_sensor_);
33 LOG_SENSOR(
" ",
"Movement Signs Sensor", this->movement_signs_sensor_);
34 LOG_SENSOR(
" ",
"Custom Motion Distance Sensor", this->custom_motion_distance_sensor_);
35 LOG_SENSOR(
" ",
"Custom Spatial Static Sensor", this->custom_spatial_static_value_sensor_);
36 LOG_SENSOR(
" ",
"Custom Spatial Motion Sensor", this->custom_spatial_motion_value_sensor_);
37 LOG_SENSOR(
" ",
"Custom Motion Speed Sensor", this->custom_motion_speed_sensor_);
38 LOG_SENSOR(
" ",
"Custom Mode Num Sensor", this->custom_mode_num_sensor_);
41 LOG_SWITCH(
" ",
"Underly Open Function Switch", this->underlying_open_function_switch_);
44 LOG_BUTTON(
" ",
"Restart Button", this->restart_button_);
45 LOG_BUTTON(
" ",
"Custom Set End Button", this->custom_set_end_button_);
48 LOG_SELECT(
" ",
"Scene Mode Select", this->scene_mode_select_);
49 LOG_SELECT(
" ",
"Unman Time Select", this->unman_time_select_);
50 LOG_SELECT(
" ",
"Existence Boundary Select", this->existence_boundary_select_);
51 LOG_SELECT(
" ",
"Motion Boundary Select", this->motion_boundary_select_);
54 LOG_NUMBER(
" ",
"Sensitivity Number", this->sensitivity_number_);
55 LOG_NUMBER(
" ",
"Custom Mode Number", this->custom_mode_number_);
56 LOG_NUMBER(
" ",
"Existence Threshold Number", this->existence_threshold_number_);
57 LOG_NUMBER(
" ",
"Motion Threshold Number", this->motion_threshold_number_);
58 LOG_NUMBER(
" ",
"Motion Trigger Time Number", this->motion_trigger_number_);
59 LOG_NUMBER(
" ",
"Motion To Rest Time Number", this->motion_to_rest_number_);
60 LOG_NUMBER(
" ",
"Custom Unman Time Number", this->custom_unman_time_number_);
67 if (this->custom_mode_number_ !=
nullptr) {
68 this->custom_mode_number_->publish_state(0);
72 if (this->custom_mode_num_sensor_ !=
nullptr) {
73 this->custom_mode_num_sensor_->publish_state(0);
77 if (this->custom_mode_end_text_sensor_ !=
nullptr) {
78 this->custom_mode_end_text_sensor_->publish_state(
"Not in custom mode");
81 this->poll_time_base_func_check_ =
false;
82 this->check_dev_inf_sign_ =
true;
84 this->sg_data_len_ = 0;
85 this->sg_frame_len_ = 0;
89 memset(this->c_product_mode_, 0, PRODUCT_BUF_MAX_SIZE);
90 memset(this->c_product_id_, 0, PRODUCT_BUF_MAX_SIZE);
91 memset(this->c_firmware_version_, 0, PRODUCT_BUF_MAX_SIZE);
92 memset(this->c_hardware_model_, 0, PRODUCT_BUF_MAX_SIZE);
93 memset(this->sg_frame_prase_buf_, 0, FRAME_BUF_MAX_SIZE);
94 memset(this->sg_frame_buf_, 0, FRAME_BUF_MAX_SIZE);
98 this->module_ready_ =
true;
100 this->poll_time_base_func_check_ =
true;
101 this->
set_interval(8000, [
this]() { this->update_(); });
106void MR24HPC1Component::update_() {
108 this->poll_time_base_func_check_ =
true;
117 size_t to_read = std::min(avail,
sizeof(buf));
123 for (
size_t i = 0; i < to_read; i++) {
124 this->r24_split_data_frame_(buf[i]);
140 if (this->poll_time_base_func_check_) {
141 switch (this->sg_start_query_data_) {
144 this->sg_start_query_data_++;
148 this->sg_start_query_data_++;
154 this->sg_start_query_data_++;
160 this->sg_start_query_data_++;
161 this->check_dev_inf_sign_ =
false;
165 this->sg_start_query_data_++;
169 this->sg_start_query_data_++;
173 this->sg_start_query_data_++;
177 this->sg_start_query_data_++;
181 this->sg_start_query_data_++;
185 this->sg_start_query_data_++;
189 this->sg_start_query_data_++;
193 this->sg_start_query_data_++;
197 this->sg_start_query_data_++;
201 this->sg_start_query_data_++;
205 this->sg_start_query_data_++;
209 this->sg_start_query_data_++;
213 this->sg_start_query_data_++;
217 this->sg_start_query_data_++;
221 this->sg_start_query_data_++;
225 this->sg_start_query_data_++;
227 this->poll_time_base_func_check_ =
false;
232 this->sg_start_query_data_++;
236 this->sg_start_query_data_++;
240 this->sg_start_query_data_++;
244 this->sg_start_query_data_++;
248 this->sg_start_query_data_++;
252 this->sg_start_query_data_++;
253 this->poll_time_base_func_check_ =
false;
262static uint8_t get_frame_crc_sum(
const uint8_t *data,
int len) {
263 unsigned int crc_sum = 0;
264 for (
int i = 0; i <
len - 3; i++) {
267 return crc_sum & 0xff;
271static int get_frame_check_status(uint8_t *data,
int len) {
272 uint8_t crc_sum = get_frame_crc_sum(data,
len);
273 uint8_t verified = data[
len - 3];
274 return (verified == crc_sum) ? 1 : 0;
278void MR24HPC1Component::r24_split_data_frame_(uint8_t value) {
279 switch (this->sg_recv_data_state_) {
281 if (FRAME_HEADER1_VALUE == value) {
286 if (FRAME_HEADER2_VALUE == value) {
287 this->sg_frame_buf_[0] = FRAME_HEADER1_VALUE;
288 this->sg_frame_buf_[1] = FRAME_HEADER2_VALUE;
292 ESP_LOGD(TAG,
"FRAME_IDLE ERROR value:%x", value);
296 this->sg_frame_buf_[2] = value;
300 this->sg_frame_buf_[3] = value;
305 this->sg_frame_buf_[4] = value;
309 ESP_LOGD(TAG,
"FRAME_DATA_LEN_H ERROR value:%x", value);
313 this->sg_data_len_ = value;
314 if (this->sg_data_len_ == 0 || this->sg_data_len_ > 32) {
315 ESP_LOGD(TAG,
"len=%d, FRAME_DATA_LEN_L ERROR value:%x", this->sg_data_len_, value);
316 this->sg_data_len_ = 0;
319 this->sg_frame_buf_[5] = value;
320 this->sg_frame_len_ = 6;
325 this->sg_frame_buf_[this->sg_frame_len_++] = value;
326 if (--this->sg_data_len_ == 0) {
331 this->sg_frame_buf_[this->sg_frame_len_++] = value;
335 if (FRAME_TAIL1_VALUE == value) {
339 this->sg_frame_len_ = 0;
340 this->sg_data_len_ = 0;
341 ESP_LOGD(TAG,
"FRAME_TAIL1 ERROR value:%x", value);
345 if (FRAME_TAIL2_VALUE == value) {
346 this->sg_frame_buf_[this->sg_frame_len_++] = FRAME_TAIL1_VALUE;
347 this->sg_frame_buf_[this->sg_frame_len_++] = FRAME_TAIL2_VALUE;
348 memcpy(this->sg_frame_prase_buf_, this->sg_frame_buf_, this->sg_frame_len_);
349 if (get_frame_check_status(this->sg_frame_prase_buf_, this->sg_frame_len_)) {
350 this->r24_parse_data_frame_(this->sg_frame_prase_buf_, this->sg_frame_len_);
352 ESP_LOGD(TAG,
"frame check failer!");
355 ESP_LOGD(TAG,
"FRAME_TAIL2 ERROR value:%x", value);
357 memset(this->sg_frame_prase_buf_, 0, FRAME_BUF_MAX_SIZE);
358 memset(this->sg_frame_buf_, 0, FRAME_BUF_MAX_SIZE);
359 this->sg_frame_len_ = 0;
360 this->sg_data_len_ = 0;
369void MR24HPC1Component::r24_frame_parse_product_information_(uint8_t *data) {
370#ifdef USE_TEXT_SENSOR
371 uint16_t product_len =
encode_uint16(data[FRAME_COMMAND_WORD_INDEX + 1], data[FRAME_COMMAND_WORD_INDEX + 2]);
372 if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_PRODUCT_MODE) {
373 if ((this->product_model_text_sensor_ !=
nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
374 memset(this->c_product_mode_, 0, PRODUCT_BUF_MAX_SIZE);
375 memcpy(this->c_product_mode_, &data[FRAME_DATA_INDEX], product_len);
376 this->product_model_text_sensor_->publish_state(this->c_product_mode_);
378 ESP_LOGD(TAG,
"Reply: get product_mode error!");
380 }
else if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_PRODUCT_ID) {
381 if ((this->product_id_text_sensor_ !=
nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
382 memset(this->c_product_id_, 0, PRODUCT_BUF_MAX_SIZE);
383 memcpy(this->c_product_id_, &data[FRAME_DATA_INDEX], product_len);
384 this->product_id_text_sensor_->publish_state(this->c_product_id_);
386 ESP_LOGD(TAG,
"Reply: get productId error!");
388 }
else if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_HARDWARE_MODEL) {
389 if ((this->hardware_model_text_sensor_ !=
nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
390 memset(this->c_hardware_model_, 0, PRODUCT_BUF_MAX_SIZE);
391 memcpy(this->c_hardware_model_, &data[FRAME_DATA_INDEX], product_len);
392 this->hardware_model_text_sensor_->publish_state(this->c_hardware_model_);
393 ESP_LOGD(TAG,
"Reply: get hardware_model :%s", this->c_hardware_model_);
395 ESP_LOGD(TAG,
"Reply: get hardwareModel error!");
397 }
else if (data[FRAME_COMMAND_WORD_INDEX] == COMMAND_FIRMWARE_VERSION) {
398 if ((this->firware_version_text_sensor_ !=
nullptr) && (product_len < PRODUCT_BUF_MAX_SIZE)) {
399 memset(this->c_firmware_version_, 0, PRODUCT_BUF_MAX_SIZE);
400 memcpy(this->c_firmware_version_, &data[FRAME_DATA_INDEX], product_len);
401 this->firware_version_text_sensor_->publish_state(this->c_firmware_version_);
403 ESP_LOGD(TAG,
"Reply: get firmwareVersion error!");
410void MR24HPC1Component::r24_frame_parse_open_underlying_information_(uint8_t *data) {
411 switch (data[FRAME_COMMAND_WORD_INDEX]) {
415 if (this->underlying_open_function_switch_ !=
nullptr) {
416 this->underlying_open_function_switch_->publish_state(data[FRAME_DATA_INDEX]);
423 if (this->custom_spatial_static_value_sensor_ !=
nullptr) {
424 this->custom_spatial_static_value_sensor_->publish_state(data[FRAME_DATA_INDEX]);
426 if (this->custom_presence_of_detection_sensor_ !=
nullptr) {
427 this->custom_presence_of_detection_sensor_->publish_state(data[FRAME_DATA_INDEX + 1] * 0.5f);
429 if (this->custom_spatial_motion_value_sensor_ !=
nullptr) {
430 this->custom_spatial_motion_value_sensor_->publish_state(data[FRAME_DATA_INDEX + 2]);
432 if (this->custom_motion_distance_sensor_ !=
nullptr) {
433 this->custom_motion_distance_sensor_->publish_state(data[FRAME_DATA_INDEX + 3] * 0.5f);
435 if (this->custom_motion_speed_sensor_ !=
nullptr) {
436 this->custom_motion_speed_sensor_->publish_state((data[FRAME_DATA_INDEX + 4] - 10) * 0.5f);
441 if (this->movement_signs_sensor_ !=
nullptr) {
442 this->movement_signs_sensor_->publish_state(data[FRAME_DATA_INDEX]);
446 if (this->custom_spatial_static_value_sensor_ !=
nullptr) {
447 this->custom_spatial_static_value_sensor_->publish_state(data[FRAME_DATA_INDEX]);
451 if (this->custom_spatial_motion_value_sensor_ !=
nullptr) {
452 this->custom_spatial_motion_value_sensor_->publish_state(data[FRAME_DATA_INDEX]);
456 if (this->custom_presence_of_detection_sensor_ !=
nullptr &&
457 data[FRAME_DATA_INDEX] < std::size(S_PRESENCE_OF_DETECTION_RANGE_STR)) {
458 this->custom_presence_of_detection_sensor_->publish_state(
459 S_PRESENCE_OF_DETECTION_RANGE_STR[data[FRAME_DATA_INDEX]]);
463 if (this->custom_motion_distance_sensor_ !=
nullptr) {
464 this->custom_motion_distance_sensor_->publish_state(data[FRAME_DATA_INDEX] * 0.5f);
468 if (this->custom_motion_speed_sensor_ !=
nullptr) {
469 this->custom_motion_speed_sensor_->publish_state((data[FRAME_DATA_INDEX] - 10) * 0.5f);
473#ifdef USE_TEXT_SENSOR
477 if ((this->keep_away_text_sensor_ !=
nullptr) && (data[FRAME_DATA_INDEX] < 3)) {
478 this->keep_away_text_sensor_->publish_state(S_KEEP_AWAY_STR[data[FRAME_DATA_INDEX]]);
485 if (this->existence_threshold_number_ !=
nullptr) {
486 this->existence_threshold_number_->publish_state(data[FRAME_DATA_INDEX]);
491 if (this->motion_threshold_number_ !=
nullptr) {
492 this->motion_threshold_number_->publish_state(data[FRAME_DATA_INDEX]);
497 if (this->motion_trigger_number_ !=
nullptr) {
499 data[FRAME_DATA_INDEX + 2], data[FRAME_DATA_INDEX + 3]);
500 this->motion_trigger_number_->publish_state(motion_trigger_time);
505 if (this->motion_to_rest_number_ !=
nullptr) {
507 data[FRAME_DATA_INDEX + 2], data[FRAME_DATA_INDEX + 3]);
508 this->motion_to_rest_number_->publish_state(move_to_rest_time);
513 if (this->custom_unman_time_number_ !=
nullptr) {
515 data[FRAME_DATA_INDEX + 2], data[FRAME_DATA_INDEX + 3]);
516 this->custom_unman_time_number_->publish_state(enter_unmanned_time / 1000.0f);
523 if (this->existence_boundary_select_ !=
nullptr) {
524 if (this->existence_boundary_select_->has_index(data[FRAME_DATA_INDEX] - 1)) {
525 this->existence_boundary_select_->publish_state(data[FRAME_DATA_INDEX] - 1);
531 if (this->motion_boundary_select_ !=
nullptr) {
532 if (this->motion_boundary_select_->has_index(data[FRAME_DATA_INDEX] - 1)) {
533 this->motion_boundary_select_->publish_state(data[FRAME_DATA_INDEX] - 1);
541void MR24HPC1Component::r24_parse_data_frame_(uint8_t *data, uint8_t
len) {
542 switch (data[FRAME_CONTROL_WORD_INDEX]) {
544 if (data[FRAME_COMMAND_WORD_INDEX] == 0x02) {
545 ESP_LOGD(TAG,
"Reply: query restart packet");
548#ifdef USE_TEXT_SENSOR
549 if (this->heartbeat_state_text_sensor_ !=
nullptr) {
550 this->heartbeat_state_text_sensor_->publish_state(
551 data[FRAME_COMMAND_WORD_INDEX] == 0x01 ?
"Equipment Normal" :
"Equipment Abnormal");
556 this->r24_frame_parse_product_information_(data);
559 this->r24_frame_parse_work_status_(data);
562 this->r24_frame_parse_open_underlying_information_(data);
565 this->r24_frame_parse_human_information_(data);
568 ESP_LOGD(TAG,
"control word:0x%02X not found", data[FRAME_CONTROL_WORD_INDEX]);
573void MR24HPC1Component::r24_frame_parse_work_status_(uint8_t *data) {
574 switch (data[FRAME_COMMAND_WORD_INDEX]) {
577 ESP_LOGD(TAG,
"Reply: get radar init status 0x%02X", data[FRAME_DATA_INDEX]);
581 if (this->custom_mode_num_sensor_ !=
nullptr) {
582 this->custom_mode_num_sensor_->publish_state(data[FRAME_DATA_INDEX]);
586 if (this->custom_mode_number_ !=
nullptr) {
587 this->custom_mode_number_->publish_state(0);
590#ifdef USE_TEXT_SENSOR
591 if (this->custom_mode_end_text_sensor_ !=
nullptr) {
592 this->custom_mode_end_text_sensor_->publish_state(
"Setup in progress");
598 if (this->custom_mode_num_sensor_ !=
nullptr) {
599 this->custom_mode_num_sensor_->publish_state(data[FRAME_DATA_INDEX]);
602 if (data[FRAME_DATA_INDEX] == 0) {
603#ifdef USE_TEXT_SENSOR
604 if (this->custom_mode_end_text_sensor_ !=
nullptr) {
605 this->custom_mode_end_text_sensor_->publish_state(
"Not in custom mode");
609 if (this->custom_mode_number_ !=
nullptr) {
610 this->custom_mode_number_->publish_state(0);
618 if ((this->scene_mode_select_ !=
nullptr) && (this->scene_mode_select_->has_index(data[FRAME_DATA_INDEX]))) {
619 this->scene_mode_select_->publish_state(data[FRAME_DATA_INDEX]);
621 ESP_LOGD(TAG,
"Select has index offset %d Error", data[FRAME_DATA_INDEX]);
628 if (this->sensitivity_number_ !=
nullptr) {
629 this->sensitivity_number_->publish_state(data[FRAME_DATA_INDEX]);
633#ifdef USE_TEXT_SENSOR
635 if (this->custom_mode_end_text_sensor_ !=
nullptr) {
636 this->custom_mode_end_text_sensor_->publish_state(
"Set Success!");
641 ESP_LOGD(TAG,
"[%s] No found COMMAND_WORD(%02X) in Frame", __FUNCTION__, data[FRAME_COMMAND_WORD_INDEX]);
646void MR24HPC1Component::r24_frame_parse_human_information_(uint8_t *data) {
647 switch (data[FRAME_COMMAND_WORD_INDEX]) {
648#ifdef USE_BINARY_SENSOR
651 if (this->has_target_binary_sensor_ !=
nullptr && data[FRAME_DATA_INDEX] < std::size(S_SOMEONE_EXISTS_STR)) {
652 this->has_target_binary_sensor_->publish_state(S_SOMEONE_EXISTS_STR[data[FRAME_DATA_INDEX]]);
659 if (this->movement_signs_sensor_ !=
nullptr) {
660 this->movement_signs_sensor_->publish_state(data[FRAME_DATA_INDEX]);
664#ifdef USE_TEXT_SENSOR
667 if ((this->motion_status_text_sensor_ !=
nullptr) && (data[FRAME_DATA_INDEX] < 3)) {
668 this->motion_status_text_sensor_->publish_state(S_MOTION_STATUS_STR[data[FRAME_DATA_INDEX]]);
674 if ((this->keep_away_text_sensor_ !=
nullptr) && (data[FRAME_DATA_INDEX] < 3)) {
675 this->keep_away_text_sensor_->publish_state(S_KEEP_AWAY_STR[data[FRAME_DATA_INDEX]]);
683 if ((this->unman_time_select_ !=
nullptr) && (data[FRAME_DATA_INDEX] < 9)) {
684 this->unman_time_select_->publish_state(data[FRAME_DATA_INDEX]);
689 ESP_LOGD(TAG,
"[%s] No found COMMAND_WORD(%02X) in Frame", __FUNCTION__, data[FRAME_COMMAND_WORD_INDEX]);
695void MR24HPC1Component::send_query_(
const uint8_t *query,
size_t string_length) {
696 if (!this->module_ready_)
706 this->send_query_(GET_RADAR_OUTPUT_INFORMATION_SWITCH,
sizeof(GET_RADAR_OUTPUT_INFORMATION_SWITCH));
720 this->send_query_(GET_FIRMWARE_VERSION,
sizeof(GET_FIRMWARE_VERSION));
726 this->send_query_(GET_HUMAN_MOTION_INFORMATION,
sizeof(GET_HUMAN_MOTION_INFORMATION));
730 this->send_query_(GET_BODY_MOTION_PARAMETERS,
sizeof(GET_BODY_MOTION_PARAMETERS));
744 this->send_query_(GET_EXISTENCE_BOUNDARY,
sizeof(GET_EXISTENCE_BOUNDARY));
750 this->send_query_(GET_SPATIAL_STATIC_VALUE,
sizeof(GET_SPATIAL_STATIC_VALUE));
754 this->send_query_(GET_SPATIAL_MOTION_VALUE,
sizeof(GET_SPATIAL_MOTION_VALUE));
758 this->send_query_(GET_DISTANCE_OF_STATIC_OBJECT,
sizeof(GET_DISTANCE_OF_STATIC_OBJECT));
762 this->send_query_(GET_DISTANCE_OF_MOVING_OBJECT,
sizeof(GET_DISTANCE_OF_MOVING_OBJECT));
766 this->send_query_(GET_TARGET_MOVEMENT_SPEED,
sizeof(GET_TARGET_MOVEMENT_SPEED));
770 this->send_query_(GET_EXISTENCE_THRESHOLD,
sizeof(GET_EXISTENCE_THRESHOLD));
774 this->send_query_(GET_MOTION_THRESHOLD,
sizeof(GET_MOTION_THRESHOLD));
778 this->send_query_(GET_MOTION_TRIGGER_TIME,
sizeof(GET_MOTION_TRIGGER_TIME));
782 this->send_query_(GET_MOTION_TO_REST_TIME,
sizeof(GET_MOTION_TO_REST_TIME));
786 this->send_query_(GET_CUSTOM_UNMAN_TIME,
sizeof(GET_CUSTOM_UNMAN_TIME));
793 this->send_query_(UNDERLYING_SWITCH_ON,
sizeof(UNDERLYING_SWITCH_ON));
795 this->send_query_(UNDERLYING_SWITCH_OFF,
sizeof(UNDERLYING_SWITCH_OFF));
797#ifdef USE_TEXT_SENSOR
798 if (this->keep_away_text_sensor_ !=
nullptr) {
799 this->keep_away_text_sensor_->publish_state(
"");
801 if (this->motion_status_text_sensor_ !=
nullptr) {
802 this->motion_status_text_sensor_->publish_state(
"");
806 if (this->custom_spatial_static_value_sensor_ !=
nullptr) {
807 this->custom_spatial_static_value_sensor_->publish_state(NAN);
809 if (this->custom_spatial_motion_value_sensor_ !=
nullptr) {
810 this->custom_spatial_motion_value_sensor_->publish_state(NAN);
812 if (this->custom_motion_distance_sensor_ !=
nullptr) {
813 this->custom_motion_distance_sensor_->publish_state(NAN);
815 if (this->custom_presence_of_detection_sensor_ !=
nullptr) {
816 this->custom_presence_of_detection_sensor_->publish_state(NAN);
818 if (this->custom_motion_speed_sensor_ !=
nullptr) {
819 this->custom_motion_speed_sensor_->publish_state(NAN);
825 uint8_t send_data_len = 10;
826 uint8_t send_data[10] = {0x53, 0x59, 0x05, 0x07, 0x00, 0x01, value, 0x00, 0x54, 0x43};
827 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
828 this->send_query_(send_data, send_data_len);
830 if (this->custom_mode_number_ !=
nullptr) {
831 this->custom_mode_number_->publish_state(0);
835 if (this->custom_mode_num_sensor_ !=
nullptr) {
836 this->custom_mode_num_sensor_->publish_state(0);
854 uint8_t send_data_len = 10;
855 uint8_t send_data[10] = {0x53, 0x59, 0x05, 0x08, 0x00, 0x01, value, 0x00, 0x54, 0x43};
856 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
857 this->send_query_(send_data, send_data_len);
863 this->send_query_(SET_RESTART,
sizeof(SET_RESTART));
864 this->check_dev_inf_sign_ =
true;
868 uint8_t send_data_len = 10;
869 uint8_t send_data[10] = {0x53, 0x59, 0x80, 0x0a, 0x00, 0x01, value, 0x00, 0x54, 0x43};
870 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
871 this->send_query_(send_data, send_data_len);
879 if (this->custom_mode_number_ !=
nullptr) {
880 this->custom_mode_number_->publish_state(0);
885 uint8_t send_data_len = 10;
886 uint8_t send_data[10] = {0x53, 0x59, 0x05, 0x09, 0x00, 0x01,
mode, 0x00, 0x54, 0x43};
887 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
888 this->send_query_(send_data, send_data_len);
902 uint8_t send_data_len = 10;
903 uint8_t send_data[10] = {0x53, 0x59, 0x05, 0x0a, 0x00, 0x01, 0x0F, 0xCB, 0x54, 0x43};
904 this->send_query_(send_data, send_data_len);
906 if (this->custom_mode_number_ !=
nullptr) {
907 this->custom_mode_number_->publish_state(0);
924 if ((this->custom_mode_num_sensor_ !=
nullptr) && (this->custom_mode_num_sensor_->state == 0))
927 uint8_t send_data_len = 10;
928 uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x0A, 0x00, 0x01, (uint8_t) (value + 1), 0x00, 0x54, 0x43};
929 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
930 this->send_query_(send_data, send_data_len);
936 if ((this->custom_mode_num_sensor_ !=
nullptr) && (this->custom_mode_num_sensor_->state == 0))
939 uint8_t send_data_len = 10;
940 uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x0B, 0x00, 0x01, (uint8_t) (value + 1), 0x00, 0x54, 0x43};
941 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
942 this->send_query_(send_data, send_data_len);
948 if ((this->custom_mode_num_sensor_ !=
nullptr) && (this->custom_mode_num_sensor_->state == 0))
951 uint8_t send_data_len = 10;
952 uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x08, 0x00, 0x01, value, 0x00, 0x54, 0x43};
953 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
954 this->send_query_(send_data, send_data_len);
960 if ((this->custom_mode_num_sensor_ !=
nullptr) && (this->custom_mode_num_sensor_->state == 0))
963 uint8_t send_data_len = 10;
964 uint8_t send_data[10] = {0x53, 0x59, 0x08, 0x09, 0x00, 0x01, value, 0x00, 0x54, 0x43};
965 send_data[7] = get_frame_crc_sum(send_data, send_data_len);
966 this->send_query_(send_data, send_data_len);
972 if ((this->custom_mode_num_sensor_ !=
nullptr) && (this->custom_mode_num_sensor_->state == 0))
975 uint8_t send_data_len = 13;
976 uint8_t send_data[13] = {0x53, 0x59, 0x08, 0x0C, 0x00, 0x04, 0x00, 0x00, 0x00, value, 0x00, 0x54, 0x43};
977 send_data[10] = get_frame_crc_sum(send_data, send_data_len);
978 this->send_query_(send_data, send_data_len);
984 if ((this->custom_mode_num_sensor_ !=
nullptr) && (this->custom_mode_num_sensor_->state == 0))
987 uint8_t h8_num = (value >> 8) & 0xff;
988 uint8_t l8_num = value & 0xff;
989 uint8_t send_data_len = 13;
990 uint8_t send_data[13] = {0x53, 0x59, 0x08, 0x0D, 0x00, 0x04, 0x00, 0x00, h8_num, l8_num, 0x00, 0x54, 0x43};
991 send_data[10] = get_frame_crc_sum(send_data, send_data_len);
992 this->send_query_(send_data, send_data_len);
998 if ((this->custom_mode_num_sensor_ !=
nullptr) && (this->custom_mode_num_sensor_->state == 0))
1002 uint8_t h24_num = (value_ms >> 24) & 0xff;
1003 uint8_t h16_num = (value_ms >> 16) & 0xff;
1004 uint8_t h8_num = (value_ms >> 8) & 0xff;
1005 uint8_t l8_num = value_ms & 0xff;
1006 uint8_t send_data_len = 13;
1007 uint8_t send_data[13] = {0x53, 0x59, 0x08, 0x0E, 0x00, 0x04, h24_num, h16_num, h8_num, l8_num, 0x00, 0x54, 0x43};
1008 send_data[10] = get_frame_crc_sum(send_data, send_data_len);
1009 this->send_query_(send_data, send_data_len);
BedjetMode mode
BedJet operating mode.
void set_timeout(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a const char* name.
void set_interval(const char *name, uint32_t interval, std::function< void()> &&f)
Set an interval function with a const char* 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()
optional< std::array< uint8_t, N > > read_array()
void write_array(const uint8_t *data, size_t len)
std::span< const uint8_t > data
@ 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
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.