MQTT Testing

The mosquitto broker package ships commandline tools (often as *-clients package) to send and receive MQTT messages. As an alternative have a look at hbmqtt_pub and hbmqtt_sub which are provided by HBMQTT. For sending test messages to a broker running on localhost check the example below:

mosquitto_pub -h -t home-assistant/switch/1/on -m "Switch is ON"

Another way to send MQTT messages by hand is to use the “Developer Tools” in the Frontend. Choose the “MQTT” tab. Enter something similar to the example below into the “Topic” field.


and in the Payload field


In the “Listen to a topic” field, type # to see everything, or “home-assistant/switch/#” to just follow the published topic. Press “Start Listening” and then press “Publish”. The result should appear similar to the text below

Message 23 received on home-assistant/switch/1/power/stat/POWER at 12:16 PM:
QoS: 0 - Retain: false
Message 22 received on home-assistant/switch/1/power/stat/RESULT at 12:16 PM:
    "POWER": "ON"
QoS: 0 - Retain: false

For reading all messages sent on the topic home-assistant to a broker running on localhost:

mosquitto_sub -h -v -t "home-assistant/#"