mirror of
https://github.com/esphome/esphome.git
synced 2026-02-08 00:31:58 +00:00
[time] Always call time sync callbacks even when time unchanged (#13456)
This commit is contained in:
committed by
Jonathan Swoboda
parent
fb984cd052
commit
ec791063b3
@@ -40,6 +40,9 @@ void RealTimeClock::synchronize_epoch_(uint32_t epoch) {
|
|||||||
// Unsigned subtraction handles wraparound correctly, then cast to signed
|
// Unsigned subtraction handles wraparound correctly, then cast to signed
|
||||||
int32_t diff = static_cast<int32_t>(epoch - static_cast<uint32_t>(current_time));
|
int32_t diff = static_cast<int32_t>(epoch - static_cast<uint32_t>(current_time));
|
||||||
if (diff >= -1 && diff <= 1) {
|
if (diff >= -1 && diff <= 1) {
|
||||||
|
// Time is already synchronized, but still call callbacks so components
|
||||||
|
// waiting for time sync (e.g., uptime timestamp sensor) can initialize
|
||||||
|
this->time_sync_callback_.call();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user