Has anyone else noticed that the google_mapsdevice_tracker integration sometimes gets updates out of order? I.e., it seems sometimes the last_seen attribute for an update is older than the last_seen attribute from the previous update. I’ve also looked at the latitude and longitude attributes when this happens and it seems sometimes an older update happens a second time (after some other updates with newer last_seen timestamps.)
I have a fix for this that I’m considering submitting as a PR, but I wanted to see if it was happening to anyone else before doing so. I came up with the following as a way to track this happening:
notify:
- name: google
platform: file
filename: google.log
timestamp: true
automation:
- trigger:
platform: event
event_type: state_changed
condition:
condition: template
value_template: >
{{ trigger.event.data.entity_id.startswith('device_tracker.google_maps')
and trigger.event.data.new_state is not none
and trigger.event.data.old_state is not none
and trigger.event.data.new_state.attributes.last_seen is defined
and trigger.event.data.old_state.attributes.last_seen is defined
and trigger.event.data.new_state.attributes.last_seen <
trigger.event.data.old_state.attributes.last_seen }}
action:
service: notify.google
data_template:
message: >
old: {{
trigger.event.data.old_state.attributes.last_seen
}} new: {{
trigger.event.data.new_state.attributes.last_seen
}} {{ trigger.event.data.new_state.name }}
This will write entries to a file named google.log in your config directory whenever this happens.
I’d be interested to hear if anyone else has noticed this, or if you give the logging technique a try and what your results are.
FWIW, sometimes this doesn’t happen for hours, maybe days, but generally it seems to happen several times a day.
Yes I have but I’ve asked a few dumb questions in the past about location and device tracking so I decided to just wait a bit and see what happened.
I’ve been tracking down other small things in my setup recently so have been looking in the logs a lot and I have seen the ‘going backwards’ error many times.
Anyone else out there using google_maps device tracker and notice that updates come out of order?
I suppose it’s not easy to notice, which might explain why it’s behaved this way. So…
Anyone else out there using google_maps device tracker that would be willing to log these “going backwards” events using the automation I provide above, and then let me know your results?
I’d really like to get some more feedback before officially submitting a fix. THANKS!!
I’m really just looking for confirmation that it happens. I have logs showing it happening for my account. I’m assuming you know it happens because of the warning from my composite tracker, yes?
So I have confirmation for two people, which is probably enough (i.e., it’s not “just me”), but I’d like to get confirmation from a few others before submitting a PR.
please let me add to this, cause it is the only thread also seeing the Backwards error. I noticed this today, and don’t know what it means or why this is caused:
device_tracker.life360_name last_seen went backwards
and
11:56 AM custom_components/composite/device_tracker.py (WARNING)
That’s a warning generated by my composite device tracker integration. For each “input” tracker it keeps track of its last_seen attribute. If, when a new update comes in, the new last_seen value is less than the previous last_seen value, it will ignore the new update and print that warning.
This is how I discovered that this seems to happen fairly often with the google_maps tracker and decided to fix it “at the source.”
I can’t say that I’ve ever seen it happen with Life360, though.
EDIT: In fact, it shouldn’t be possible with Life360. It has code to skip updates where the new last_seen is <= the previous last_seen:
Well, as I said, it shouldn’t be possible. But obviously it does seem to have happened. Could you send me all the related lines from your log file (via PM if you like)?
EDIT: Never mind. I think I just figured out how it could happen. I’ll fix it and submit a PR. Thanks for letting me know!
Hmm, you’re right. Now that you mention it, I do recall seeing a discussion among the developers where warnings in the UI log cannot be suppressed. Apparently that will only keep the warnings out of the “more detailed” home-assistant.log file (which seems, to me at least, backwards.) But that’s the way it is.
I guess that’s another argument for making these INFO messages. I made them WARNING messages, though, on purpose. Even though the change (to ignore these updates) had to be reviewed and accepted, and even though it would have been in the release notes, doesn’t mean that everyone (that uses google_maps) would be aware of it. I wanted to make sure people were aware, but more importantly, get feedback in case there was a problem with it.
So, at some point before too long I’ll submit another PR to change them to INFO messages. Those can be suppressed from the UI log (and typically are.)
life360_xxx: Ignoring update because timestamp is older than last timestamp
Have been receiving this error for many months for one person in circle. Guessing there was a bogus timestamp many months ago thats prevents further updates. How do I clear out the bad data?
If somehow the timestamp retrieved from the Life360 server was corrupted and was interpreted as some time in the future, it is possible to see this warning until a new timestamp comes that is after it. However, this invalid timestamp will not be retained across HA restarts. So, restarting HA should resolve the problem (unless it happens again for some reason.)
Honestly, this doesn’t happen much that I’m aware of, and when it does it seems to resolve itself in short order. And from the few times I’ve heard of it or seen it happen directly, the problem was more that an old timestamp was unexpectedly received as opposed to one in the future.
Bottom line, there isn’t a whole lot that can be done about it. The HA integration has to believe the data it is receiving from the Life360 server. If the server sends bad data sometimes,
Does the warning happen constantly for this one person? Are there good updates in between? Do the GPS coordinates in HA tend to keep up with that person’s device?
You could try adding this to your config:
logger:
default: info
logs:
homeassistant.components.life360: debug
Then restart HA. After a while you can check home-assistant.log and look for messages concerning life360. There might be some messages, especially DEBUG messages, that can shed light on how this person’s device is behaving.
Phil, thanks for the response, however this has been going on many months with many restarts, many updates, a couple restorations. I don’t have the knowledge or skills yet to diagnose with any validity but my guess is there is a file stored somewhere that doesn’t get overwritten with normal activities. This person’s life360 account works normally, so I assume it is somewhere in HA. I was thinking someone would tell me to go to directory xxx and eliminate file yyy and the world would be wonderful. Wish life was that simple. Any help appreciated…
oops, I just found the rest of your message, miss it in gmail. Will add debug to config for more info