MQTT setup

After finishing with Raspberry Pi Setup, next step is install MQTT Broker. To install it you can use our bash script or install it manually.

Install with script

First, to install MQTT Broker with script you need to download it:

curl -O

then start the script:


He will ask you to insert USERNAME and PASSWORD for Broker. After finishing, you can go to the next part - "Home Assistant"

Manual Installation

Alternatively, you could install all by hangs.

First, install Mosquitto Broker:

sudo apt update -y && sudo apt install mosquitto mosquitto-clients -y

Configure username (you can use any username you want) and password (you will be asked to enter the password after the command):

sudo mosquitto_passwd -c /etc/mosquitto/passwd <username>

Then edit configuration file:

sudo nano /etc/mosquitto/mosquitto.conf

Add the following at the end of the file:

listener 1883
allow_anonymous false
password_file /etc/mosquitto/passwd

Then restart the service:

sudo systemctl restart mosquitto

And check the Broker status:

systemctl status mosquitto
Broker status

Home Assistant

Alright, you made it here. The tough part is done.

With Home Assistant installed, it’s time to configure it. Here you will create the owner account of Home Assistant. This account will be an administrator and will always be able to change everything. Enter a name, username, password and click on “create account”.

create user

Next, you can enter a name for your home and set your location and unit system. Click “DETECT” to find your location and set your time zone and unit system based on that location. If you’d rather not send your location, you can set these values manually.

set location

Once you are done, click Next. In this screen, Home Assistant will show any devices that it has discovered on your network. Don’t be alarmed if you see fewer items than what is shown below; you can always manually add devices later.

additional devices

Finally, click Finish. Now you’re brought to the Home Assistant web interface. This screen will show all of your devices. So let’s get that screen filled up!

Now, you should install MQTT client. For this go to Settings -> devices & Services.

settings screen

And press ADD INTEGRATION at the right bottom corner. In the opened window find MQTT:

Press on it and set up your broker address (localhost), port (1883) and your username and password, which you've created earlier, then press submit:

Then press on three dots on MQTT integration and choose System Options and check if automatically adding new devices is enabled:

After finishing, you can go to the next article:

Method 1 (with zigbee2MQTT)

Method 2 (with SLS Gateway)

← Raspberry Pi Setup Zigbee2MQTT setup →