1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-14 06:38:17 +00:00

feat: add read_timers_to_log method to log active lamp timers

This commit is contained in:
Oliver Kleinecke 2025-02-18 14:08:36 +01:00
parent 478bcd6baf
commit df1cf4eb2f
2 changed files with 16 additions and 0 deletions

View File

@ -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<unsigned char *>(lamp_name_buffer), 32);
ESP_LOGV(TAG, "Lamp name: %s", lamp_name_buffer);
DynamicLampTimer timer;
this->parent_->fram_->read((2048 + 32), reinterpret_cast<unsigned char *>(&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;

View File

@ -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;