Home Assistant MQTT Bridge — Complete Guide
In this tutorial, you'll learn about Home Assistant MQTT Bridge. We cover key concepts, practical examples, and best practices.
Hook
You have an MQTT broker running (Mosquitto) and devices publishing to topics. Home Assistant is subscribed to those topics, but the entities show "Unavailable." The debugger shows MQTT messages arriving at the broker, but Home Assistant does not see them.
The Wrong Way
Running multiple MQTT brokers in parallel without a bridge between them creates silos — devices on one broker are invisible to clients on another.
# BAD: Two separate MQTT brokers with no bridge
# Broker 1: mosquitto (port 1883) for sensors
# Broker 2: mosquitto (port 1884) for Home Assistant
Sensor publishes to 1883
Home Assistant subscribes to 1884
Topic never reaches HA — different brokers
Two unrelated brokers cannot share messages without a bridge.
The Right Way
Use a single broker or configure an MQTT bridge between two brokers.
# 1. Verify Home Assistant's MQTT config
cat /config/configuration.yaml | grep -A5 "mqtt:"
mqtt:
broker: 192.168.1.50
port: 1883
username: hass
password: securepassword
# 2. Check if Home Assistant can reach the broker
docker exec hass mosquitto_sub -h 192.168.1.50 -p 1883 -u hass -P securepassword -t "#" -C 1
(no output — timeout or auth error)
If the test fails, check broker authentication:
# 3. Test with telnet
echo | nc -w 2 192.168.1.50 1883
(empty — port is open but broker may need auth)
# 4. Configure Home Assistant with the correct credentials
# Web UI → Settings → Devices & Services → MQTT → Configure
# 5. Restart Mosquitto and Home Assistant
docker restart mosquitto hass
[INFO] MQTT: Connected to broker 192.168.1.50:1883
[INFO] MQTT: Subscribed to topic homeassistant/#
If you need two brokers, set up a bridge in Mosquitto:
# /etc/mosquitto/conf.d/bridge.conf
connection hass-bridge
address 192.168.1.51:1883
topic # both
remote_username hass
remote_password securepassword
Prevention
- Use a single MQTT broker for all your IoT devices and Home Assistant.
- If you need multiple brokers, configure proper bridging.
- Test MQTT messages with
mosquitto_subandmosquitto_pubbefore configuring HA. - Set
discovery: truein Home Assistant's MQTT config for auto-discovery. - Monitor MQTT traffic with
mosquitto_sub -t "#" -vduring troubleshooting.
Common Mistakes with assistant mqtt bridge
- Using
returnto exit a function early instead of wrapping a pure value in the monad - Mixing let bindings with <- bindings in do notation, producing type errors
- Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
These mistakes appear frequently in real-world HOME code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
DodaTech — MQTT that speaks Home Assistant's language.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro