The MQTT component needs you to run an MQTT broker for Home Assistant to connect to. There are four options, each with various degrees of ease of setup and privacy.
This is the most private option, but it requires a little bit of work to setup. There are multiple free and open-source brokers to pick from: e.g., Mosquitto, EMQ or Mosca. For hass.io users, the recommended setup method is to use the Mosquitto MQTT broker addon.
# Example configuration.yaml entry mqtt: broker: 192.168.1.100
(string)(Optional)The IP address or hostname of your MQTT broker, e.g., 192.168.1.32.
(integer)(Optional)The network port to connect to. Default is 1883.
(string)(Optional)The client ID that Home Assistant will use. Has to be unique on the server. Default is a randomly generated one.
(integer)(Optional)The time in seconds between sending keep alive messages for this client. Default is 60.
(string)(Optional)The username to use with your MQTT broker.
(string)(Optional)The corresponding password for the username to use with your MQTT broker.
(string)(Optional)Protocol to use: 3.1 or 3.1.1. By default it connects with 3.1.1 and falls back to 3.1 if server does not support 3.1.1.
(string)(Optional)Path to the certificate file, e.g.,
(boolean)(Optional)Set the verification of the server hostname in the server certificate.
(string)(Optional)TLS/SSL protocol version to use. Available options are:
'1.2'. Make sure to put quotes around the value. Defaults to
There is an issue with the Mosquitto package included in Ubuntu 14.04 LTS. Specify
protocol: 3.1 in your MQTT configuration to work around this issue.
If you get this error
AttributeError: module 'ssl' has no attribute 'PROTOCOL_TLS' then you need to set
If you are running a Mosquitto instance on the same server as Home Assistant then you must ensure that the Mosquitto service starts before Home Assistant. For a Linux instance running Systemd (Raspberry Pi, Debian, Ubuntu and others) then you should edit the file
/etc/systemd/system/[email protected] as
sudo nano /etc/systemd/system/[email protected]) and add the Mosquitto service:
If you are running a Mosquitto instance on a different server with proper SSL encryption using a service like Let’s Encrypt you may have to set the certificate to the operating systems own
.crt certificates file. In the instance of Ubuntu this would be
The Mosquitto project runs a public broker. This is the easiest to set up, but there is no privacy as all messages are public. Use this only for testing purposes and not for real tracking of your devices or controlling your home.
mqtt: broker: test.mosquitto.org port: 1883 or 8883 # Optional, replace port 1883 with following if you want encryption # (doesn't really matter because broker is public) port: 8883 # Download certificate from http://test.mosquitto.org/ssl/mosquitto.org.crt certificate: /home/paulus/downloads/mosquitto.org.crt
Home Assistant is not affiliated with CloudMQTT nor will receive any kickbacks.
- Create an account (no payment details needed)
- Create a new CloudMQTT instance (Cute Cat is the free plan)
- From the control panel, click on the Details button.
- Create unique users for Home Assistant and each phone to connect
(CloudMQTT does not allow two connections from the same user)
- Under manage users, fill in username, password and click add
- Under ACLs, select user, topic
#, check ‘read access’ and ‘write access’
- Copy the instance info to your configuration.yaml:
mqtt: broker: CLOUDMQTT_SERVER port: CLOUDMQTT_PORT username: CLOUDMQTT_USER password: CLOUDMQTT_PASSWORD
Home Assistant will automatically load the correct certificate if you connect to an encrypted channel of CloudMQTT (port range 20000-30000).
If you experience an error message like
Failed to connect due to exception: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed, then add
certificate: auto to your broker configuration and restart Home Assistant.
Home Assistant contains an embedded MQTT broker called HBMQTT. If you don’t have an MQTT broker, you can configure this one to be used. If configured, Home Assistant will automatically connect to it.
|Password||password set under mqtt settings|
# Example configuration.yaml entry mqtt: password: hello
As of release 0.92, the embedded broker has been marked as deprecated. This means bugs may not be fixed, and the functionality may be removed in a future release.
Before release 0.76, the embedded broker would use your API password as a password to the MQTT user. This is no longer the case.
There is an issue with the HBMQTT broker and the WebSocket connection that is causing a memory leak. If you experience this issue, consider using another broker like Mosquitto.
To use Owntracks with the internal broker a small configuration change must be made in order for the app to use MQTT protocol 3.1.1 (Protocol Level 4).
In the Owntracks preferences (Android: v1.2.3+, iOS: v9.5.1+) open Configuration Management; Find the value named
mqttProtocolLevel and set the value to
4. The application will now use MQTT 3.1.1 to connect, which is compatible with the embedded broker.
If you want to customize the settings of the embedded broker, use
embedded: and the values shown in the HBMQTT Broker configuration. This will replace the default configuration.
# Example configuration.yaml entry mqtt: embedded: # Your HBMQTT config here. Example at: # http://hbmqtt.readthedocs.org/en/latest/references/broker.html#broker-configuration