time sync notification (#1442)

* add on_time_sync trigger

* cleanup lint

* fix review remark (sntp didn't trigger callbacks)
This commit is contained in:
Florian Mösch
2021-01-18 13:34:50 +01:00
committed by Jesse Hills
parent 828f7946ea
commit 6781d08c9b
8 changed files with 34 additions and 6 deletions
+4
View File
@@ -75,5 +75,9 @@ void CronTrigger::add_days_of_week(const std::vector<uint8_t> &days_of_week) {
}
float CronTrigger::get_setup_priority() const { return setup_priority::HARDWARE; }
SyncTrigger::SyncTrigger(RealTimeClock *rtc) : rtc_(rtc) {
rtc->add_on_time_sync_callback([this]() { this->trigger(); });
}
} // namespace time
} // namespace esphome