Sending json text via MQTT

Anyone know how to send messages through MQTT with a local broker? My settings are:

Lilygo t3s3 running 2.3.4.ea61808 Beta
Channel 0 (primary): LongFast
Uplink: Enabled
Downlink: Enabled

MQTT:
enabled: yes
IP: 10.55.0.106 (mosquitto broker running on my LAN)
username: blank
password: blank
encrypted: false
json: true
topic: msg/US
client proxy: false

I’m able to see the json messages of received direct messages like so:

msh/US/2/json/LongFast/!fa5a18e8 {"channel":0,"from":413545356,"id":1604305848,"payload":{"text":"test message"},"rssi":-75,"sender":"!fa5a18e8","snr":6,"timestamp":1713383600,"to":1976953804,"type":"text"}

But I’m not able to send. I’ve tried:

mosquitto_pub -d -h 10.55.0.106 -t 'msh/US/2/json/LongFast/!18a6338c' -m '{"channel":3,"from":413545356,"id":1604305993,"payload":{"text":"test12"},"sender":"!18a6338c","to":1976953804,"type":"text"}'

The above complains about the topic not being “mqtt” or downlink being disabled (it’s not).

I also tried:

mosquitto_pub -d -h 10.55.0.106 -t 'msh/US/2/json/mqtt/!18a6338c' -m '{"channel":3,"from":413545356,"id":1604305993,"payload":{"text":"test12"},"sender":"!18a6338c","to":1976953804,"type":"text"}'

My local node seems to be ignoring the message, however. Nothing gets output over the USB serial debug.

Has anyone been able to send json via MQTT?

One thing I noticed from the docs (MQTT | Integrations Overview | Meshtastic) is that the “type” is supposed to be “sendtext”, not “text”.

1 Like

It worked! Thanks. This was the command I used:

mosquitto_pub -d -h 10.55.0.106 -t 'msh/US/2/json/mqtt' -m '{"channel":0,"from":4200208616,"payload":"test2 from CLI","to":1976953804,"type":"sendtext"}'

image