1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-16 18:22:22 +01:00

fix: update timer date handling in DynamicLampComponent for improved accuracy

This commit is contained in:
Oliver Kleinecke
2025-02-18 11:04:43 +01:00
parent b996293ccf
commit 2147e9c7aa

View File

@@ -245,14 +245,13 @@ bool DynamicLampComponent::add_timer(std::string lamp_name, bool timer_active, u
new_timer.saturday = saturday; new_timer.saturday = saturday;
new_timer.sunday = sunday; new_timer.sunday = sunday;
ESPTime now = this->rtc_->now(); ESPTime now = this->rtc_->now();
time_t begin_date = now.to_time_t(); time_t begin_date = now.to_c_tm();
time_t end_date = now.increment_days(1).to_time_t(); time_t end_date = now.increment_day(1).to_c_tm();
new_timer.begin_date = begin_date; new_timer.begin_date = begin_date;
new_timer.end_date = end_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.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.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());
ESP_LOGV(TAG, "Size of struct is %" PRIu8 "", static_cast<uint8_t>(sizeof(new_timer))); ESP_LOGV(TAG, "Size of struct is %" PRIu8 "", static_cast<uint8_t>(sizeof(new_timer)));
return true; return true;
} }