How do HA, Mqtt broker and OwnTracks work together?

If you were at home you will see nothing on the HA map as it only displays location when you are away from your home location it could be that is your issue?

Any reason not to use the owntracks integration already in homeassistant, instead of trying to roll your own integration?

Thanks for your replying. I noticed there’s already the owntracks component/platform? I set it once in my configuration.yaml like below:

mqtt:
  broker: m11.cloudmqtt.com
  port: 23340
  username: {my-username}
  password: {my-password-for-username}

device_tracker:
  - platform: mqtt
    devices: 
      {my-device-id}: 'owntracks/{my-username}/{my-device-model}'
  - platform : owntracks
    max_gps_accuracy: 200
    mqtt_topic: "owntracks/#"

Here’s some gap I didn’t figure out:

  • What is the owntracks platform for?
  • Does it also depend on the mqtt broker I specified above?
  • Should I remove the mqtt platform for device tracker component if I use owntracks platform?
  • How is my phone supposed to send message to CloudMQTT if I don’t install OwnTracks App on my phone?

Thanks again.

Thanks for your reply, I will see if there’s any change when I am away from my HOME zone.

It’s for an autoconfiguration of tracking devices using Owntracks.

Yes, it needs to be able to communicate with the broker that your device is talking to.

Yes.

You need SOME way to send MQTT messages from your device stating the location, in a way that mimics Owntracks. Zanzito can do this on Android.

1 Like

I see, thanks for your replay, I modified my configuration.yaml like below:

mqtt:
  broker: m11.cloudmqtt.com
  port: 23340
  username: {my-username}
  password: {my-password-for-username}

device_tracker:
  - platform : owntracks
    max_gps_accuracy: 200
    mqtt_topic: "owntracks/#"

I still see nothing at my HA side, did I miss something? Thanks.

Unless you are on an old version of HA, you need to use owntracks properly

I get it work after I change the port from SSL port to non-SSL port. Well security is another topic, thanks.

OK, but you do realize that when you update, owntracks will be broken, right? Because Owntracks requires a new formatting in the config yaml.

For your question

I didn’t get it, now I get it running with SSL enabled. I have my ha configuration.yaml like below:

mqtt:
  broker: m11.cloudmqtt.com
  port: 23340
  client_id: home_assistant
  certificate: auto
  username: {password}
  password: {password}

device_tracker:
  - platform: owntracks

I get the port 23340 from CloudMQTT SSL port. The iOS OwnTracks app configuration something like:

Mode: MQTT
TrackerID: {tracker-id}
DeviceID: {device-model}
Host: m11.cloudmqtt.com
Port: 23340
WebSockets: disabled
Proto: 4
TLS: enabled
UserID: {my-username-for-iOS-device}
Authentication: enabled
Password: {password-for-my-username}
Secret encryption key: 

Actually I am not so aware of what can be a security risk here. I will learn more about OwnTracks security topic and the TLS client.

When you update your Home Assistant, you will need to follow the directions on the Owntracks component to fix your Owntracks

please allow me to jump in here, my setup stopped working about a week ago, and I have changed nothing related …

using the owntracks: (and not the device_tracker ever since that breaking change was implemented), and doing so successfully with this settings:

owntracks:
  max_gps_accuracy: 100
  #secret: !secret owntracks_secret
  waypoints: true
  #mqtt_topic: !secret owntracks_mqtt_topic
  waypoint_whitelist:
    - !secret owntracks_user_id

I need my iPhone to communicate with the mqtt broker on one of my Ha instances (using a secure port forward from domain.duckdns.org) , and have always done so via the mqtt setting in the app.
which now stopped working…

Although I hadn’t setup the integration by clicking add integration, it has always showed in the list of integrations. deleted that, as per instructions in the documentation, to add it again and received a ridiculously long url… entered that, but still no connection.

What is going wrong here?
just to be clear: I have 2 HA instances (mqtt broker on one of them) and need my iPhone to talk to both HA instances

please help me getting my Owntracks back? deleted the app and reentered my credentials didn’t help either btw.

filed an issue on the Owntracks Github: https://github.com/owntracks/ios/issues/568

found this thread: Authentication Home Assistant and Owntracks HTTP

where @deisi explains how t setup http connection, but how would that work for 2 Ha instances… couldn’t set the 2 web hooks in the one Owntracks app. This is really silly.

thanks

just for reference to point to the solution in my settings:

Mqtt mode with 2 HA instances: correct port forwarding in the router solves this.

Just so you understand, your MQTT broker is never listening on 8123, since that service is handled by your HA. MQTT non TLS broker port is 1883, and TLS is 8883, so never would it have worked to point MQTT to 8123. Ever.

yes, I understand that, thanks.

its just that all of a sudden things stopped working. And trying to follow the guidelines of the new integration doesn’t help. It doesn’t even mention the possibility of using the Mqtt setup, merely as a collateral pickup of the http integration.

Coming from a nicely tuned Mqtt configuration, reading all the issues people have with the new http integration, wasn’t very attractive, so I put all on getting the mqtt setup to work again.

Thanks to the authors on Owntracks GitHub, and a brainwave for a port forward, I have it back again…

both mqtt and device_tracker entities, via the owntracks: setup.

On all my Ha instances, via the clean Mqtt route. No horrendous entity-names, all very concise and simple.

btw, its never as black and white with these ports, since there are internal and external ports, defaults and non defaults… let alone on more than one instance ;-)), or maybe :-((

thanks for lending a hand!

I think once you get it to work, its worth the effort. In particular on recent android versions, as it works significantly better.

yes, its still working :wink:
without a hiccup. Still don’t understand what happened before, but Owntracks is steady as a rock again.
Mqtt is tailor-made used in my setups. very powerful.

Hi,
Could someone help me please? Thanks!

I have OwnTracks installed on my iphone. It’s connected and indicates it’s “idle”.

I have a Hassio notification indicating that device_tracker cannot be setup. I’m using the integrated Mosquitto Broker add-on.

Here is the excerpt from my configuration.yaml:

owntracks:
  max_gps_accuracy: 200
  waypoints: true
  mqtt_topic: "owntracks/#"
  events_only: true

device_tracker:
  platform: owntracks
  mqtt_topic: “owntracks/#”
  username: !secret username
  password: !secret alarm_psswd
  new_device_defaults:
    track_new_devices: true

I cannot see anywhere on the owntracks page…

… Where it says to configure it under the device_tracker component.

Maybe try following the instructions.

I tried it without the device_tracker portion as well. Although I get no notification errors, I still do not see anything on the overview menu.

Looks like I’m supposed to be using port 8883 with MQTT. After changing to this port and reconfiguring my forwarding in my router, I get an error “idle NSPOSIXError Domain 61…”

Weird, I changed the port back to 1883, now the status is connected.
I see a Map menu on the left now and can see it’s working! Success!

Now to figure out how to install the recorder part.