Unknown location when using MQTT device tracker with OwnTracks

I’m having issues when using MQTT as a device tracker with OwnTracks.
First, here’s the MQTT part of my configuration.yaml:

mqtt:
  - device_tracker:
      name: "phone1"
      state_topic: "owntracks/user1/phone1"
      unique_id: device_tracker-phone1
      source_type: gps
  - device_tracker:
      name: "phone2"
      state_topic: "owntracks/user2/phone2"
      unique_id: device_tracker-phone2
      source_type: gps

Using MQTT5 Explorer, I found that locations are being published correctly to MQTT:

{"_type":"location","BSSID":"ab:cd:ef:gh:ij:kl","SSID":"my_WIFI","_id":"12345678","acc":8,"alt":150,"batt":43,"bs":1,"cog":0,"conn":"w","created_at":1742144273,"inregions":["Home"],"lat":50.123123123123,"lon":10.123123123123,"m":1,"t":"p","tid":"ab","tst":1742141555,"vac":92,"vel":0}

Now, the device tracker is being recognized by HA, however the location is always being shown as “Unknown”.

Do I need to setup something else to have HA be able to get the device locations?

Thanks a lot in advance

The reason why those device trackers do not work is because the attributes that owntracks publishes have different names than the attributes the device tracker needs.

The easy path is to use the owntracks integration. There are instructions in the docs in how to set it up to read from MQTT.

Alternatively you could write an automation to trigger off the MQTT topic and then call device.see with the correct attribute data.

Is there some kind of documentation on creating that kind of automation? I need my Home Assistant to be accessible only via VPN whereas OwnTracks should be able to get device location updates also from outside.

Look at the device_tracker documentation.

Why don’t you just use the owntracks integration and connect it to your existing MQTT topic?

The simplest way to get it to work, is to get a Nabu casa subscription, setup the owntracks integration, expose the webhook via Nabu casa and then point owntracks to that REST webhook. The documentation for all of this is very clear and easy to follow.