From cd8201ac6baed3402e12987d03f4a0747313cd8f Mon Sep 17 00:00:00 2001 From: Hareesh M U Date: Sat, 4 Nov 2023 16:18:45 +0000 Subject: [PATCH] Remove Service- Fix Tests --- esphome/components/ld2450/ld2450.cpp | 47 ---------------------------- esphome/components/ld2450/ld2450.h | 5 +-- 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/esphome/components/ld2450/ld2450.cpp b/esphome/components/ld2450/ld2450.cpp index 572f1b99ea..4bd7d280ec 100644 --- a/esphome/components/ld2450/ld2450.cpp +++ b/esphome/components/ld2450/ld2450.cpp @@ -26,25 +26,6 @@ void LD2450Component::setup() { ESP_LOGCONFIG(TAG, "Mac Address : %s", const_cast(this->mac_.c_str())); ESP_LOGCONFIG(TAG, "Firmware Version : %s", const_cast(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] = {}; diff --git a/esphome/components/ld2450/ld2450.h b/esphome/components/ld2450/ld2450.h index baa5ec9997..15d02f0865 100644 --- a/esphome/components/ld2450/ld2450.h +++ b/esphome/components/ld2450/ld2450.h @@ -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)