Help setting up OwnTracks, Mosquitto, and MQTT

Hello everyone. I am new to home automation and openHAB but cannot figure out how to wire everything up and make it work. I have read countless articles from Google searches, I have searched the community here and every example I have tried does not cause the Switch to flip.

Here is what I have so far

  • I have OwnTracks installed on my phone.
  • I have mosquitto installed on a server that is seperate from openHAB.
  • I see the phone connect and disconnect from the mosquitto server
  • I see openHAB connect and disconnect from the mosquitto server
  • I can use the _sub and _pub apps and send messages back and forth through a topic

I have tried wiring up the topic to a String in openHAB but it errors out saying it must be a Switch.

From here, I do not understand the binding setting nor do I understand the difference between using Regions and Home.
Here is what I have in my configs

Switch item=MY_PHONE icon=“present” valuecolor=[ON=“green”,OFF=“red”]

Switch MY_PHONE “My Phone” {mqttitude=“mqttbroker:owntracks/jbyrd/5s/event:ByrdHome”}

MQTT Transport

I do not have anything in the Mqttitude Binding. I have read conflicting information about having these values populated.

I do have a a Region set up in OwnTracks with a radius of 1 meter. When I walk around the block, no events fire that I can see anywhere. I do have the region shared.

I have compared the topic that shows in OwnTrack and I have it matching what I have put in openHAB.

At this point, I have no idea what to try.

Thanks in advance for your help.

Only thing I can think of is does the name of the region in your phone app match ByrdHome in your item binding?

It does match. I did have it called just home but read that was not good since home was reserved.

Do I need to fill out the mqttitude binding for Lat/Lon in the config file?

Not if you are seeing transition (enter/leave) pubs on your /event topic - can you confirm this via mosquitto_sub?

home is fine for a region name - that is what I use.

I never saw a leave/enter message but I had several diff states of setup before I took it all back to the ground and built it back. I will give that a test tomorrow.

Outside of walking all over my neighbor hood, is there a way to simulate enter/leave events?

Do you mean 100 meters or 1 kilometer? Most cell phones aren’t accurate to less that 30 meters. If it is 1 meter, you may just not be entering the region

I agree with Mike that a 1 meter radius is too small. I’ve been using a 50 to 100 meter radius with my regions and it is working reasonably well.

Also, be sure read to review the [OwnTracks location-related documentation] (, especially the section for the type of phone that you have. For example, depending on the phone, the position updates happen somewhat infrequently. There are also separate documentation pages for Android and iOS that describe other publishing behaviors specific to the phone operating system. I assume the event/leave event detection is constrained by those behaviors.

For example, I have a 15 minute commute to work and I have a region defined for my workplace. Sometimes I get a notification immediately as a I leave the region. Other times I get it after I’m most of the way home (~ 10 minutes after leaving the region). It depends on when the OwnTracks app is triggered by the operating system.

For detecting whether my wife and I are at home I’m using iBeacons with OwnTracks. They are much more reliable than the GPS-based geofencing for that purpose.

I had it set to 1m trying to get the events to fire as I walked around the block.

I have it set to 250m, turned everything back to normal, left for work and nothing changed. I have ownTracks set to refresh in the background and I see connections in the mosquitto server. I see it changing IP space as I left my house, hit the cell network, then hit the wireless network in the office.

I have mosquitto logging out to the db file and I can see the json strings with location data but its only data for my home. Everything is shared.

I will keep digging in these settings, it has to be something I am overlooking but I think my lack of understanding how both sides communicate might be causing me more issues.

When you say you see location data, what is the “_type” field in the JSON data? For events, it should be “transition” and will be published on a different topic than location data (_type=“location”, topic=owntracks/user/device/event).


Do you have more than 1 beacon in your house?

I don’t see a transition in my logs. I have setup a few other regions to see if it will trigger when I head out to lunch here in a few.

I currently have 4 iBeacons in the house that are monitored by OwnTracks and another 4 GPS regions defined (one for the house and 3 others).

Continuing the discussion from Help setting up OwnTracks, Mosquitto, and MQTT:

Hello there,
I saw your post. I just need little help.
I am also trying to do same thing. I have owntracks installed my iphone. Also mosquitto.
I want to get connected my iphone owntracks and front end webpage and want to see the owntracks data.
I dont where to to write the connection code in eclipse and all.
If I am off the track please let me know or share something for me.


No you aren’t - Jerel is trying to setup presence detection - your question is relating to storing data and presenting in your own web page. Please don’t cross post between threads.

Jerel - can you subscribe to owntracks/jbyrd/# using mosquitto_sub, set you region radius to 250m, ensure you have Owntracks set to High Accuracy and set the reporting frequency to 60s and 100m. Then go for a walk around your block and see what is reported back to the MQTT broker.

Hey there my apologies for cross post.


I will set up a few things and do that when I get home tonight.

I did manage to get OwnTracks to trigger when I left for lunch. I got the notification on my phone of leaving Work and I can see transition events in the log db for mosquitto, so I think I am making progress.

It does not look like anything triggered on openHAB but I also dont have anything setup for Work. When openHAB is subscribed to a channel will it show messages on the console like the exec binding firing off for all or will it only show when when the event I asked for. So I have it set up for ByrdHome currently, will the console show an incoming message even though it should not act on it?

If you setup debug/trace logging for the mqttitude binding you will probably see a load of logging as different messages arrive. You could try enabling debug/trace logging in the mqtt binding as well.

When I got home, everything tagged the way I would have expected. We went out to dinner and it logged that we left the house and then it shows we arrived back home.

it looks like everything was working. It would appear that the biggest mistake I made was setting the radius to small which meant the phone could not detect entering and leaving regions.

Thanks everyone who helped out on this thread. I will look into using ibeacons but the owntracks app will get me going for now.

has anyone an idea how to advertise an owntracks compatible iBeacon?
Currently, my raspberry pi advertises an eddystone URL
( )
Is it possible to advertise the URL and use it as an ibeacon with a UUID for Owntracks?
at the moment several ibeacon scanner will show only “unknown beacon/UUID”

I am using an android phone, so there might be another behaviour on android devices.

Yes, I have a raspberry pi running a ibeacon. This is a work in progress project. I’m not getting great results in owntracks yet, but the beacon part is working.

UUID="A1 CC BD B9 10 EC 45 0C B8 21 72 43 49 12 5D 78"
MAJOR="00 01"
MINOR="00 01"

start() {
	echo "Launching virtual iBeacon..."
	hciconfig $BLUETOOTH_DEVICE up
	hciconfig $BLUETOOTH_DEVICE noleadv
	hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 $UUID $MAJOR $MINOR $POWER 00
	# Start LE Advertisment using Default Settings
	hciconfig $BLUETOOTH_DEVICE leadv 3
	# Start LE Advertisment using 100ms Advert Rate
	#hcitool -i hci0 cmd 0x08 0x0006 A0 00 A0 00 03 00 00 00 00 00 00 00 00 07 00
	#hcitool -i hci0 cmd 0x08 0x000a 01
	echo "Complete"

stop() {
	echo "Disabling virtual iBeacon..."
	hciconfig $BLUETOOTH_DEVICE noleadv
	echo "Complete"

case $1 in
  start|stop) "$1" ;;
  *) echo "Usage: $0 { start | stop }" ;;

You can generate your own unique UUID here

I’m working on getting it started as a service, but currently you will need to start it again after a reboot.

i start with

./ start


./ stop

Hope this is helpful. I’ll be posting a full write up once I get this working correctly.

1 Like