The relay is compatible with Python 3.9 and newer on Linux, macOS, and Windows. We encourage contributions to fix bugs or add enhancements.
Clone the repository:
git clone https://github.com/geoffwhittington/meshtastic-matrix-relay.git
Create a Python virtual environment in the project directory:
python3 -m venv .pyenv
Activate the virtual environment and install dependencies:
source .pyenv/bin/activate
pip install -r requirements.txt
To configure the relay, create a config.yaml
file in the project directory. You can refer to the provided sample_config.yaml
for an example configuration.
Activate the virtual environment:
source .pyenv/bin/activate
Run the main.py
script:
python main.py
Example output:
python main.py
INFO:meshtastic.matrix.relay:Starting Meshtastic <==> Matrix Relay...
INFO:meshtastic.matrix.relay:Connecting to radio at meshtastic.local ...
INFO:meshtastic.matrix.relay:Connected to radio at meshtastic.local.
INFO:meshtastic.matrix.relay:Listening for inbound radio messages ...
INFO:meshtastic.matrix.relay:Listening for inbound matrix messages ...
INFO:meshtastic.matrix.relay:Processing matrix message from @bob:matrix.org: Hi Alice!
INFO:meshtastic.matrix.relay:Sending radio message from Bob to radio broadcast
INFO:meshtastic.matrix.relay:Processing inbound radio message from !613501e4 on channel 0
INFO:meshtastic.matrix.relay:Relaying Meshtastic message from Alice to Matrix: [Alice/VeryCoolMeshnet]: Hey Bob!
INFO:meshtastic.matrix.relay:Sent inbound radio message to matrix room: #someroomid:example.matrix.org
To run the bridge automatically on startup in Linux, set up a systemd service:
[Unit]
Description=A Meshtastic to Matrix bridge
After=default.target
[Service]
Type=idle
WorkingDirectory=%h/meshtastic-matrix-relay
ExecStart=%h/meshtastic-matrix-relay/.pyenv/bin/python %h/meshtastic-matrix-relay/main.py
Restart=on-failure
[Install]
WantedBy=default.target
Enable and start the service:
systemctl --user enable mmrelay.service
systemctl --user start mmrelay.service
We use Trunk for automated code quality checks and formatting. Contributors are expected to run these checks before submitting a pull request.
Follow these steps to set up Trunk:
-
Install Trunk via the official installation script:
curl -fsSL https://get.trunk.io | bash
-
Initialize Trunk in your local environment:
trunk init
-
To check your code and automatically fix issues, run:
trunk check --all --fix
Refer to the Trunk documentation for more details on using Trunk effectively.