From 3db334d5b2ca98e2e3c7f8e82064813528c85865 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Wed, 19 Feb 2025 10:37:05 +0100 Subject: [PATCH] fix: change return type of build_lamp_list_from_list_str_ to std::vector and update related handling --- esphome/components/dynamic_lamp/dynamic_lamp.cpp | 8 ++++---- esphome/components/dynamic_lamp/dynamic_lamp.h | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/esphome/components/dynamic_lamp/dynamic_lamp.cpp b/esphome/components/dynamic_lamp/dynamic_lamp.cpp index 6d1945a203..352d3ebfd9 100644 --- a/esphome/components/dynamic_lamp/dynamic_lamp.cpp +++ b/esphome/components/dynamic_lamp/dynamic_lamp.cpp @@ -267,10 +267,10 @@ bool DynamicLampComponent::add_timer(std::string lamp_list_str, bool timer_activ return true; } -LampList DynamicLampComponent::build_lamp_list_from_list_str_(std::string lamp_list_str) { +std::vector DynamicLampComponent::build_lamp_list_from_list_str_(std::string lamp_list_str) { std::string delimiter = ","; std::vector lamp_list_vector = this->split_to_int_vector_(lamp_list_str, delimiter); - LampList lamp_list; + std::vector lamp_list; memset(&lamp_list, 0, sizeof(lamp_list)); if (lamp_list_vector.size() > 16) { ESP_LOGW(TAG, "Too many lamps in list, only 16 supported!"); @@ -294,9 +294,9 @@ void DynamicLampComponent::read_timers_to_log() { if (this->active_lamps_[i].active) { DynamicLampTimer timer; this->fram_->read((2048), reinterpret_cast(&timer), 24); - LampList lamp_list = *reinterpret_cast(&timer.lamp_list); + std::vector lamp_list = *reinterpret_cast *>(&timer.lamp_list); for (uint8_t j = 0; j < 16; j++) { - if (lamp_list[j]) { + if (lamp_list[j] && this->active_lamps_[j].active) { ESP_LOGV(TAG, "Timer found for lamp %s: %d, action: %d, hour: %d, minute: %d, monday: %d, tuesday: %d, wednesday: %d, thursday: %d, friday: %d, saturday: %d, sunday: %d", this->active_lamps_[j].name, timer.active, timer.action, timer.hour, timer.minute, timer.monday, timer.tuesday, timer.wednesday, timer.thursday, timer.friday, timer.saturday, timer.sunday); diff --git a/esphome/components/dynamic_lamp/dynamic_lamp.h b/esphome/components/dynamic_lamp/dynamic_lamp.h index 99021373df..5ff2db9861 100644 --- a/esphome/components/dynamic_lamp/dynamic_lamp.h +++ b/esphome/components/dynamic_lamp/dynamic_lamp.h @@ -68,8 +68,6 @@ struct CombinedLamp { bool used_outputs[16]; }; -std::vector LampList {}; - struct DynamicLampTimer { unsigned char validation[3] = { 'D', 'L', 'T' }; uint8_t lamp_list[2]; @@ -121,7 +119,7 @@ class DynamicLampComponent : public Component { uint8_t get_lamp_index_by_name_(std::string lamp_name); std::array get_lamp_outputs_by_name_(std::string lamp_name); std::vector split_to_int_vector_(const std::string& s, const std::string& delimiter); - LampList build_lamp_list_from_list_str_(std::string lamp_list_str); + std::vector build_lamp_list_from_list_str_(std::string lamp_list_str); CombinedLamp active_lamps_[16]; LinkedOutput available_outputs_[16];