From ced4eea497b1746363ee8e84755f458afeb5819b Mon Sep 17 00:00:00 2001 From: Anton Sergunov Date: Thu, 9 May 2024 16:59:05 +0000 Subject: [PATCH] Special handlr for esp_idf --- esphome/components/sntp/sntp_component.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/esphome/components/sntp/sntp_component.cpp b/esphome/components/sntp/sntp_component.cpp index d0c4e61a38..a82f5c95d8 100644 --- a/esphome/components/sntp/sntp_component.cpp +++ b/esphome/components/sntp/sntp_component.cpp @@ -81,10 +81,12 @@ void SNTPComponent::update() { } #endif #if defined(USE_ESP_IDF) + this->has_time_ = false; sntp_restart(); #endif } void SNTPComponent::loop() { +#if defined(USE_ESP_IDF) for (const auto &item : callback_args_) { switch (item.second) { case SNTP_SYNC_STATUS_RESET: @@ -92,6 +94,7 @@ void SNTPComponent::loop() { break; case SNTP_SYNC_STATUS_COMPLETED: ESP_LOGD(TAG, "Time sync completed"); + this->has_time_ = true; this->time_sync_callback_.call(); break; case SNTP_SYNC_STATUS_IN_PROGRESS: @@ -104,7 +107,7 @@ void SNTPComponent::loop() { } } callback_args_.clear(); - +#else if (this->has_time_) return; @@ -116,6 +119,7 @@ void SNTPComponent::loop() { time.minute, time.second); this->time_sync_callback_.call(); this->has_time_ = true; +#endif } } // namespace sntp