Owntracks location tracking with MQTT and HTTPS (recorder) support
OCaml 95.9%
Dune 1.3%
Other 2.7%
10 1 0

Clone this repository

https://tangled.org/anil.recoil.org/ocaml-owntracks
git@git.recoil.org:anil.recoil.org/ocaml-owntracks

For self-hosted knots, clone URLs may differ based on your setup.

README.md

owntracks#

OCaml types and JSON codecs for OwnTracks MQTT location messages.

Overview#

OwnTracks is an open-source location tracking application that publishes GPS coordinates, accuracy, speed, battery, and other device state over MQTT. This library provides type-safe parsing and serialization of all OwnTracks message types.

Packages#

  • owntracks - Core types and jsont codecs
  • owntracks-cli - Command-line tools for MQTT subscription and data export

Installation#

opam install owntracks      # Core library
opam install owntracks-cli  # CLI tools

Usage#

Decoding Messages#

let json = {|{"_type":"location","lat":51.5,"lon":-0.1,"tst":1234567890}|} in
match Jsont_bytesrw.decode_string Owntracks.Message.jsont json with
| Ok (Location loc) ->
    Printf.printf "Location: %.4f, %.4f\n"
      (Owntracks.Location.lat loc)
      (Owntracks.Location.lon loc)
| Ok _ -> print_endline "Other message type"
| Error e -> Printf.printf "Error: %s\n" e

Message Types#

Type Description
Location GPS coordinates, accuracy, speed, battery
Transition Region entry/exit events
Waypoint Monitored region definitions
Card User information for display
LWT Last Will and Testament (disconnect notification)

Integration Modules#

  • Mqtt - MQTT message parsing and topic helpers
  • Recorder - OwnTracks Recorder HTTP API parsing
  • Geojson - Convert locations to GeoJSON format

CLI Tools#

The owntracks-cli package provides:

  • Real-time MQTT monitoring
  • GeoJSON export
  • OwnTracks Recorder API queries

References#

License#

ISC