MQTT Testing

The mosquitto broker package ships commandline tools (often as *-clients package) to send and receive MQTT messages. 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 manually is to use the “MQTT” integration in the frontend. Choose “Settings” on the left menu, click “Devices & Services”, and choose “Configure” in the “Mosquitto broker” tile. Enter something similar to the example below into the “topic” field under “Publish a packet” and press “PUBLISH” .


and in the Payload field


In the “Listen to a topic” field, type # to see everything, or “home-assistant/switch/#” to just follow a published topic, then press “START LISTENING”. The messages 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/#"