2.1.1.3 MQTT Broker
How It Works
Imagine your smart home devices (lights, thermostats, door locks, etc.) are family members who need to communicate. Instead of each device talking directly to every other device (which would be messy), they all use a central "message board" called an MQTT broker. When one device needs to send information or receive a command, it posts the message to this board, and other devices that care about that message can read it.
A Practical Example
Let's say you have:
- A smart light in your living room
- A motion sensor in your hallway
- Home Assistant (your smart home hub)
When the motion sensor detects movement, it doesn't directly tell the light to turn on. Instead, it posts a message saying "motion detected in hallway" to the central message board. Home Assistant reads this message, thinks "I have a rule that says turn on the living room light when motion is detected," and then posts a message saying "turn on living room light." The light reads this instruction and turns on.
Why It's Useful
- Devices don't need to know about each other — they just post and read messages
- It's lightweight — doesn't use much internet bandwidth or processing power
- It works reliably even if connections are slow — messages get delivered when devices reconnect
- You can automate things — Home Assistant acts as the "smart controller" that makes decisions based on the messages it receives
That's essentially what MQTT does in Home Assistant—it's the communication backbone that lets your devices talk to each other through a central hub.
Installation
Now, here we will assume that you have installed ha core via docker and not the HA OS. The HA OS mqtt installation is a lot simpler but you gain some and you loose some ;) So we will basically create another mqtt container that will serve as our mqtt broker.
Source: Setup MQTT broker in docker
The source from above explains everything pretty well but I want to add something to it that made the setup easier for me. That is simply setting the PUID and PGID to my user. By default the first user runs on PUID=PGID=1000 so we add this to the docker compose file as such
Compose file
services:
mosquitto:
container_name: mqtt
image: eclipse-mosquitto:2
environment:
- PUID=1000
- PGID=1000
ports:
# Standard MQTT protocol
- 1883:1883
# MQTT over WebSocket
- 9001:9001
volumes:
# Mount configuration directory
- ./config:/mosquitto/config
# Persist message data
- ./data:/mosquitto/data
# Persist log files
- ./log:/mosquitto/log
restart: unless-stopped
networks:
mosquitto:
networks:
mosquitto:
The frigate Integration will make use of an MQTT broker and a Frigate HA Blue print. Inside this integration it is assumed that you have installed HA core via docker compose and handle all the other containers outside of the HA environment. If you have deployed Frigate already and you want to add it to your HA instance then you need to create an MQTT container. This container can either be created inside the frigate compose file or separately. It is up to you, bu
https://www.home-assistant.io/integrations/mqtt