From 81e8ca130f0644386e5467c8038af883b37f7bc9 Mon Sep 17 00:00:00 2001 From: tyjtyj Date: Thu, 28 Sep 2023 14:08:07 +0800 Subject: [PATCH] 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 --- .../components/google_maps/device_tracker.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/google_maps/device_tracker.py b/homeassistant/components/google_maps/device_tracker.py index 2ee12f0154c..be776df1751 100644 --- a/homeassistant/components/google_maps/device_tracker.py +++ b/homeassistant/components/google_maps/device_tracker.py @@ -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 = {