Related Topics
[AI Router] Installing MQTT Broker (Mosquitto)
MQTT (Message Queuing Telemetry Transport) is a lightweight messaging protocol commonly used for communication between IoT devices. In Home Assistant, MQTT is often used for automation integration. For example, when you use Frigate for video analysis (such as detecting someone entering a specific area), Frigate will send a message to Home Assistant via MQTT, which can then trigger other automations (like turning on lights or sending notifications).
MQTT Roles:
What are the roles in the MQTT protocol? Taking the scenario of integrating Frigate IP cameras with Home Assistant as an example:
- Publisher: Frigate. When Frigate detects an event (e.g., someone enters a specific area) from the IP camera feed, it publishes this event as a message to the MQTT broker.
- Subscriber: Home Assistant. It subscribes to the specific topic published by Frigate. When Home Assistant receives the message, it can trigger automations (such as turning on lights or sending notifications).
- Broker: Mosquitto. Acts as the middleman, receiving messages from Frigate and forwarding them to Home Assistant subscribers. In this example, Frigate and Home Assistant do not communicate directly, but exchange messages via the Mosquitto MQTT broker.
1. Prerequisites
- Make sure you are familiar with basic Portainer operations. You can refer to the guide Understanding Docker, Images, Containers, and Portainer with AdGuard Home Example.
- You will need to use the vi text editor for some steps. If you are not familiar, look up a basic vi tutorial online.
2. Install Mosquitto
2-1. Deploy Mosquitto using Portainer:
- Go to the [Stacks] page in Portainer and click [Add Stack].
- Name this stack mosquitto.
- In the [Web editor], paste the following configuration:

version: "3.8" services: # --- MQTT Broker (Eclipse Mosquitto) --- mosquitto: image: eclipse-mosquitto:2 container_name: mosquitto restart: unless-stopped volumes: - mosquitto_config:/mosquitto/config - mosquitto_data:/mosquitto/data - mosquitto_log:/mosquitto/log
ports: - "1883:1883" # MQTT - "9001:9001" # WebSocket volumes: mosquitto_config: mosquitto_data: mosquitto_log: |
2-2. Click the [Deploy the stack] button to complete the deployment.

3. Configure Mosquitto
3-1. Go to the [Containers] page in Portainer and find mosquitto.
3-2. Click on mosquitto to enter the container details page, then click the [Console] tab.

3-3. In the [Command] field, enter /bin/sh and click [Connect] to open the container's command line interface.

3-4. In the command line, enter the following command to create a password file:
mosquitto_passwd -c -b /mosquitto/config/passwd <username> <password>
Replace <username> and <password> with your desired username and password (use only letters and numbers, and do not start with #). To confirm the file was created: run ls /mosquitto/config to check that both mosquitto.conf and passwd exist.

3-5. Edit the Mosquitto configuration file mosquitto.conf by entering:
vi /mosquitto/config/mosquitto.conf

3-6. In the mosquitto.conf, add the following settings to specify the password file path and disable anonymous access: Press i to enter insert mode, then add the following content to the beginning or end of the file: You can use ctrl + shift + v to paste text in the vi editor.
allow_anonymous false password_file /mosquitto/config/passwd listener 1883 0.0.0.0 socket_domain ipv4 |

3-7. Press Esc , type :wq, and press Enter to save and exit the editor. (If you want to discard changes, type :q! and press Enter )

3-8. Restart the Mosquitto container to apply the settings:
- Go back to the [Containers] page in Portainer and find mosquitto.
- Click on mosquitto to enter the container details page, then click the [Restart] button.

4. Set Up MQTT Integration in Home Assistant
4-1. In Home Assistant, go to [Settings] > [Devices & Services] and click [Add Integration].
4-2. Search for and select [MQTT].

4-3. In the pop-up dialog, select MQTT and enter the following information:
- Broker: localhost or the IP address of your AI board
- Port: 1883
- Username: The username you set for Mosquitto
- Password: The password you set for Mosquitto


4-4. Once complete, you can use an MQTT client to connect to Mosquitto.

How to get the (Utility / Firmware)?
You can download the latest drivers, software, firmware and user manuals in the ASUS Download Center.
If you need more information about the ASUS Download Center, please refer this link.