I would like some help to get accurate distance between 2 device trackers. I would like to use this in an automation to automatically lock my car and send a notification when i move more than 10 meters away from it. I found a ninja template as follows:
As suggested above, distance is in km, not m. But also it is not likely you will reach the accuracy you want. Both the car position and yours are not always perfect. Also, updates are not immediate, so unless you are both stationary you would need to account for difference of either position in time too. You can find more about GPS accuracy, and reasons why it is not always maximum accuracy here: GPS.gov: GPS Accuracy.
I noticed “distance” is always off from the one that google maps provides, e.g. over a length of 6km about 20-40m, I have little to compare as to which one comes closer to the truth
The sensor that Moss provided above works and gives the correct value.
Edwin’s comment is also true. Leaving from the car doesn’t automatically lock it. When you are stationary the home assistant app updates the location and that’s when the automation triggers. You can be many kilometers away until it finally updates the location.
For now, I just set a notification to be received if the car is unlocked for testing purposes.