I have a Teltonika router in my car that sends GPS coordinates every minute to my HA instance, and I can see all values of longitude and latitude in the history.
However, the history shows just the usual coloured stripes, whereas I would like to have the position mapped on Google Maps or OpenStreetMap, shown as a journey over time, i.e. the map should show all positions from the history for a selected period. How is this possible?
I do not have InfluxDB or Grafana (yet).
Thank you very much for sharing your thoughts!
PS to the moderators:
If there is a better fitting sub-forum, please let me know. Thank you, too!
Btw, the stock map uses hours_to_show - you cannot select a period like “01.08.24 - 20.08.24”. But a custom ha-map-card allows to select a period. Ofc you will need to keep data in DB for a longer time than a default “10 days”.
As for other things - elaborate what do you miss in the stock map card.
The stock map does not provide any sensor with coordinates from my router, despite I have these sensors:
sensor.teltonika_gps_latitude
sensor.teltonika_gps_longitude
And indeed I will need a period from the past that is more than 10 days ago, because I want to see retrospectively my journey during my holidays. Maybe HA is not the right thing to do it, but I really want to extract the available coordinates (even if only available on the daily backups) to once create this map.
So my question is maybe rather about how to extract these values and import them into a map (which does not have to be a map within HA).
Create a template sensor with attributes “latitude”, “longitude” - take values from these sensors.
If available - add “gps_accuracy” attribute similarly.
State for this template sensor set as “not_home” (could be a static value imho).
There is FR to set “purge interval per entity”. But meanwhile you will have to set it to smth like “365” (year) - which will need a lot of HDD space since all entities will be kept.
Thank you very much for your patience! Your hint was very helpful and is the solution for my question! After studying a bit further (incl. your other post over there: Help in gps map display - #9 by Ildar_Gabdullin), I was able to make it work. I first needed to understand how to add multiple entities into one template sensor.
Also for other users’ reference, here is my templates.yaml (included from 'configuration.yaml`):
type: map
entities:
- entity: sensor.router_gps_position
name: R
theme_mode: auto
title: Router
geo_location_sources: []
I will work a bit more on the state: not_home, because I do not want to show it as “not at home” statically. The following reference will hopefully be helpful for me (and other interested users, too):
(section State based binary sensor - device tracker sensor with latitude and longitude attributes)
Device_tracker integration sets a state in accordance to current coords - it finds the closest zone which intersects with “curr. coords PLUS gps_accuracy” (BTW - on a Map card you can see a circled area dependingly on “gps_accuracy”).
I see no need to replicate same functionality in your manually created sensor.
Of course, you may use a MANUALLY created device_tracker & “device_tracker.see” service (called in some automation when your source sensors are changed) - then a state probably will be set automatically. In this case you will not need that template sensor.
Or you may keep using that “template sensor” (just rename “accuracy” to “gps_accuracy”) with a constant “not_home” state.
I would choose the 1st variant. You may even create a “person” entity then associated to this manual device_tracker.
For this you will need some already set device_tracker dependently on coords; so this is not your case.
I read that article and already “dropped out” after the section about “Configuring a device_tracker platform”. How does this config play together with my new template sensor?
I like your idea to create another (“dummy”) person just for this router gps coordinates, but here I fail, too, in understanding how to proceed after the creation of that person.
Maybe my too basic knowledge calls for opening a separate thread. On the other hand, this example with the GPS coordinates might interest others, too.
If your time allows it, and you would like to share some further thoughts regarding my questions here, I am very happy, too.
If you choose to use manually created “device_tracker” - you will not need a template sensor.
Start from the beginning:
You have 3 sensors - latitude, longitude, gps_accuracy. And these are THREE separate sensors. Call them “source sensors”.
You need to show a marker on a map - and probably with a track.
To show a marker on a map - you need to place an entity on a Map card (let’s call it “map entity”). This “map entity” must have at least 2 attributes - latitude, longitude.
Next, if that “map entity” has one more attribute (“gps_accuracy”) - then when showing on a Map a circle will be displayed to show an area where this object may present in fact.
A “state” of this “map entity” is NOT needed for a Map. It may only be needed for other cards (like Entities card) - to show either “Home”, “Away” or a name of a particular zone. Usually “state” should be defined automatically dependingly on coords (lat, long) and gps_accuracy (see my explanation about “intersection with a zone” above).
So, you got 2 ways:
– create a template sensor with 3 attributes (taken from those “source sensors”) - and this template sensor will be your “map entity” (place it on the Map card); but the “state” you cannot define easily, so just set it = “not_home” (if “state” if not needed for you);
– OR create manually (see my linked post above) a “device_tracker” (as “map entity”) and then set it’s coords & gps_accuracy by “device_tracker.see” service in some automation; this automation must be called after every change of “source sensors”. In this case the “state” will be defined automatically.