Clients#

Using our OwnTracks app is cool, but what do you do with the location data the apps send (i.e. publish) to the MQTT broker? We have some suggestions.

You know that OwnTracks publishes location information to an MQTT or HTTP endpoint. The data it publishes is transferred in a particular format called JSON, and this is what it looks like.

When you've got your endpoint set up, and OwnTracks configured to use it, you'll want to do something useful with the data, and the following sections introduce you to some of the existing clients you can utilize for doing that.

mosquitto_sub#

mosquitto_sub is a very basic command-line client provided by the Mosquitto project. However, it is brilliantly useful, and you can also use it for long-time collection of data by having it run in the background with stdout pointing to a file.

In it's most basic invocation, you have the program connect to your broker and subscribe to the topics you're interested in. (If you've used our quicksetup you just need the -t 'owntracks/# option as we've configured the rest for you.)

mosquitto_sub -h localhost -p 1883 -v -t 'owntracks/#'

mosquitto_sub and it's counterpart, mosquitto_pub for publishing to a broker, support a slew of options. It'll be worth your while to study their manual page.

Recorder#

We recommend our very own OwnTracks Recorder because it's lightweight, relatively simple to set up, and because it offers a lot of features. It stores location data published by the apps by subscribing to an MQTT broker, and it enables you to access that data in a variety of formats. The best part is: it doesn't require a heavy external database of any kind.

Recorder

And the best is, you can configure the Recorder to also accept the HTTP POST requests from the apps, so it's the best companion for the OwnTracks apps in HTTP mode as well. Here again, if you used quicksetup, you already have a correctly configured Recorder.

Read more about the Recorder.

mqttwarn#

You will recall the discussion on MQTT, and the analogy with the cauldron. On this matter, mqttwarn, while not specific to OwnTracks, is another client you can connect to your MQTT broker. We think it is worth mentioning, and both Ben and JP -- the creators -- are quite pleased with what it does.

mqttwarn lets you do things like submitting a tweet each time OwnTracks reports a location (but do consider whether you really want that ;]), send an e-mail when a loved one enters a particular region, or use ntfy.sh to deliver a notification to your mobile phone, just to name a few examples of what is possible. Think of a self-hosted IFTTT or Zapier, but all that running on your premises, and a bit less enterprise.

Technically speaking, mqttwarn is a highly configurable MQTT message router, where the routing targets are notification plugins, written in Python. mqttwarn currently supports well over 90 different notification services or providers. A picture says a thousand words.

mqttwarn

Enjoy exploring the mqttwarn documentation.

openHAB#

Presence detection in home automation is one of the most important pieces of the puzzle. Without it your smart home is effectively blind, and as a result can hardly be called 'smart' at all. There are very few automation rules that do not require some form of context in terms of human occupancy. Rules around security, lighting, music, even coffee machines -- all need to know if 'someone' is home before deciding whether to take action.

openHAB

This is where OwnTracks steps in. In its simplest form it can be configured with waypoints (for home/work etc) that generate events whenever your phone enters/leaves these regions. These are sent to your own personal MQTT broker where your home automation software can react accordingly. The beauty of OwnTracks is two-fold - it is simple, you can disable the standard location reporting so all you get is the waypoint event/leave events, which is all your smart home cares about. The second is that, in all your data is yours and yours alone - there is no cloud service collecting, storing and potentially mining your data.

Read more about openHAB and OwnTracks.

Home Assistant#

Another home automation solution that can be used with OwnTracks is Home Assistant. Home Assistant allows you to track the location of people connected to your personal MQTT broker. It has a map to show their current location and can trigger automations based on entering and leaving zones. In order to use the internal broker of Home Assistant, the MQTT protocol level has to be set to 4.

See the demo for an example of the map with OwnTracks devices or read more about how Home Assistant connects to your private MQTT broker, how to enable OwnTracks support in Home Assistant and how to configure automations based on zones.

Roll your own#

If you feel really brave, you can write your own program which subscribes to OwnTracks data, but don't forget to tell us about it!

Here are some projects we know of which use and/or integrate OwnTracks and/or which are useful when using MQTT in general or OwnTracks in particular.