mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-05-02 17:18:58 +00:00

* Split MQTT documentation * Add more details * Move content to /docs * Enable sidebar * Move content to /docs * Enable sidebar * Move content * Update links * Remove wizard stuff * Enable sidebar * Minor changes * Move MQTT parts to /docs * update links * Update links and sync content * Fix link * Enable sidebar * Remove navigation * Remove navigation and other minor updates * Update links * Add overview page * Make title linkable * Update * Plit content * Update links * Rearrange content * New getting-started section * Add icons for docs * Update for new structure * Update for new structure * Add docs navigation * Add docs overview page * Remove ecosystem navigation * Add docs and remove other collections * Move ecosystem to docs * Remove duplicate files * Re-add ecosystem overview * Move to ecosystem * Fix permission * Update navigation * Remove collection * Move overview to right folder * Move mqtt to upper level * Move notebook to ecosystem * Remove un-used files * Add one more rectangle for iOS * Move two parts back from docs and rename Run step * Remove colon * update getting-started section * Add redirect * Update * Update navigation
61 lines
1.9 KiB
Markdown
61 lines
1.9 KiB
Markdown
---
|
|
layout: page
|
|
title: "MQTT Testing"
|
|
description: "Instructions how to test your MQTT setup."
|
|
date: 2015-08-07 18:00
|
|
sidebar: true
|
|
comments: false
|
|
sharing: true
|
|
footer: true
|
|
logo: mqtt.png
|
|
redirect_from: /components/mqtt/#testing-your-setup
|
|
---
|
|
|
|
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](http://hbmqtt.readthedocs.org/en/latest/references/hbmqtt_pub.html) and [hbmqtt_sub](http://hbmqtt.readthedocs.org/en/latest/references/hbmqtt_sub.html) which are provided by HBMQTT. For sending test messages to a broker running on localhost check the example below:
|
|
|
|
```bash
|
|
$ 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.
|
|
|
|
```bash
|
|
$ mosquitto_pub -V mqttv311 -t "hello" -m world
|
|
```
|
|
|
|
or if you are using a API password:
|
|
|
|
```bash
|
|
$ mosquitto_pub -V mqttv311 -u homeassistant -P <your api 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.
|
|
|
|
```json
|
|
{
|
|
"topic":"home-assistant/switch/1/on",
|
|
"payload":"Switch is ON"
|
|
}
|
|
```
|
|
|
|
The message should appear on the bus:
|
|
|
|
```bash
|
|
... [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:
|
|
|
|
```bash
|
|
$ mosquitto_sub -h 127.0.0.1 -v -t "home-assistant/#"
|
|
```
|
|
|
|
For the embedded MQTT broker the command looks like:
|
|
|
|
```bash
|
|
$ mosquitto_sub -v -V mqttv311 -t "#"
|
|
```
|
|
|
|
Add the username `homeassistant` and your API password if needed.
|
|
|