Python API - MQTT example for Home Assistant

I have built a setup where I have a raspberry pi with a PIR sensor connected to the GPIO. When the sensor detects movement it sends a MQTT message to another raspberry pi running Home Assistant.

This python program uses the API to sends a notification with time stamp to meshtastic when motion is detected. It also subscribes to a MQTT-topic (temperature sensor) and relays that value to meshtastic.


I love it! Thanks for sharing.

I’ve read of a few posts from people hoping to do the same. I think this is a good resource.


I have a Xaio connected directly connected to the tbeam on pin35 for the serial_app and it’s relaying the “motion” alert via mesh/mqtt. But I’m getting some foreign encoding anyone have an idea on how to clean it up?

Are you using my code in the link above or some other solution?

No. The XAIO is directly connected to the meshtsatic node and fwding to mqtt via the SerialApp and iI deployed an onprem meshtastic-backend server to for the clear txt mqtt.

I accidentally cross-posted here.

No problem,
Hope you will get your setup to work!