From afa42646feec87e4b072bdbbb56ee6f49ec0d815 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 16 Oct 2026 12:19:39 -1000 Subject: [PATCH] [ld6002b] Brace the entity lookup chains --- esphome/components/ld6002b/ld6002b.cpp | 37 ++++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/esphome/components/ld6002b/ld6002b.cpp b/esphome/components/ld6002b/ld6002b.cpp index 29979a594b1..84b08abd78f 100644 --- a/esphome/components/ld6002b/ld6002b.cpp +++ b/esphome/components/ld6002b/ld6002b.cpp @@ -1372,26 +1372,27 @@ void LD6002BComponent::wake_() { void LD6002BComponent::set_number_value(number::Number *entity, float value) { // Found by pointer, so the entities share one generated class instead of storing a type each NumberType type; - if (entity == this->hold_delay_number_) + if (entity == this->hold_delay_number_) { type = NumberType::HOLD_DELAY; - else if (entity == this->z_min_number_) + } else if (entity == this->z_min_number_) { type = NumberType::Z_MIN; - else if (entity == this->z_max_number_) + } else if (entity == this->z_max_number_) { type = NumberType::Z_MAX; - else if (entity == this->low_power_sleep_number_) + } else if (entity == this->low_power_sleep_number_) { type = NumberType::LOW_POWER_SLEEP; - else if (entity == this->area_x_min_number_) + } else if (entity == this->area_x_min_number_) { type = NumberType::AREA_X_MIN; - else if (entity == this->area_x_max_number_) + } else if (entity == this->area_x_max_number_) { type = NumberType::AREA_X_MAX; - else if (entity == this->area_y_min_number_) + } else if (entity == this->area_y_min_number_) { type = NumberType::AREA_Y_MIN; - else if (entity == this->area_y_max_number_) + } else if (entity == this->area_y_max_number_) { type = NumberType::AREA_Y_MAX; - else if (entity == this->area_z_min_number_) + } else if (entity == this->area_z_min_number_) { type = NumberType::AREA_Z_MIN; - else // Only registered entities call this, so the last one needs no compare + } else { // Only registered entities call this, so the last one needs no compare type = NumberType::AREA_Z_MAX; + } switch (type) { case NumberType::HOLD_DELAY: { uint32_t delay = static_cast(value); @@ -1447,14 +1448,15 @@ void LD6002BComponent::set_number_value(number::Number *entity, float value) { void LD6002BComponent::set_select_value(select::Select *entity, size_t index) { // Found by pointer, so the entities share one generated class instead of storing a type each SelectType type; - if (entity == this->sensitivity_select_) + if (entity == this->sensitivity_select_) { type = SelectType::SENSITIVITY; - else if (entity == this->trigger_speed_select_) + } else if (entity == this->trigger_speed_select_) { type = SelectType::TRIGGER_SPEED; - else if (entity == this->installation_select_) + } else if (entity == this->installation_select_) { type = SelectType::INSTALLATION_MODE; - else // Only registered entities call this, so the last one needs no compare + } else { // Only registered entities call this, so the last one needs no compare type = SelectType::AREA_ID; + } switch (type) { case SelectType::SENSITIVITY: if (index == 0) { @@ -1821,12 +1823,13 @@ void LD6002BComponent::clear_target_state_() { void LD6002BComponent::set_switch_state(switch_::Switch *entity, bool state) { // Found by pointer, so the entities share one generated class instead of storing a type each SwitchType type; - if (entity == this->low_power_switch_) + if (entity == this->low_power_switch_) { type = SwitchType::LOW_POWER; - else if (entity == this->point_cloud_switch_) + } else if (entity == this->point_cloud_switch_) { type = SwitchType::POINT_CLOUD; - else // Only registered entities call this, so the last one needs no compare + } else { // Only registered entities call this, so the last one needs no compare type = SwitchType::TARGET_DISPLAY; + } switch (type) { case SwitchType::LOW_POWER: this->low_power_enabled_ = state;