From 2147e9c7aa8ee43cf6018e7995583f9a088a682f Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Tue, 18 Feb 2025 11:04:43 +0100 Subject: [PATCH] fix: update timer date handling in DynamicLampComponent for improved accuracy --- esphome/components/dynamic_lamp/dynamic_lamp.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/esphome/components/dynamic_lamp/dynamic_lamp.cpp b/esphome/components/dynamic_lamp/dynamic_lamp.cpp index 7ce6f28e17..f6cef914d9 100644 --- a/esphome/components/dynamic_lamp/dynamic_lamp.cpp +++ b/esphome/components/dynamic_lamp/dynamic_lamp.cpp @@ -245,14 +245,13 @@ bool DynamicLampComponent::add_timer(std::string lamp_name, bool timer_active, u new_timer.saturday = saturday; new_timer.sunday = sunday; ESPTime now = this->rtc_->now(); - time_t begin_date = now.to_time_t(); - time_t end_date = now.increment_days(1).to_time_t(); + time_t begin_date = now.to_c_tm(); + time_t end_date = now.increment_day(1).to_c_tm(); new_timer.begin_date = begin_date; new_timer.end_date = end_date; - ESP_LOGV(TAG, "Added new timer for lamp %s, active %d, mode %d, hour %d, minute %d, monday %d, tuesday %d, wednesday %d, thursday %d, friday %d, saturday %d, sunday %d, begin_date %s, end_date %s", + ESP_LOGV(TAG, "Added new timer for lamp %s, active %d, mode %d, hour %d, minute %d, monday %d, tuesday %d, wednesday %d, thursday %d, friday %d, saturday %d, sunday %d", new_timer.lamp_name, new_timer.active, new_timer.mode, new_timer.hour, new_timer.minute, new_timer.monday, new_timer.tuesday, new_timer.wednesday, - new_timer.thursday, new_timer.friday, new_timer.saturday, new_timer.sunday, - new_timer.begin_date.to_string().c_str(), new_timer.end_date.to_string().c_str()); + new_timer.thursday, new_timer.friday, new_timer.saturday, new_timer.sunday); ESP_LOGV(TAG, "Size of struct is %" PRIu8 "", static_cast(sizeof(new_timer))); return true; }