From df1cf4eb2fdfb30671b3a54e8c3b5171bd464bab Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Tue, 18 Feb 2025 14:08:36 +0100 Subject: [PATCH] feat: add read_timers_to_log method to log active lamp timers --- esphome/components/dynamic_lamp/dynamic_lamp.cpp | 15 +++++++++++++++ esphome/components/dynamic_lamp/dynamic_lamp.h | 1 + 2 files changed, 16 insertions(+) diff --git a/esphome/components/dynamic_lamp/dynamic_lamp.cpp b/esphome/components/dynamic_lamp/dynamic_lamp.cpp index ec7483b835..abc4fa114a 100644 --- a/esphome/components/dynamic_lamp/dynamic_lamp.cpp +++ b/esphome/components/dynamic_lamp/dynamic_lamp.cpp @@ -261,6 +261,21 @@ bool DynamicLampComponent::add_timer(std::string lamp_name, bool timer_active, u return true; } +void DynamicLamp::read_timers_to_log() { + uint8_t i = 0; + for (i = 0; i < 16; i++) { + if (this->parent_->active_lamps_[i].active) { + char lamp_name_buffer[32]; + this->parent_->fram_->read(2048, reinterpret_cast(lamp_name_buffer), 32); + ESP_LOGV(TAG, "Lamp name: %s", lamp_name_buffer); + DynamicLampTimer timer; + this->parent_->fram_->read((2048 + 32), reinterpret_cast(&timer), 24); + ESP_LOGV(TAG, "Timer active: %d, mode: %d, hour: %d, minute: %d, monday: %d, tuesday: %d, wednesday: %d, thursday: %d, friday: %d, saturday: %d, sunday: %d", + timer.active, timer.mode, timer.hour, timer.minute, timer.monday, timer.tuesday, timer.wednesday, timer.thursday, timer.friday, timer.saturday, timer.sunday); + } + } +} + bool DynamicLampComponent::write_state_(uint8_t lamp_number, float state) { if (this->active_lamps_[lamp_number].active) { this->active_lamps_[lamp_number].state_ = state; diff --git a/esphome/components/dynamic_lamp/dynamic_lamp.h b/esphome/components/dynamic_lamp/dynamic_lamp.h index 844446a542..ceb227ae12 100644 --- a/esphome/components/dynamic_lamp/dynamic_lamp.h +++ b/esphome/components/dynamic_lamp/dynamic_lamp.h @@ -106,6 +106,7 @@ class DynamicLampComponent : public Component { bool add_timer(std::string lamp_name, bool timer_active, uint8_t mode, uint8_t hour, uint8_t minute, bool monday, bool tuesday, bool wednesday, bool thursday, bool friday, bool saturday, bool sunday); + void read_timers_to_log(); protected: friend class DynamicLamp;