Merge pull request #9410 from DigitalAlchemist/zigbee_time_correction

Fixed last_seen calculation with zigbee devices.
This commit is contained in:
Theo Arends 2020-09-27 21:49:27 +02:00 committed by GitHub
commit 4c0ee053b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -645,7 +645,12 @@ void Z_Devices::setLQI(uint16_t shortaddr, uint8_t lqi) {
void Z_Devices::setLastSeenNow(uint16_t shortaddr) {
if (shortaddr == localShortAddr) { return; }
getShortAddr(shortaddr).last_seen= Rtc.utc_time;
// Only update time if after 2020-01-01 0000.
// Fixes issue where zigbee device pings before WiFi/NTP has set utc_time
// to the correct time, and "last seen" calculations are based on the
// pre-corrected last_seen time and the since-corrected utc_time.
if (Rtc.utc_time < 1577836800) { return; }
getShortAddr(shortaddr).last_seen = Rtc.utc_time;
}