Device Tracker implementation to import historical data with timestamp

I have built a custom GPS tracker with an ESP32, and I am using the gpslogger integration to post the data to the Home Assistant. However, the ESP32 doesn’t always have a network connection, so I have programmed it in a way where it will collect location data via GPS and store it in a cache, and then dump it to the webhook once it regains network connectivity. However, this causes the time to be wrong on each of the data points, as it simply shows the time in which it was uploaded, not the time it was recorded.

I was wondering if there was a way to build a custom integration implementation in which I could insert a timestamp along with the location data. I have done a bit of research and come across this thread - Insert state at specific timestamp - #7 by PeteRage. It suggests you could use async_add_external_statistics to import the data with a timestamp, but it seems that TrackerEntity’s are a bit different that regular sensors, so I have been having trouble figuring out an implementation.

If anyone has any insight that would be fantastic!

1 Like