Best way to detect when device tracker is not moving


I have a device tracker for my car (from bmw connected drive integration) and I would like to detect when the car is parked. My idea was to detect when the device tracker is not changing the position for a certain time but I’m not sure it is feasible or not.

The device tracker has the following attribute:

source_type: gps
latitude: xxxxxxxx
longitude: xxxxxxx
gps_accuracy: 0
car: 320e
vin: xxxxxxxxxx
direction: 224
attribution: Data provided by MyBMW
icon: mdi:car
friendly_name: 320e

I can check when the device tracker was updated but it’s not really the same. If something else that gps location changes it will also be considered as an update.

What would you do to detect that the car is parked ?

So what else do you expect should change the sensor ?
Alternative is to store the lat/lon in a separate sensor and check if changed a certain %, this as the gps is also not stable, even when the device is static…

Try a proximity sensor

I think the problem is that the device tracker received updates even the car is not moving.
For instance the car got parked more than one hour ago but the last change and last update was from 5 minutes ago.
I like the idea to check if the lat/lon change more than a certain %. Any idea how to do that in an automation (would like to use it as a trigger) ?

I quickly checked and I think it is usefull to know the distance or the proximity of something. I don’t think it would be able to detect when it is not moving (when it’s parked), is it ?

I would create a template input helper / sensor that states ‘moving’ if its own value (via attribs) are different from the source (device) and then update it also the attribs.
Something alike : device lat/lon updates > sensor gets triggered via the template, if diff more than x% then update

And this may sound daunting but have a look here
Template - Home Assistant (

Mine currently returns a state attribute dir_of_travel with a value of stationary

It’s not something I’m currently tracking but for a car I would expect it to be reasonably responsive.

EDIT: The last_changed sensor attribute on my sensor indicates no change since my arrival at work (within 1 minute of my actual arrival) so it should be suitable.

Could be … or not … as you may have seen there are plenty of posts with device_tracker issues and myself I have 3 phones that behave oddly irregular, even when in the same location.
But, no question that your proposal to use proximity is a good and simple solution provided the device has good data

@X4V1 you might want to edit some of that information out of your post, just in case (lat, lon, vin)

1 Like

I think it could be useful.
If you set the zone to be home and the unit of measurement to km (or miles) then it should be static when the car is stationary.
That means you could have an automation or triggered sensor to trigger on state of the distance sensor with noting in to and from, but for: 1 minute.

That means as long as you are driving the distance changes and this means the automation does not trigger.
When you park the unit of measurement will be large enough to swallow any GPS jitter and thus making the sensor static for the required time to trigger the automation.