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 <repository_url>  # Replace with your GitLab/GitHub repository URL
      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).

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.1.tar.gz (43.4 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.1-py3-none-any.whl (30.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mesh2traccar-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bd91f07999cba6b8ab30eac006a01bb26e797abc28a4b288c0943c16713f5bd3
MD5 70f7b0f8ae18f6f960a1e386465e53c4
BLAKE2b-256 7c2e089fe575ae444c2bbf7e0179b336b0adc9fd50bd35f332519e1dcb8ab5ce

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mesh2traccar-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 807ee9946ec96f4f49cd137ef2a10e61d0d9e793bf4349a65733240c9706b195
MD5 b1f743ec9332b6063d9d687e0a9532b7
BLAKE2b-256 8fa1f7f84009ce5d6a6c4899a895cdd460fbc3467b0a5bf71e84cc404e186a75

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