Publish MQTT message with JSON payload

Dear all,

I would like to publish an MQTT message with JSON payload:

Switch button "Update" {mqtt=">[rabbit:owntracks/peter/phone/cmd:command:ON:\"{abcd\:2}\"]"}

The problem is that I do not know how to escape the colon sign.

OwnTracks allows to remotely trigger the current location by sending MQTT message with the payload:


This MQTT message I want to publish after button click in OpenHAB.

Thank you for your help

I found an workaround through a rule:


Switch button
String locationRequest "[%s]" {mqtt=">[rabbit:owntracks/peter/phone/cmd:command:*:default]"}


Switch item=button label="Update" mappings=[ON="Now"]


rule "mqtt publish"
    Item button received command

Hope it helps


I have similar problem.
Did you find solution?
Is this Button Item correct?

Switch item=button label="Update" mappings=[ON="Now"]

Edit: It’s correct. 100% working for me. Thanks

Hey there are a lot of questions about how to send a JSON paload via MQTT within the item file and no rule. I Just figured it out.
Just use \ to escape the colon ( : ) like example:

    Switch Awtrix_Power "Awtrix Power" { mqtt=">[broker:awtrix/basics:command:ON:{\"power\"\\: true}]"}

It will send the JSON payload: {“power”: true}
No Rules or maps needet. i used MQTT 1x biding
Maybe it will help someone in the future.

1 Like

@GordanTrevis: Are you using a current Beta version of AWTRIX? And the MQTT app?
I try to show some data from openhab (e.g. from HTTP or Netatmo binding) on my AWTRIX, but I have no idea how to do this.

Hey @RolandS , :wink:
No i have not yet installed the new AWTRIX-Beta. im using the current ‘stable’ version.
But its actually quite simple. Im using both the ‘HTTP-API’ and the ‘MQTT-API’ from Awtrix.
I can send you all the stuff, but im not sure if this is the right place. Maybe Ask in new thread again - And i can post it there?