Skip to content

Commit

Permalink
Do not save last_seen if older than prev_seen (#30647)
Browse files Browse the repository at this point in the history
Also add warnings when updates skipped similar to google_maps
  • Loading branch information
pnbruckner authored and balloob committed Jan 10, 2020
1 parent c785b79 commit 626c01b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions homeassistant/components/life360/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ def _prev_seen(self, dev_id, last_seen):
)
reported = False

self._dev_data[dev_id] = last_seen or prev_seen, reported
# Don't remember last_seen unless it's really an update.
if not last_seen or prev_seen and last_seen <= prev_seen:
last_seen = prev_seen
self._dev_data[dev_id] = last_seen, reported

return prev_seen

Expand All @@ -218,7 +221,17 @@ def _update_member(self, member, dev_id):
return

# Only update when we truly have an update.
if not last_seen or prev_seen and last_seen <= prev_seen:
if not last_seen:
_LOGGER.warning("%s: Ignoring update because timestamp is missing", dev_id)
return
if prev_seen and last_seen < prev_seen:
_LOGGER.warning(
"%s: Ignoring update because timestamp is older than last timestamp",
dev_id,
)
_LOGGER.debug("%s < %s", last_seen, prev_seen)
return
if last_seen == prev_seen:
return

lat = loc.get("latitude")
Expand Down

0 comments on commit 626c01b

Please sign in to comment.