Remove Service- Fix Tests

This commit is contained in:
Hareesh M U 2023-11-04 16:18:45 +00:00
parent 59499d1970
commit cd8201ac6b
2 changed files with 1 additions and 51 deletions

View file

@ -26,25 +26,6 @@ void LD2450Component::setup() {
ESP_LOGCONFIG(TAG, "Mac Address : %s", const_cast<char *>(this->mac_.c_str()));
ESP_LOGCONFIG(TAG, "Firmware Version : %s", const_cast<char *>(this->version_.c_str()));
ESP_LOGCONFIG(TAG, "HLK-LD2450 setup complete");
ESP_LOGCONFIG(TAG, "Registering services");
register_service(&::esphome::ld2450::LD2450Component::on_set_radar_zone_, "set_radar_zone",
{
"zone_type",
"zone1_x1",
"zone1_y1",
"zone1_x2",
"zone1_y2",
"zone2_x1",
"zone2_y1",
"zone2_x2",
"zone2_y2",
"zone3_x1",
"zone3_y1",
"zone3_x2",
"zone3_y2",
});
register_service(&::esphome::ld2450::LD2450Component::on_reset_radar_zone_, "reset_radar_zone");
ESP_LOGCONFIG(TAG, "Services registration complete");
}
void LD2450Component::dump_config() {
@ -128,34 +109,6 @@ void LD2450Component::loop() {
}
}
// Service reset_radar_zone
void LD2450Component::on_reset_radar_zone_() {
this->zone_type_ = 0;
for (auto &i : zone_config_) {
i.x1 = 0;
i.y1 = 0;
i.x2 = 0;
i.y2 = 0;
}
this->send_set_zone_command_();
}
// Service set_radar_zone
void LD2450Component::on_set_radar_zone_(int zone_type, int zone1_x1, int zone1_y1, int zone1_x2, int zone1_y2,
int zone2_x1, int zone2_y1, int zone2_x2, int zone2_y2, int zone3_x1,
int zone3_y1, int zone3_x2, int zone3_y2) {
this->zone_type_ = zone_type;
int zone_parameters[12] = {zone1_x1, zone1_y1, zone1_x2, zone1_y2, zone2_x1, zone2_y1,
zone2_x2, zone2_y2, zone3_x1, zone3_y1, zone3_x2, zone3_y2};
for (int i = 0; i < MAX_ZONES; i++) {
zone_config_[i].x1 = zone_parameters[i * 4];
zone_config_[i].y1 = zone_parameters[i * 4 + 1];
zone_config_[i].x2 = zone_parameters[i * 4 + 2];
zone_config_[i].y2 = zone_parameters[i * 4 + 3];
}
this->send_set_zone_command_();
}
// Set Zone on LD2450 Sensor
void LD2450Component::send_set_zone_command_() {
uint8_t cmd_value[26] = {};

View file

@ -23,9 +23,6 @@
#ifdef USE_SELECT
#include "esphome/components/select/select.h"
#endif
#ifdef USE_API
#include "esphome/components/api/custom_api_device.h"
#endif
#ifdef USE_TEXT_SENSOR
#include "esphome/components/text_sensor/text_sensor.h"
#endif
@ -113,7 +110,7 @@ enum PeriodicDataValue : uint8_t { HEAD = 0XAA, END = 0x55, CHECK = 0x00 };
enum AckDataStructure : uint8_t { COMMAND = 6, COMMAND_STATUS = 7 };
class LD2450Component : public Component, public uart::UARTDevice, public esphome::api::CustomAPIDevice {
class LD2450Component : public Component, public uart::UARTDevice {
#ifdef USE_SENSOR
SUB_SENSOR(target_count)
SUB_SENSOR(still_target_count)