Merge branch 'tech-upgrade' of https://github.com/emsesp/EMS-ESP32 into tech-upgrade

This commit is contained in:
MichaelDvP
2023-02-27 15:22:26 +01:00

View File

@@ -152,9 +152,10 @@ void WebSchedulerService::loop() {
}
last_tm_min = 0; // startup done, now use for RTC
}
// check timer every minute, sync to EMS-ESP clock
uint32_t uptime_min = uuid::get_uptime_sec() / 60;
if (last_uptime_min != uptime_min || last_uptime_min == -1) {
if (last_uptime_min != uptime_min) {
for (ScheduleItem & scheduleItem : *scheduleItems) {
// retry startup commands not yet executed
if (scheduleItem.active && scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_TIMER && scheduleItem.elapsed_min == 0
@@ -169,11 +170,12 @@ void WebSchedulerService::loop() {
}
last_uptime_min = uptime_min;
}
// check calender, sync to RTC, only execute if year is valid
time_t now = time(nullptr);
tm * tm = localtime(&now);
if (tm->tm_min != last_tm_min && tm->tm_year > 120) {
// find the real dow and minute from NTP or RTC
// find the real dow and minute from RTC
uint8_t real_dow = 1 << tm->tm_wday; // 1 is Sunday
uint16_t real_min = tm->tm_hour * 60 + tm->tm_min;