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.
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 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.
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.
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.
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.
Enjoy exploring the mqttwarn documentation.
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.
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.
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.
- MQTT Inspector for iOS, written by Christoph Krey, who also did our OwnTracks for iOS app. This is an indispensable utility for all things MQTT.
- the thing system ( code )
- A Clojure webapp that aims to manage information gathered from OwnTracks; clojure-mqttitude-backend
- An OwnTracks flow by Giovanni @juzam Angoli for Node-RED which publishes messages to pushover.net upon entering or leaving a geo-fence.
- MyMQTT is an app for Android which enables you to subscribe and publish to an MQTT broker.
- Matthew Bordignon made a small Web page which uses Websockets to display the barometer reading published by OwnTracks for iOS. (Screenshot.)
- PHP front & backend for OwnTracks payloads
- Orion, an alternative to OwnTracks Recorder with powerful visualization features (server, web client, demo)
- OwntracksOSM is an Owntracks and OpenStreetMap based mapping and location sharing app for Samsung smartwatches (screenshots).
- From OwnTracks to QGIS, a solution to import OwnTracks data into QGIS.
- Magic Mirror module for displaying results from OpenTracks
- Prometheus OwnTracks Exporter
- hauk-snitch bridges OwnTracks and Hauk and makes it easy to share your current live location with other people for a given period of time. Just send them a link, all they need is a browser.
- mqottrace, written by Michael Staats is a Perl program which collects OwnTracks locations and stores them in an SQLite3 database; it also includes a tool to convert this data to GPX format.