Owntracks CloudMQTT Setup Help

I’m trying to set up a geofence to toggle a switch when I am close to my house. I’m using Owntracks on my phone and CloudMQTT.

In openhab I have the mqtt and mqttitude bindings installed and configured as below.

  • mqtt.cfg

  • mqttitude.cfg
    no changes

  • HomeItems.items
    Switch PresenceCD “CD @ home” {mqttitude=“mosquitto:owntracks/phone/colephone/event:home”}

  • Geofence.sitemap
    Switch item=PresenceCD

Using the following command I can see information from Owntracks which makes me think that Owntracks and CloudMQTT are configured correctly

  • sudo mosquitto_sub -h m15.cloudmqtt.com -p 11774 -u openhabian -P openhabian -t “owntracks/phone/colephone”

  • when I force Owntracks to upload I get something like… {"_type":“location”,“tid”:“1”,“acc”:4,“batt”:21,“conn”:“w”,“lat”:52.116962,“lon”:-106.6635014,“t”:“u”,“tst”:1544681793,"_cp":true}

In Owntracks I have two regions set up, one is home and work

On the CloudMQTT website I can also see my connections from the Owntracks app, my mosquitto_sub command and the MQTT.fx applications I have running. I never see the connection Openhab.

Any help is appreciated!

Please use the code fence

Your mqtt.cfg should be:


You might want to switch to HTTP (as recommended by the Owntracks authors) and use the new GPStracker binding.

1 Like

I adjusted the code fence. No changes in the switch status. Any other help?

I would like to use MQTT as I also wanted to install some other wifi door status switches that also used MQTT. Any other help or error logs I can look at?

That is unrelated. You can use MQTT for your door switches and HTTP for owntracks.

Whatever that means (you don’t expect us to know what is in there by default, do you ?). You would need to properly configure that, too.
But mqttitude binding is now deprecated - use gpstracker as I suggested instead.

Thanks for the help Markus!

I will try out GPS tracker with HTTP as suggested. Are there any free options for remote host connections? If I use my local IP, I am only going to be able to use geofencing when I am at home connected to my local network.

Respone to mqqtitude

In mqttitude.cfg file the only configuration option it gives me are for lat/lon coordination and geofence distance, I am also not using manual mode. The documentation details that the broker configuration is completed in the MQTT binding.

Broker Configuration

First you will need to install and configure the MQTT binding. This will define the connection properties for your MQTT broker and specify the broker ID which we will need when configuring the Mqttitude item bindings.

services/mqttitude.cfg Config

You only need to define these properties in your services/mqttitude.cfg configuration file if you are using one or more ‘Manual Mode’ item bindings. In this mode you need to let the binding know exactly where ‘home’ is and the size of your geofence.

Here is an example;

# Optional. The lat/lon coordinates of 'home'

# Optional. Distance in metres from 'home' to be considered 'present'

Your MQTT config (mqtt.cfg) will need to look something like below.

# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
broker.url=tcp://   (replace with your server IP address)

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.

# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.

# Optional. User id to authenticate with the broker.

# Optional. Password to authenticate with the broker.

I have the mqqt binding installed and configured as below. These match the cloudMQTT details.


I have two users set up in cloudMQTT. One is for my phone, owntracks and one is for openhab.

I can see the connection from Owntracks on cloudMQTT. I can also see the other connections on cloudMQTT if I make them. For example using MQTT.fx program or if I run the mosquitto_sub command. I never see the connection from openhab though…

Is there a way to see if openhab is opening an MQTT connection or subscription?


As I said above

I changed the broker.url as per below but it still did not work.

Is there a way to see if openhab is opening an MQTT connection or subscription? any other help?

Yes check your log

Anything specific I should be looking for? When will it issue the MQTT connection or subscription? on startup of the app? or do I need to reboot?

If you are on openHAB 2.4 snapshot or milestone:
Just to be sure: You installed the MQTT 1.x binding from the legacy repository and not the binding that calls itself MQTT?

I installed MQTT using the paper UI. Version 1.12.0. Is not the correct binding?

Looks good. You don’t need to reboot. The connection should be established as soon as the configuration file changes, actually. But you haven’t looked into the logs yet have you?

just in case: add a troubleshooting option as the first line in your mqtt.cfg (you can remove it after the connection works)

mosquitto.retain=true  //why retain true? :) 

Yes, you can simply use myopenHAB.org! All you need to do is to use “https://home.myopenhab.org/gpstracker/owntracks/” as the “Host” parameter in OwnTracks and obviously you need to provide your credentials in “Identification” with it. No need to setup any MQTT broker or anything.

1 Like

I got it to work. My issue was with the mqtt binding setup, I had multiple mqtt brokers defined for some reason. I believe it was caused by using the paper UI to install the mqtt binding and then editing the .cfg files over and over. When I would write the mqtt.cfg file I would get multiple broker initialization as if the mqtt broker was defined multiple times. The log looked something like this.

  • 2018-12-16 16:37:49.722 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘colesbroker’
  • 2018-12-16 16:37:49.722 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘broker’
  • 2018-12-16 16:37:49.722 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘mosquitto’

I ended up reinstalling openhab and starting over. I edited the mqtt.cfg as per below and did not edit anything in mqttitude.cfg.


  • Colesbroker.url=tcp://m15.cloudmqtt.com:11744
  • Colesbroker.user=openhabian (This needs to match your username and password on cloudmqtt)
  • Colesbroker.pwd=***** (This needs to match your username and password on cloudmqtt)

When you write the mqtt.cfg file you should see the follow in the openhablog.log

  • 2018-12-16 16:37:49.717 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
  • 2018-12-16 16:37:49.722 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘colesbroker’

If this worked you will see the connection on the cloudmqtt website under connections.

I defined a switch as per below

  • Switch ColeIsHome "Cole @ home" <switch> { mqttitude="colesbroker:owntracks/phone/colephone/event:home" }

I put this switch on a sitemap

  • Switch item=ColeIsHome

In own tracks I set up the following

  • Username – matches user defined in cloud mqtt
  • Password – matches password defined in cloud mqtt
  • Device ID – colephone (you can call this whatever you want but your topic in the item definition must match)

In owntracks I defined a region called “home”. When you are leaving or entering the area it will send an event topic something like the following.


  • owntracks/phone/colephone/event


  • {"_type":"transition","tid":"1","acc":34.948,"desc":"home","event":"enter","lat":52.1174525,"lon":-106.6639978,"tst":1544994786,"wtst":1544664304,"t":"c"}


  • {"_type":"transition","tid":"1","acc":34.948,"desc":"home","event":"leave","lat":52.1174525,"lon":-106.6639978,"tst":1544994786,"wtst":1544664304,"t":"c"}

You can test your connection by defining an string item and putting this on your sitemap. Then when you get any updates from OwnTracks you can see the whole message received in openhab. This will work for any Owntracks messages that have the same topic i.e. “owntracks/phone/colephone”.

In Items

  • String ColeIsHere "Cole @ home [%s]" {mqtt="<[colesbroker:owntracks/phone/colephone:state:default]" }

In sitemap

  • Switch item=ColeIsHere

Hopefully this helps the next person.