-
-
Notifications
You must be signed in to change notification settings - Fork 34.8k
Description
The problem
Today I noticed some location updates that weren't really possible to have happen (if the device GPS was indeed accurate):
- 10:54:57 at the store (accuracy: 83)
- 10:54:57 0.8 miles down the road (accuracy: 1110, entering zone A)
- 10:55:27 1.0 miles down the road (accuracy: 6, exiting zone A)
- 10:56:37 back at the store, 175 ft from original store location (accuracy: 47)
- 10:56:37 back at the store, 50 ft from previous location (accuracy: 47)
This is a 35 mph road, and there's no way that I was traveling 120 mph part way down the road just to turn around and head back to the store a minute later at 50mph. 😉
Probable Cause
I think the mobile app tried to send a few updates to the server, and for whatever reason the HTTP requests ended up taking some time to complete or needing to be retried. (This seems like it should be expected to happen decently often with the mobile app since mobile networks aren't incredibly reliable.) In the meantime, several other updates were processed and made their way to the server. The requests just ended up making their way to the server out of order making it appear as if I moved back and forth.
Related Code
The registered webhook simply dispatches a SIGNAL_LOCATION_UPDATE
message that data was received, and the data gets written directly into the entity.
Possible Solution
The data that gets sent to the webhook for iOS and Android should include a device_timestamp
which can be stored along with the data when written. Additionally, the timestamp can be compared to the last value stored. The data should only be updated when:
- The new
device_timestamp
is greater than the exiting stored value - The existing data is missing a
device_timestamp
(hasn't yet received an update from a mobile app version that added the field) - The incoming data is missing a
device_timestamp
(the mobile app was downgraded to a prior version and is no longer sending the field)
What version of Home Assistant Core has the issue?
core-2024.9.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
device_tracker
Link to integration documentation on our website
https://www.home-assistant.io/integrations/device_tracker/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response