home-assistant.io/source/_docs/mqtt/testing.markdown
Franck Nijhof 1833c32a2c Cleans up front matter (#9835)
* Sets front matter defaults

* Removes default front matter from section templates/pages

* Removes default front matter from addon pages

* Removes default front matter from integration pages

* Removes default front matter from posts

* Removes default front matter from docs pages

* Removes default front matter from other pages

* Fixes blog category pages
2019-07-11 14:35:08 -07:00

1.7 KiB

title, description, logo
title description logo
MQTT Testing Instructions on how to test your MQTT setup. mqtt.png

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 127.0.0.1 -t home-assistant/switch/1/on -m "Switch is ON"

If you are using the embedded MQTT broker, the command looks a little different because you need to add the MQTT protocol version and your broker credentials.

$ mosquitto_pub -V mqttv311 -u homeassistant -P <broker password> -t "hello" -m world

Another way to send MQTT messages by hand is to use the "Developer Tools" in the Frontend. Choose "Call Service" and then mqtt/mqtt_send under "Available Services". Enter something similar to the example below into the "Service Data" field.

{
   "topic":"home-assistant/switch/1/on",
   "payload":"Switch is ON"
}

The message should appear on the bus:

... [homeassistant] Bus:Handling <Event MQTT_MESSAGE_RECEIVED[L]: topic=home-assistant/switch/1/on, qos=0, payload=Switch is ON>

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

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

For the embedded MQTT broker the command looks like:

$ mosquitto_sub -v -V mqttv311 -u homeassistant -P <broker password> -t "#"