Fix time.on_time triggering if time jumped back (#1806)

Co-authored-by: Otto winter <otto@otto-winter.com>
This commit is contained in:
brambo123 2021-08-03 19:56:23 +02:00 committed by Otto winter
parent b0d12aeea1
commit dd637582a4
No known key found for this signature in database
GPG Key ID: 48ED2DDB96D7682C
1 changed files with 4 additions and 1 deletions

View File

@ -22,7 +22,10 @@ void CronTrigger::loop() {
return;
if (this->last_check_.has_value()) {
if (*this->last_check_ >= time) {
if (*this->last_check_ > time && this->last_check_->timestamp - time.timestamp > 900) {
// We went back in time (a lot), probably caused by time synchronization
ESP_LOGW(TAG, "Time has jumped back!");
} else if (*this->last_check_ >= time) {
// already handled this one
return;
}