How to compute distances from GPS history

Hello! I have a GPS sensor from Home Assistant companion app. I’m looking for a way to compute the number of km that have been traveled each day. I have seen the proximity tool but I don’t understand how it can be used in my situation.

Is it possible to turn the GPS position to a cumulative number of km and then use the utility meter to get a number of km per day?

Thanks!

Hi

A while ago I made a comment on Reddit with a rough algorithm that would do this, but I haven’t tried it myself. I found that location updates were difficult to control on iDevices, which would result in extremely inaccurate results.

On Android though, you can easily force fine location updates (with a cost on battery life), and I think results should be adequate.

That would be very inaccurate when you are stationary.
It’s not uncommon to get wild readings when indoors

1 Like

Thanks for your answers!

@cxnull I will go through your algorithm and see how I can implement it.

@Hellis81 I agree, but this seems manageable (e.g. by ignoring distances when I am in a zone, or by using a more complex algorithm to detect when I’m “not really moving”). The result will be approximate anyway.

Is it android or apple?
In android you could as stated earlier enable high accuracy mode and perhaps a second boolean to “enable distance tracking” and have those two as your condition in the automation, that way you can toggle the counter on and off as you like.

You could actually make a service call to enable high accuracy when the distance tracking boolean is enabled.