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