MQTT
MQTT (aka MQ Telemetry Transport) is a machine-to-machine or “Internet of Things” connectivity protocol on top of TCP/IP. It allows extremely lightweight publish/subscribe messaging transport.
The MQTT component needs an MQTT broker like Mosquitto or Mosca. The Eclipse Foundation is running a public MQTT broker at iot.eclipse.org or the Mosquitto Project under test.mosquitto.org. If you prefer to use a public, keep in mind to adjust the topic and that your messages may be publicly accessible.
To integrate MQTT into Home Assistant, add the following section to your configuration.yaml
file:
1 2 3 4 5 6 7 8 9 |
|
The MQTT component has no TLS support at the moment. This means that only plain-text communication is possible.
Building on top of MQTT
There are two ways to integrate MQTT into your process. One is by using the MQTT-automation rule. The other one is by integrating it into a component. See the MQTT example component how to do this.
Testing
For debugging purposes mosquitto
is shipping commandline tools to send and recieve MQTT messages. For sending test messages to a broker running on localhost:
1
|
|
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.
1 2 3 4 |
|
The message should appear on the bus:
1
|
|
For reading all messages sent on the topic home-assistant
to a broker running on localhost:
1
|
|