Smart Home Assistant

MQTT for Home Assistant in 10 Minutes

SepehrBy Sepehr· 20 April 2026· Updated 25 October 2026· 6 min read
✓ Independent — no paid placements✓ UK-tested in real homes✓ Cited sources

This article contains affiliate links — see our disclosure policy.

Home Assistant smart home devices communicating through an MQTT broker, shown as connected nodes on a dark background

Key takeaways

  • MQTT in Home Assistant needs two parts: the Mosquitto broker add-on and the MQTT integration, both set up in about 10 minutes.
  • Home Assistant requires a broker supporting MQTT protocol version 5, which the official Mosquitto add-on provides out of the box.
  • MQTT Explorer, a free desktop app, lets you confirm the broker works by showing the homeassistant topic tree.
  • Zigbee2MQTT needs a broker, so install Mosquitto first, whereas ESPHome connects through its native API by default.
  • Auto-discovery is on by default and uses the homeassistant prefix, creating entities for Tasmota and Shelly Gen2 without YAML.
On this page[tap to expand]
Affiliate disclosure: Some links in this article are affiliate links. If you buy via one of these links, we may earn a small commission at no extra cost to you. As an Amazon Associate, we earn from qualifying purchases. This never affects our editorial decisions — see our affiliate policy.

MQTT in Home Assistant is a lightweight publish-subscribe messaging system that lets devices talk locally through a broker. To set it up, install the Mosquitto broker add-on, add the MQTT integration, then let Shelly, Tasmota and ESPHome devices auto-discover in about 10 minutes.

A proper MQTT setup is usually the fix when a Shelly relay or Tasmota socket drops out of Home Assistant whenever the Wi-Fi hiccups, and this guide covers everything from installing the broker to seeing your first device appear. Using Zigbee devices? Zigbee2MQTT builds on exactly this broker, and ESPHome is the alternative for DIY devices.

What Is MQTT and Why Does It Matter?

MQTT (Message Queuing Telemetry Transport) was originally developed for satellite telemetry in the late 1990s and later adopted as an ISO standard. At its core it is a broker-and-client model: devices publish messages to named topics, and other devices or software subscribe to those topics. The broker — Mosquitto in most home setups — sits in the middle and routes traffic.

For smart home use this model has three big advantages:

  • Lightweight. MQTT packets are tiny, so battery-powered sensors can stay asleep between readings and still push data reliably.
  • Fast. Round-trip latency from a wall switch to Home Assistant is typically under 50 ms on a local network.
  • Local. Everything stays on your LAN — no cloud dependency, no privacy concerns, no subscription fees.

If you are new to Home Assistant itself, the Home Assistant UK setup guide covers installation from scratch before you add MQTT.

What you need before you start

You need a running Home Assistant OS or Supervised install (for the add-on route), a device that supports MQTT such as a Shelly or Tasmota-flashed Sonoff, and optionally a computer for MQTT Explorer. On Container or Core installs, run Mosquitto separately and use the external-broker option in Step 2.

Step 1: Install the Mosquitto Broker Add-on

Home Assistant OS and Home Assistant Supervised users can run Mosquitto as an official add-on, which means no command-line configuration and automatic integration with the supervisor.

  1. In Home Assistant, go to Settings → Add-ons → Add-on Store.
  2. Search for Mosquitto broker and select the result published by the Home Assistant team.
  3. Click Install and wait for the download to complete.
  4. On the add-on's Info tab, enable Start on boot and Watchdog, then click Start.

Mosquitto is an open-source MQTT broker that implements MQTT protocol versions 5.0, 3.1.1, and 3.1, making it compatible with every smart home device you are likely to encounter. Home Assistant requires your broker to support MQTT protocol version 5 — the official add-on meets this requirement out of the box.

You do not need to edit the add-on's configuration YAML for a basic setup. Home Assistant will generate secure credentials automatically when you set up the integration in the next step.

Step 2: Add the MQTT Integration in Home Assistant

With the broker running, wire Home Assistant to it via the MQTT integration:

  1. Go to Settings → Devices & Services → Add Integration.
  2. Search for and select MQTT.
  3. Home Assistant detects the running Mosquitto add-on and offers to configure automatically — click Submit.
  4. If you are connecting to an external broker instead, enter the broker's IP address, port (default 1883), and your credentials manually.

Once the integration is added, a new MQTT entry appears in Devices & Services. Clicking Configure lets you adjust the discovery prefix, birth messages, and last-will settings without editing YAML.

For more must-have add-ons to pair with MQTT, see our roundup of the best Home Assistant add-ons.

Step 3: Test the Broker with MQTT Explorer

Before connecting real devices, confirm the broker is working with MQTT Explorer — a free, open-source desktop app (Windows, macOS, Linux) that shows every topic on your broker in a live tree view. The latest stable release is version 1.13.0.

  1. Download MQTT Explorer from mqtt-explorer.com.
  2. Create a new connection: enter your Home Assistant IP address as the host, port 1883, and the MQTT username and password Home Assistant generated (found in the Mosquitto add-on's Configuration tab under logins).
  3. Click Connect. If Mosquitto is healthy you will immediately see the homeassistant/ topic tree populate.

You can also publish a test message from MQTT Explorer to confirm two-way communication, then watch Home Assistant's developer tools log to verify it arrived.

Step 4: Connect Smart Home Devices via MQTT

MQTT is supported natively by three of the most popular DIY-friendly hardware families:

Shelly Devices

Modern Shelly devices (Plus and Pro ranges) have built-in MQTT support via their web UI. Open the device's interface, go to Settings → MQTT, enable MQTT, and enter your broker's IP, port, username, and password. Shelly Gen2 and later devices also support MQTT auto-discovery. The Shelly Plus 1 (available on Amazon.co.uk, prices vary by retailer) is a popular choice for converting standard light switches to smart ones without replacing the switch plate.

Sonoff Devices with Tasmota

Many Sonoff devices — including the compact Sonoff Mini R4 (Amazon.co.uk, prices vary) — can be flashed with the open-source Tasmota firmware, which adds MQTT support and removes the cloud dependency entirely. After flashing, open the Tasmota web interface, go to Configuration → Configure MQTT, and enter your broker details.

Tasmota Firmware

Tasmota runs on dozens of ESP8266 and ESP32-based devices. Once MQTT is configured, entering SetOption19 0 in the Tasmota console enables full Home Assistant auto-discovery. Tasmota version 9.2 or later is required; version 10.1.0 or later is recommended for the best experience.

MQTT Auto-Discovery in Home Assistant

MQTT auto-discovery is enabled by default when you set up the MQTT integration. Home Assistant subscribes to the homeassistant/# topic tree and listens for discovery payloads. When a compatible device comes online it publishes a small JSON config message to a topic like:

homeassistant/switch/living_room_socket/config

Home Assistant reads that payload and automatically creates the entity — no YAML, no restart. The discovery prefix (homeassistant by default) can be changed in the MQTT integration's options.

For devices to reliably appear after a Home Assistant restart, they should either publish their discovery message with the retain flag set (so the broker stores and replays it) or subscribe to the homeassistant/status birth topic and re-publish discovery payloads when they see an online message.

Tasmota, Shelly Gen2 firmware, and ESPHome (which can also talk to Home Assistant natively, without MQTT) all handle this correctly out of the box, which is why they pair so cleanly with Home Assistant's MQTT integration.

If you run Zigbee devices through Zigbee2MQTT, it publishes to this same Mosquitto broker, so the setup above is a prerequisite for it.

Troubleshooting Tips

  • Entity not appearing? Open MQTT Explorer and check whether the device is publishing to the expected topic. If the topic is missing, the device has not connected to the broker — double-check IP, port, and credentials on the device side.
  • Broker rejects connections? Confirm the Mosquitto add-on is running and that you are using the correct Home Assistant-generated credentials. The add-on log (visible in the add-on's Log tab) shows authentication errors in real time.
  • Entities disappear after restart? Ensure retained messages are enabled on the device or that it re-publishes discovery payloads on Home Assistant's birth message. In MQTT Explorer you can verify whether a topic has the retain flag set.
  • Wrong state values? Check the value_template in the entity's MQTT configuration. Tasmota uses POWER as the state key; Shelly uses a different schema — consult the device's documentation for the exact payload format.

Related: Zigbee2MQTT setup guide, Node-RED automations in Home Assistant, and IoT VLAN for Home Assistant., and see how SONOFF OpenEdge uses MQTT for local-only device control.

Buy the picks in this guide

Recommended for Home Automation

See all devices →

Frequently asked questions

Do I need a separate MQTT broker or does Home Assistant include one?

Home Assistant does not bundle an MQTT broker itself, but the official Mosquitto broker add-on can be installed in seconds via Settings → Add-ons → Add-on Store — search for 'Mosquitto broker', published by the Home Assistant team, then click Install and Start. It's an open-source broker supporting MQTT protocol versions 5.0, 3.1.1, and 3.1, and since Home Assistant requires a broker that supports MQTT protocol version 5, the official add-on meets this requirement without any manual configuration. For a basic setup you don't need to edit the add-on's configuration YAML at all, as Home Assistant generates secure credentials automatically when you add the MQTT integration. Alternatively, you can point Home Assistant at any external MQTT 5-compatible broker — such as a Mosquitto instance running on a separate server — by entering its IP address, port (default 1883), and login credentials manually during setup.

Which Shelly devices support MQTT auto-discovery?

Shelly Gen2 and Gen3 devices — including the Plus, Pro, and Mini ranges — support MQTT auto-discovery out of the box when running recent firmware, so they appear in Home Assistant automatically once connected to your broker. To enable this, open the device's web UI, go to Settings → MQTT, enable MQTT, and enter your broker's IP address, port, username, and password. The Shelly Plus 1, for example, is a popular choice for converting standard light switches to smart ones without replacing the switch plate, and it supports this same auto-discovery process. Older Gen1 Shelly devices can still publish MQTT messages, but they lack native discovery support, so you'll need to configure entities manually in Home Assistant or rely on the dedicated Shelly integration instead of MQTT discovery.

Do I need MQTT if I use Zigbee2MQTT?
Yes. Zigbee2MQTT bridges your Zigbee coordinator to an MQTT broker, and Home Assistant reads devices through the MQTT integration, so a broker such as Mosquitto is a hard requirement. You install Mosquitto once, add the MQTT integration, and Zigbee2MQTT publishes every device to it with discovery enabled. That is the only case where you need MQTT purely for Zigbee. If you use ZHA instead, Home Assistant talks to the coordinator directly and no broker is needed for Zigbee at all. The same broker can also serve Shelly, Tasmota and other devices, so installing it is rarely wasted effort, but you do not need it for ESPHome, which uses its own native API by default.
What is the difference between the MQTT broker and the MQTT integration?
The broker is the server that receives and routes messages; Mosquitto is the usual choice and runs as a Home Assistant add-on or a separate container. The integration is the Home Assistant component that connects to a broker as a client, subscribes to topics and turns discovery messages into entities. You need both: the add-on alone does nothing visible in Home Assistant, and the integration alone has nothing to connect to. If you already run an external broker elsewhere on your network, skip the add-on and point the integration at that broker's IP address, port 1883 and credentials instead. Devices, Zigbee2MQTT and Tasmota all talk to the broker, not to the integration directly.
How do I connect a device to MQTT in Home Assistant?
Install Mosquitto and add the MQTT integration first, then open the device's own settings and enter the broker details: your Home Assistant IP address, port 1883, and the MQTT username and password. On Shelly this is Settings, then MQTT; on Tasmota it is Configuration, then Configure MQTT. With discovery enabled, the device publishes a config message and appears under the MQTT integration automatically, with no YAML or restart. If nothing appears, open MQTT Explorer and check the device is publishing under the homeassistant topic prefix, and confirm the credentials match. Tasmota users may also need to turn on discovery with SetOption19 in the console, as covered above.
Is MQTT secure for home use?
MQTT is secure enough for home use when you keep the broker on your local network and require a username and password, which the Home Assistant Mosquitto add-on does by default. Traffic on port 1883 is unencrypted, so anyone on the same network could read it, which is why you should avoid exposing the broker to the internet. If you need remote access, use a VPN or Home Assistant Cloud rather than port forwarding. Placing IoT devices on a separate VLAN reduces exposure further, and Mosquitto also supports TLS on port 8883 if you want encrypted connections between devices and the broker. Use a unique password for each client where practical.
Can I use MQTT with Home Assistant Cloud (Nabu Casa)?
Yes. MQTT runs entirely on your local network and Home Assistant Cloud only provides remote access to the Home Assistant interface, so the two work side by side without extra configuration. Your devices keep talking to the local Mosquitto broker as normal, and entities created through MQTT show up in the Nabu Casa remote UI like any other. What Cloud does not do is expose your broker itself to the internet, so external MQTT clients cannot connect through it. If you need a device away from home to publish to your broker, use a VPN or a separately secured broker. For ordinary local devices there is nothing to change.

Sources

Sources verified 2026-06-19

  1. Home Assistant — MQTT Integration
  2. Eclipse Mosquitto — Eclipse Mosquitto: An open source MQTT broker
  3. Tasmota — Home Assistant — Tasmota Documentation
›How we researched this

Claims in this article are checked against primary sources — manufacturer specifications, official documentation, Which? research, Ofgem guidance, or gov.uk — rather than forum threads or video reviews. Where the author has direct hands-on experience with a product (most Home Assistant, Zigbee, and home-networking gear is running in his own homelab), that is stated explicitly in the text.

For categories outside that personal setup — such as boilers, heat pumps, and other areas that are traditionally a heating engineer's domain — verdicts are built from cross-referenced manufacturer data, published lab results, and vetted expert and owner reviews rather than a claim of personal hands-on testing. See the editorial policy for the full methodology.

Sepehr

Written by

Sepehr

10+ years hands-on with Home Assistant & networking · Research-backed elsewhere · No brand deals

Smart home specialist with 10+ years running a self-hosted Home Assistant setup — Zigbee2MQTT, Frigate NVR, and local-first automations. Independent coverage for UK homes, no brand deals.

LinkedIn →

Citing this page? Please use a dofollow link back to the original article — it helps us keep the data on this page accurate and up to date.

Related reading