Setting up MQTT in Home Assistant Container

I’m running Home Assistant Container in Docker, alongside Portainer. I’ve actually downloaded Eclipse Mosquitto as its own container as well, but I’m having trouble getting MQTT set up in Home Assistant. The traditional way is to use Supervisor / Addons to set up MQTT, but Home Assistant Container does not have this option. Has anyone have a workaround for this?

Use the integration

HA >> settings >> devices and services >> add integration >> mqtt

When connecting docker containers I use the host name of container as this prevents issues if docker decides to change the docker IP. By using this method you only need expose ports if connecting outside docker network

You can use portainer to set hostame if you did not do so during container creation

EDIT

If it is not clear, the integration will connect to the mosquitto container you setup.

im assuming your looking for a specific instruction how to setup mqtt (mosquitto) server. In that case you can just follow the video below how to setup a new mqtt server via docker and add it up to home assistant.

Run Your own LOCAL MQTT broker to control your IoT devices in Home Assistant - YouTube

I used to have HAOS installed but ended up moving my install into an all container install because it’s actually much simpler to update, manage, rollback and recover if something oopsie happens.

1 Like

You could also follow this instruction
MQTT HA
HAOS and Docker set-up explaned.

Cheers,
Mike

Thanks very much for this. I was able to successfully setup MQTT as a docker container, and get it set up in Home Assistant.

It seems like if you were to do this with Supervisor, it would automatically create an entity card in your Overview. But since I’m not using Supervisor, I’m searching around for a way to display an MQTT message in Home Assistant. Any ideas on home to manually setup an entity or a button or something for the Overview home page to acknowledge when Home Assistant receives an MQTT notification? So far I’m not having any luck.

You can show it as persistent message

This thread may have some examples

Thanks very much for the response. I’ve been researching persistent messages, blueprints, automations. I can’t figure out how to edit configuration.yaml with Home Assistant Container, or set up hass-configurator-docker to edit configuration.yaml. I’m told the “MQTT Integration” should to much of the heavy lifting, but I have no idea leverage it.

SSH onto machine and edit the file

There are more gui friendly methods but it depends on the OS.

I just tried to install MQTT today doing exactly this in a docker container but instead of installing I get this “Please enter the connection information of your MQTT broker.”

I don’t get Home Assistant. I just want to get frigate installed and after reading all the document pages, wiki etc I can’t in a VM of HAOS, Docker Container nor an Ubuntu install. The closest I’ve gotten is a VM of HAOS but EVERYTHING I try from Zigbee to Frigate just hangs.

I have the exact same issue. I’m a noob and i dont understand… When i try to install MQTT broker in HA it ask me a hostname, a user and a password. :man_facepalming:
I’m using a docker latest version of HA installed in a Synology container.
As i understand MQTT is built-in HA and should be a user and a password written in a file, but where? or we can install from the UI? Should i install an separate image in my docker? …
What should i do? Help pls.

Assuming you have used mosquitto and left the defaults no username or password, you can use any HA user/password combination to connect.

This is documented in the configuration page of Mosquitto but it is not very understandable the first time you use the broker.

I never install mqtt before… no mosquito at all… and what hostname should i try?

Then when you add the integration just select the first option. You will not be asked anything.

image

You need to go to the add-on and add Mosquitto. Just start the add-on and add the integration, nothing else to do!

You mean add integration button in settings? because i dont see any add-ons menu. There is no mosquito available in all integrations. look

maybe its because i run a docker version of HA on a Synology container?

If you run docker you just intstall an MQTT broker in a seperate docker container then setup “MQTT” integration in devices and services.

Docker requires docker network understanding but generally it is not hard and should be expected if you venture into server management

Yes add-ons not available in Docker I think. In such case you need to install an MQTT broker in your Docker stack and the connect it to HA.

Ok, thank you both, i will try that.