How to visualise GPS latitude/longitude values over time on a map (e.g. Google or OMP)?

Hello!

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! :heart:

PS to the moderators:
If there is a better fitting sub-forum, please let me know. Thank you, too! :+1:

Is there really nobody who would like to share their thoughts about my question?

Thanks a lot for taking your time and providing a few hints that might point me to the right direction. :heart:

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).

Further suggestions are very welcome! :blush:

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.

1 Like

I have this in templates.yaml:

sensor:

    - name: Router GPS latitude
      unique_id: router_latitude
      state: >
          {{ states('sensor.teltonika_gps_latitude') }}

    - name: Router GPS longitude
      unique_id: router_longitude
      state: >
          {{ states('sensor.teltonika_gps_longitude') }}

    - name: Router GPS accuracy
      unique_id: router_gps_accuracy
      state: >
          {{ states('sensor.teltonika_gps_accuracy') }}

But how can I show the first two on the map?

As I told, you need to create ONE template sensor with these 3 attributes: latitude, longitude, gps_accuracy, state=not_home

1 Like

Thank you very much for your patience! :heart: Your hint was very helpful and is the solution for my question! :+1: 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`):

  sensor:
    - name: Router GPS position
      unique_id: router_gps_position
      state: not_home
      attributes:
        latitude: >
          {{ states('sensor.router_gps_latitude') }}
        longitude: >
          {{ states('sensor.router_gps_longitude') }}
        accuracy: >
          {{ states('sensor.router_gps_accuracy') }}

And the lovelace code:

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)

1 Like

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.

1 Like

I am afraid that I understood only half of your detailed post, sorry. :face_with_open_eyes_and_hand_over_mouth: (for my lack of knowledge)

What exactly did you mean by favoring the 1st option? The device_tracker building block integration?

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. :blush:

If you choose to use manually created “device_tracker” - you will not need a template sensor.

Start from the beginning:

  1. You have 3 sensors - latitude, longitude, gps_accuracy. And these are THREE separate sensors. Call them “source sensors”.
  2. You need to show a marker on a map - and probably with a track.
  3. 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.
  4. 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.
  5. 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).
  6. 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.