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.
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.
Read more about the Recorder.
You'll recall (we hope) the discussion on MQTT and the analogy with the cauldron. mqttwarn, while not specific to OwnTracks, is another client you connect to your MQTT broker. We think it's worth mentioning (and both Ben and JP -- the creators -- are quite pleased with what it does).
mqttwarn lets you do things like tweet everytime OwnTracks reports a location (but do consider whether you really want that), send an e-mail when a loved one enters a particular region, etc.
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 private mode, 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.
- Stefano Costa cooks Italian pasta using OwnTracks.
- 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)