mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 23:48:11 +01:00
Fix notificagtions
This commit is contained in:
parent
4f0b0ed952
commit
347b35a2c7
2 changed files with 11 additions and 9 deletions
|
@ -88,6 +88,7 @@ void SNTPComponent::update() {
|
||||||
// force resync
|
// force resync
|
||||||
if (sntp_enabled()) {
|
if (sntp_enabled()) {
|
||||||
#if defined(USE_ESP_IDF)
|
#if defined(USE_ESP_IDF)
|
||||||
|
ESP_LOGD(TAG, "Forsing resync");
|
||||||
sntp_restart();
|
sntp_restart();
|
||||||
#else
|
#else
|
||||||
sntp_stop();
|
sntp_stop();
|
||||||
|
@ -99,13 +100,12 @@ void SNTPComponent::update() {
|
||||||
}
|
}
|
||||||
void SNTPComponent::loop() {
|
void SNTPComponent::loop() {
|
||||||
#ifdef USE_ESP_IDF
|
#ifdef USE_ESP_IDF
|
||||||
if (sync_time_to_report_ != 0) {
|
if (sync_time_to_report_ == 0)
|
||||||
|
return
|
||||||
|
|
||||||
this->cancel_timeout(FORCE_UPDATE_SCHEDULE);
|
this->cancel_timeout(FORCE_UPDATE_SCHEDULE);
|
||||||
const ESPTime time = ESPTime::from_epoch_local(sync_time_to_report_);
|
const ESPTime time = ESPTime::from_epoch_local(sync_time_to_report_);
|
||||||
ESP_LOGD(TAG, "Synchronized time: %04d-%02d-%02d %02d:%02d:%02d", time.year, time.month, time.day_of_month,
|
|
||||||
time.hour, time.minute, time.second);
|
|
||||||
sync_time_to_report_ = 0;
|
sync_time_to_report_ = 0;
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
if (this->has_time_)
|
if (this->has_time_)
|
||||||
return;
|
return;
|
||||||
|
@ -114,11 +114,11 @@ void SNTPComponent::loop() {
|
||||||
if (!time.is_valid())
|
if (!time.is_valid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
this->has_time_ = true;
|
||||||
|
#endif
|
||||||
ESP_LOGD(TAG, "Synchronized time: %04d-%02d-%02d %02d:%02d:%02d", time.year, time.month, time.day_of_month, time.hour,
|
ESP_LOGD(TAG, "Synchronized time: %04d-%02d-%02d %02d:%02d:%02d", time.year, time.month, time.day_of_month, time.hour,
|
||||||
time.minute, time.second);
|
time.minute, time.second);
|
||||||
#endif
|
|
||||||
this->time_sync_callback_.call();
|
this->time_sync_callback_.call();
|
||||||
this->has_time_ = true;
|
|
||||||
}
|
}
|
||||||
#ifdef USE_ESP_IDF
|
#ifdef USE_ESP_IDF
|
||||||
void SNTPComponent::set_update_interval(uint32_t update_interval) {
|
void SNTPComponent::set_update_interval(uint32_t update_interval) {
|
||||||
|
|
|
@ -35,7 +35,9 @@ class SNTPComponent : public time::RealTimeClock {
|
||||||
std::string servers_[3];
|
std::string servers_[3];
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
#ifdef USE_ESP_IDF
|
||||||
bool has_time_{false};
|
bool has_time_{false};
|
||||||
|
#endif
|
||||||
bool servers_was_setup_{false};
|
bool servers_was_setup_{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue