Welcome to the A-Z Series: M is for MQTT
In today’s episode of our Home Assistant A-Z Series, we’re diving into a topic that works quietly in the background and yet is absolutely essential: MQTT! It’s the invisible glue that brings almost any device into your smart home. Without MQTT, my smart home would grind to a halt in many places – but why is that?
Today I’ll explain in simple terms (promise: no complicated technical jargon!) what MQTT is, why it matters so much, and how I’ve integrated 52 devices with it in my Home Assistant setup.
What Is MQTT? 30 Seconds of Theory, Jargon-Free
Let me explain MQTT so simply that anyone can understand it – even if you’re not deeply technical.
The Problem Without MQTT
Normally, Home Assistant has to talk directly to every device. That means:
- Home Assistant needs to know how to control the device
- What data the device sends
- In what units the data arrives
- What interface the device uses
For every single device, Home Assistant needs its own dedicated integration. That’s a lot of work and limits the number of supported devices.
The Solution: MQTT as a Middleman
MQTT steps in between and simplifies everything dramatically:
- Home Assistant only needs to know how to read from an MQTT server
- The device only needs to know how to post its data to MQTT
- The MQTT Broker (server) mediates between the two
The Brilliant Advantage
This has a huge advantage:
✅ The device can support MQTT and doesn’t care whether you’re using Home Assistant, OpenHAB, or any other smart home solution
✅ Home Assistant doesn’t care which device you have – as long as it speaks MQTT
MQTT is therefore a supremely universal solution for integrating as many devices as possible into Home Assistant, without Home Assistant needing to explicitly support each device!
In the video, I explain this even more clearly with a diagram!
A Live Look: 52 Devices via MQTT in My Smart Home
Enough theory! Let’s look at a real smart home and see everything I’ve integrated with MQTT.
In my MQTT integration in Home Assistant, I can see: 52 devices connected via MQTT. That’s more than half of all my devices! Without MQTT, my smart home would be capable of considerably less.
Let’s look at some concrete examples:
Aqara Motion Sensors via Zigbee2MQTT
I have several Aqara motion sensors distributed throughout my smart home – in the hallway, bathroom, storage room, and other areas.
How are they integrated?
- The sensors speak Zigbee (a wireless protocol)
- I use Zigbee2MQTT – the universal gateway for Zigbee devices
- Zigbee2MQTT translates Zigbee signals into MQTT messages
- Home Assistant reads these MQTT messages
The brilliant part: Zigbee2MQTT supports hundreds of different Zigbee devices from a wide variety of manufacturers. Set it up once, and everything works through the same pipeline!
In the video you can see the motion sensors live in the dashboard!
Philips Hue Lights via Zigbee2MQTT
My Philips Hue lights also run via MQTT – likewise through Zigbee2MQTT!
Why not the official Philips Hue Bridge?
Good question! The Hue Bridge would certainly work too, but:
✅ With Zigbee2MQTT I skip the need for an extra bridge ✅ Everything runs through the same infrastructure (one Zigbee stick) ✅ Completely local – no Philips cloud required ✅ Cheaper (no expensive Hue Bridge needed)
Hue lights also speak Zigbee, so they can communicate with Zigbee2MQTT just as easily as the Aqara sensors!
Where I use Hue lights:
- Bedroom (for the wake-up light)
- Terrace (for evening lighting)
In the video I’ll show you what the Hue lights look like in the MQTT dashboard!
Sonoff Devices with TASMOTA Firmware
Another great example: Sonoff devices. These are smart relays and sensors – similar to Shelly modules.
My configuration:
I’ve flashed most of my Sonoff devices with TASMOTA firmware. This is an open-source, alternative firmware that:
- ✅ Works completely locally (no cloud)
- ✅ Natively supports MQTT
- ✅ Is far more flexible than the stock firmware
- ✅ Is more secure (open source, no backdoors)
The Sonoff devices communicate via Wi-Fi (not Zigbee!) and send their data directly to the MQTT Broker.
Examples in my setup:
- Smart plugs
- Relays for light control
- Temperature sensors
In the video I go into more detail on TASMOTA and show you what the devices look like!
Xiaomi Light Sensors for Automations
I have two Xiaomi light sensors mounted on the outside of the building. They continuously measure brightness and help me with various automations.
What I use them for:
- Automatic lighting (e.g., terrace lights at dusk)
- Blind control (automatically closing when the sun is intense)
- Energy management (cloud cover = lower PV output)
These sensors also speak Zigbee and run via Zigbee2MQTT through MQTT into Home Assistant.
In the video I show you the live sensor readings!
Wallbox via EVCC
A particularly cool example: my wallbox for the EV is also integrated via MQTT!
How does that work?
I use EVCC (Electric Vehicle Charge Controller) – intelligent software for managing the wallbox. EVCC can:
- PV surplus charging (only charge when the solar system produces enough power)
- Use dynamic electricity prices (charge when power is cheap)
- Monitor all values (charging power, battery level, costs)
EVCC publishes all these values to MQTT, making them available in Home Assistant.
What I get via MQTT:
- Current charging power (in kW)
- Total energy meter (total amount charged)
- Current charging price (for dynamic tariffs)
- Grid price and electricity rates
- EV state of charge (in %)
All this data can be used in automations or displayed on dashboards!
More on EVCC is available in my dedicated video – link in the video and description above!
In the video I show you the wallbox entities live in the MQTT dashboard!
Why MQTT Is So Important
After all these examples, it’s clear: MQTT is the backbone of my smart home!
The Advantages at a Glance
- Universal: Almost any device can speak MQTT
- Vendor-independent: Whether Aqara, Philips, Sonoff, or Xiaomi – they all use MQTT
- Protocol-agnostic: Zigbee, Wi-Fi, even Ethernet – everything ends up at MQTT
- Future-proof: New device? If it speaks MQTT, it works
- Local: No cloud required, everything stays on your own network
In the video I go even deeper into these advantages!
Installation: How to Get MQTT Into Home Assistant
Convinced and ready to use MQTT? No problem – the installation is surprisingly easy!
Option 1: Home Assistant OS (recommended for beginners)
If you’re running Home Assistant OS, MQTT is just one click away:
Step 1: Go to Settings → Add-ons
Step 2: Search for “Mosquitto broker” (this is the MQTT server)
Step 3: Install the add-on and start it
Step 4: Home Assistant automatically detects the Broker and suggests the integration
That’s it! No complex configuration needed. The Broker is running and ready to use immediately.
Option 2: Home Assistant Core / Docker
If you run Home Assistant Core and manage everything via Docker, you can start the Mosquitto Broker as a separate container:
Docker Compose example:
|
|
Then add the MQTT integration in Home Assistant and provide the IP address and port (1883) of the Mosquitto container.
In the video I show you both installation methods!
Configuration: Almost None Required!
The beauty of MQTT: it requires almost no configuration!
- The default port (1883) works out of the box
- No complex settings
- Ready to use immediately
Of course, for added security you can also:
- Set up a username and password
- Enable TLS encryption
- Configure Access Control Lists (ACLs)
But for getting started, the default configuration is perfectly sufficient!
Connecting Devices to MQTT
You now have an MQTT Broker running – but how do devices connect to it?
Zigbee Devices: Zigbee2MQTT
For all Zigbee devices, I recommend Zigbee2MQTT:
What you need:
- A Zigbee USB stick (e.g., ConBee II, Sonoff Zigbee 3.0)
- The Zigbee2MQTT software (as an add-on or Docker container)
Setup:
- Plug in the Zigbee stick
- Install Zigbee2MQTT
- Enter the MQTT Broker details (usually done automatically)
- Pair devices (put them into pairing mode)
Done! All Zigbee devices appear automatically in Home Assistant.
Wi-Fi Devices: Native MQTT Support or TASMOTA
Some devices (e.g., Shelly, ESPHome devices) natively support MQTT. Simply enter the MQTT Broker IP in their settings – done!
Other devices (e.g., Sonoff) can be flashed with TASMOTA and then have MQTT enabled.
In the video I walk through concrete examples!
Software Integrations: EVCC and Others
Many software tools like EVCC can publish their data to MQTT. In the respective configuration, you enable MQTT and provide the Broker details – and the data flows straight into Home Assistant!
Creative Use Cases for MQTT
Beyond plain device data, you can also use MQTT for creative purposes:
Build Your Own Sensors
With ESPHome or TASMOTA you can build custom sensors and integrate them via MQTT:
- Temperature and humidity sensors in the garden
- Water level sensors for plants or cisterns
- Door contacts in unusual locations
- PIR sensors for motion detection
Exchange Data Between Systems
MQTT is perfect for sharing data between different systems:
- Home Assistant → Node-RED → MQTT
- MQTT → Grafana (for beautiful dashboards)
- MQTT → InfluxDB (for long-term data analysis)
Trigger External Automations
You can trigger external tools via MQTT messages:
- Start the 3D printer when the solar system has enough surplus
- Activate the irrigation system when soil moisture is low
- Arm security systems based on presence
The possibilities are endless!
Pitfalls and Tips
To wrap up, here are a few important tips from my own experience:
Tip 1: Plan Your Topic Structure Early
MQTT uses Topics for organization. Think through a sensible hierarchy from the start:
|
|
Not:
|
|
A clear structure will save you a lot of headaches later!
Tip 2: Use Retained Messages
For status values, you should enable Retained Messages. This way the Broker stores the last known value – even if a client restarts.
Tip 3: Understand Quality of Service (QoS)
MQTT defines three QoS levels:
- QoS 0: Fire and forget (fast, but unreliable)
- QoS 1: Delivered at least once
- QoS 2: Delivered exactly once
For smart home purposes, QoS 1 is usually sufficient.
Tip 4: Use Discovery
Many tools (e.g., Zigbee2MQTT, TASMOTA) support MQTT Discovery. This means devices register themselves automatically with Home Assistant – no manual configuration needed!
In the video I go into these tips in more detail!
Conclusion: MQTT Is Indispensable
After all of this, it’s clear: MQTT is absolutely indispensable for my smart home!
What I wouldn’t have without MQTT:
- 52 fewer devices
- No Zigbee devices
- No flexible wallbox integration
- Far fewer options for custom projects
MQTT makes a smart home flexible, open, and future-proof. It’s one of the reasons I value Home Assistant so highly!
Make sure to watch the video – there you’ll see everything in action live!
Your Experiences?
What do you integrate with MQTT?
Let me know in the comments:
- Which devices do you use over MQTT?
- Do you have creative use cases?
- Are you using Zigbee2MQTT or other gateways?
- What questions do you have about MQTT?
Further Reading and Videos
If you’re interested in MQTT and related topics:
- EVCC: Smart EV Charging – How I connect the wallbox via MQTT
- Understanding Entities – How MQTT devices appear as entities
- Making Your Dishwasher Smart – With MQTT-capable smart plugs
Find the complete A-Z Series here: Home Assistant A-Z Overview