Skip to main content

A Python application to forward Meshtastic MQTT location messages to a Traccar server

Project description

Mesh2Traccar

A Python application to forward Meshtastic MQTT location messages to a Traccar server.

Installation

  1. Install the Package:

    • Option A: Via PyPI (Recommended):
      pip install mesh2traccar
      
    • Option B: Via Git Clone (for developers or custom versions):
      git clone https://gitlab.com/drid/mesh2traccar
      cd mesh2traccar
      pip install .
      
      Note for Developers: For local development, place mesh2traccar.conf in the current directory to use it instead of /etc/mesh2traccar/mesh2traccar.conf. Logs will be written to ./mesh2traccar.log if /var/log/mesh2traccar/ is not writable.
  2. Create a User and Group:

    sudo groupadd mesh2traccar
    sudo useradd -r -g mesh2traccar -d /var/lib/mesh2traccar -s /sbin/nologin mesh2traccar
    
  3. Set Up Directories:

    sudo mkdir -p /etc/mesh2traccar /var/lib/mesh2traccar /var/log/mesh2traccar
    sudo chown mesh2traccar:mesh2traccar /var/lib/mesh2traccar /var/log/mesh2traccar
    
  4. Copy Configuration File:

    • For PyPI installation:
      sudo cp $(python -c "import pkg_resources; print(pkg_resources.resource_filename('mesh2traccar', 'mesh2traccar.conf'))") /etc/mesh2traccar/
      
    • For Git clone installation:
      sudo cp mesh2traccar.conf /etc/mesh2traccar/
      
    • Set permissions:
      sudo chown mesh2traccar:mesh2traccar /etc/mesh2traccar/mesh2traccar.conf
      sudo chmod 640 /etc/mesh2traccar/mesh2traccar.conf
      
  5. Edit Configuration: Edit /etc/mesh2traccar/mesh2traccar.conf to set your MQTT and Traccar settings:

    • mqtt.broker: MQTT broker address.
    • mqtt.port: MQTT broker port (default 1883).
    • mqtt.username and mqtt.password: MQTT credentials (optional).
    • mqtt.client_id_prefix: Prefix for MQTT client ID.
    • mqtt.topic_sub: Meshtastic MQTT topic (e.g., msh/ANZ/2/json/LongFast/+).
    • traccar.url: Traccar server URL (e.g., http://your-traccar-server:5055).
    • traccar.device_id: Default device ID for Traccar.
    • traccar.api_key: Traccar API key (optional).
  6. Install Systemd Service:

    • For PyPI installation:
      sudo cp $(python -c "import pkg_resources; print(pkg_resources.resource_filename('mesh2traccar', 'mesh2traccar.service'))") /etc/systemd/system/
      
    • For Git clone installation:
      sudo cp mesh2traccar.service /etc/systemd/system/
      
    • Enable the service:
      sudo systemctl daemon-reload
      sudo systemctl enable mesh2traccar.service
      
  7. Start the Service:

    sudo systemctl start mesh2traccar.service
    

Usage

  • Check Service Status:

    sudo systemctl status mesh2traccar.service
    
  • View Logs:

    tail -f /var/log/mesh2traccar/mesh2traccar.log
    
  • Stop or Restart:

    sudo systemctl stop mesh2traccar.service
    sudo systemctl restart mesh2traccar.service
    

Notes

  • Ensure your MQTT broker and Traccar server are running and accessible.
  • Register Meshtastic node IDs (e.g., !2f8382cc) in Traccar as device identifiers.
  • If the ! prefix causes issues, modify mesh2traccar.py to remove it:
    device_id = format(from_id, 'x') if from_id is not None else TRACCAR_DEVICE_ID
    
  • The software is licensed under the GNU General Public License v3 (GPLv3). See the LICENSE file for details.

Troubleshooting

  • Check /var/log/mesh2traccar/mesh2traccar.log (or ./mesh2traccar.log for local development) for errors.
  • Verify MQTT topic and Traccar URL in the configuration file.
  • Ensure the mesh2traccar user has permissions to read /etc/mesh2traccar/mesh2traccar.conf (or ./mesh2traccar.conf for development).

License

This project is licensed under the GNU General Public License v3.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mesh2traccar-0.1.2.tar.gz (43.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mesh2traccar-0.1.2-py3-none-any.whl (30.9 kB view details)

Uploaded Python 3

File details

Details for the file mesh2traccar-0.1.2.tar.gz.

File metadata

  • Download URL: mesh2traccar-0.1.2.tar.gz
  • Upload date:
  • Size: 43.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for mesh2traccar-0.1.2.tar.gz
Algorithm Hash digest
SHA256 41a1ba4a3331b8284254f728f4930d88408407956a3455641b382a5738c0d1d8
MD5 49e8964e8dbf709c331a35082eec7ac6
BLAKE2b-256 d42dde092a50f6839db2863650cd52117dab831f2d8c6240c8e00f73b80222dc

See more details on using hashes here.

File details

Details for the file mesh2traccar-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: mesh2traccar-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 30.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for mesh2traccar-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c0759f0834623a027cf8f6507f2723e5e54fad6b04ccf2f5d3bb1ed93e117fac
MD5 af1c36ffd9203ce6ae6c344a30661f9a
BLAKE2b-256 cb1d20a499c9f9416c7ef114630ef06d27aeaca00283e6a44d721455abbbdad1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page