Mosquitto Setup unter openHABian

OpenHAB CLI Tool

Just as Node-RED, Mosquitto (our Broker for the MQTT Protocol) can be installed through the OpenHAB-CLI. First, login to your Pi via SSH (Windows user can use the free Terminal from Mobaterm and open the CLI tool with sudo openhabian-config. Use your user password (on openHABian this is openhabian by default) to execute the program, choose Optional Components and select Mosquitto:

openHABian Home Automation

Choose a User Authentication for the MQTT Server (make sure to write down the password choose here - it has to be set in our OpenHAB MQTT Configuration (inside mqtt.cfg) as well as in Node-RED (inside all your MQTT-Nodes in every Node-RED flow: Node Property > MQTT Server > Security).) - see Troubleshooting below.

openHABian Home Automation

And you are done!

openHABian Home Automation


You set up everything but sending a message over MQTT from your Node-RED Dashboard or the OpenHAB Basic-UI does not do anything!

We used the OpenHAB CLI to add a MQTT Authentication to the Mosquitto Server - the default user is openhabian and the password you have chosen yourself (e.g. mymqttpassword, s. below). That information has to be added to /etc/openhab2/services/mqtt.cfg to enable OpenHAB to send messages through your MQTT server:

openHABian Home Automation

You can edit the file by using Vim by typing sudo vim "/etc/openhab2/services/mqtt.cfg". Press the letter i to edit the file, add your mosquitto.user and mosquitto.pwd, then press ESC and type :wq! to save and close the file:


To add the Authentication to Node-RED double-click your MQTT Nodes and edit the MQTT Server information:

openHABian Home Automation

openHABian Home Automation

openHABian Home Automation

Manual Installation (optional)

If you are not using the openHABian Linux distro on your Pi, you can install or upgrade Mosquitto following the regular Setup Guide.

To use the new repository, you should first import the repository package signing key:

sudo apt-key add mosquitto-repo.gpg.key

Then make the repository available to apt:

cd /etc/apt/sources.list.d/

Then one of the following, depending on which version of debian you are using:

sudo wget
sudo wget

Then update apt information:

apt-get update

And install the package:

apt-get install mosquitto

Alternative Mosquitto Downloads can be found here