No description
  • Python 97.7%
  • Dockerfile 2.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2022-06-14 15:36:31 +02:00
Dockerfile The script 2022-06-14 15:36:31 +02:00
mqtt2owntracks.py The script 2022-06-14 15:36:31 +02:00
README.md first commit 2022-06-14 15:35:21 +02:00

MQTT2OwnTracks

A script to sync OwnTracks messages from MQTT to an HTTP endpoint

About

This was created because I wanted to use NextTracks in MQTT mode, but also use Nextcloud PhoneTrack which does not support MQTT.

Installation

  • Clone repository
  • Build Docker image

Usage

Option Type Required Example Description
--owntracks-url string yes https://maps.example.com/{session_token}/{device_name} URL of your OwnTracks instance
--owntracks-tokens JSON (string) no {"user1":"myverysecrettoken","user2":"anothersecrettoken"} username:token mapping which can be used in the OwnTracks URL
--accuracy int no 15 Minimum accuracy for location data to forward it to the URL (default: 10)
--mqtt-host string yes 10.0.0.1 IP address or hostname of the MQTT broker to connect to (default: none)
--mqtt-port int no 1883 TCP port for the MQTT broker to connect to (default: 1883)
--mqtt-client-id string no mqtt2owntracks Client ID to use for MQTT (default: mqtt2owntracks)
--mqtt-topic string no owntracks/# Base topic to use for MQTT (default: owntracks/#)
--mqtt-user string no mqtt Username to use for MQTT (default: none)
--mqtt-pass string no supersecret Password to use for MQTT (only when --mqtt-user is specified, default: none)
--verbose, -v[vv] switch no - Enable verbose output. Repeat up to 3 times to increase verbosity.

Tokens

The OwnTracks/NextTracks client will publish its payloads to owntracks/{user_name}/{device_id}. The PhoneTrack implementation is using a URL format like /index.php/apps/phonetrack/log/owntracks/{session_token}/{device_id}. To make it possible for multiple users to use this, some tokens can be used in the URL, which will then be replaced by the values from MQTT. The {session_token} will be looked up for the corresponding user in the dictionary specified with --owntracks-tokens. Available tokens for the URL are:

Token Description
{user_name} The first level of the MQTT topic, after the owntracks base topic
{session_token} The session token for the corresponding user, specified in --owntracks-tokens
{device_name} The second level of the MQTT topic, after the owntracks base topic