Configure MQTT correctly on HASSIO (version addon from v3 onwards)

2 minutes of reading
Guide purposes
  • Correctly configure theaddon MQTT for HASSIO (versions from v3 up)
  • Difficulty level: medium low
Concepts dealt with:
  • Software configuration
Software components used:
Prerequisites
Physical devices used:
GUIDE more indicated for:

All environments

Notes and disclaimer
  • qualsiasi modifica all'impianto elettrico dev'essere progettata ed effettuata da personale qualificato;
  • any changes implemented in probefore is a propersonal responsibility as well as a profirst risk and danger (the contents of the present page are purely educational);
  • any changes implemented in proprior to a device it voids the guarantee, quality approvals and certifications.
Driving review: 2.1
guide by Andker

Abstract

Where the highernamefrom the v2 version to a higher version broke the common functionnameof the MQTT server su HASSIO or has found malfunctionsnameNTI from 4.1 onwards, this guide shows how to clean up the configuration and prosee a a correct integration.

Nb This guide is suitable also for those who make the first installation / configuration of theadd-on "Mosquitto Broker" for the first time on HASSIO - simply skip to the "User creation" paragraph.

Cleaning

Uninstall 'saddon MQTT.
Go under the heading HASSIO, identify theaddon e remove it completely.

Subsequently, at the configuration Home Assistant prosee to remove the MQTT block, if present:

mqtt:
  broker: ip_del_broker

Once these two steps have been taken restart Home Assistant.

User creation

At this point, go to the item "Settings"/"users”And add a new user, calling it for example "mqtt_user. "
Save your password.

Installation add-on

At this point prosee the installation of theadd-on "Mosquitto Broker"
Once done, enter the following configuration below:

{
  "logins": [{"username": "", "password": ""}],
  "anonymous": false,
  "quiet_logs": true,
  "customize": {
    "active": true,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "require_certificate": false
}

taking care to customize, based on the credentials created in the previous step, the fields “username" and "password"(In the example they are intentionally left empty). At this point prosee save the configuration but no start theaddon.

Restart again Home Assistant.

ACL

At this point it is necessary to create the "access control list" necessary for the correct functionnameof the service.
Through "Configurator"(Or other modes, Samba, SSH or what we believe) access the route

/share/mosquitto/

and create a file called "accesscontrollist"(Without any extension) and bring back the following configuration:

user MQTT_USERNAME
topic #
user homeassistant
topic #
user hass.io
topic #
user PROPRIO_USERNAME
topic #

taking care of customizing the first and last line, entering in the first the name of the user created in the second step of this guide (replacing the string “MQTT_USERNAME") And in the penultimate the profirst username at Home Assistant (replacing the string "PROPRIO_USERNAME"). Save the files.

Always inside the folder "mosquitto", Create a new file called"acl.conf”And write the following line inside it:

acl_file /share/mosquitto/accesscontrollist

Save this second file as well e restart Home Assistant.

Start theaddon

After restarting Home Assistant, prosee to start theaddon.

HASSIO - Mosquitto Broker

Integration

Now look at the menu item "Settings"/"Integrations"
We select "configure" next to the item MQTT:

Meni Integration MQTT HASSIO

Then configure the integration as follows:

HASSIO - Mosquitto Broker - Integration HASSIO

Finally, reboot Home Assistant.

Device configuration

It is now possible provvedere to the configuration of the MQTT devices in order to make them point to the IP of Home Assistant, to the 1883 port and configuring username and password as per previously created credentials.

To this proposito reading is recommended careful was originally the guide dedicated to the configuration of the MQTT components in the profirst home automation.


Home Assistant Official LogoATTENZIONE: remember that there is on our FORUM community an ad hoc section dedicated to Home Assistant, for any doubt, question, information on the specific merit of these components.


Please comment below