Fix google maps device_tracker same last seen timestamp (#99963)

* Update device_tracker.py 

This fix the google_maps does not show current location when HA started/restarted and also fix unnecessary update when last_seen timestamp is the same. 
Unnecessary update is causing proximity sensor switching from between stationary and certain direction.

* Remove elif

* Fix Black check

* fix black check

* Update device_tracker.py

Better patch

* Update device_tracker.py

* Update device_tracker.py

Fix Black

* Update device_tracker.py

change warning to debug
pull/101386/head
tyjtyj 2023-09-28 14:08:07 +08:00 committed by Franck Nijhof
parent 9ab340047d
commit 81e8ca130f
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
1 changed files with 11 additions and 1 deletions

View File

@ -112,12 +112,22 @@ class GoogleMapsScanner:
last_seen = dt_util.as_utc(person.datetime)
if last_seen < self._prev_seen.get(dev_id, last_seen):
_LOGGER.warning(
_LOGGER.debug(
"Ignoring %s update because timestamp is older than last timestamp",
person.nickname,
)
_LOGGER.debug("%s < %s", last_seen, self._prev_seen[dev_id])
continue
if last_seen == self._prev_seen.get(dev_id, last_seen) and hasattr(
self, "success_init"
):
_LOGGER.debug(
"Ignoring %s update because timestamp "
"is the same as the last timestamp %s",
person.nickname,
last_seen,
)
continue
self._prev_seen[dev_id] = last_seen
attrs = {