Is there current documentation for setting up Mosquitto on an HA docker image?

password_file /mosquitto/config/pwfile
listener 1883 192.168.100.1  

This is what’s in my config file. Don’t know what to put since the documentation talks about getting an add-on and there’s nothin’ about that in my HA menus that I can find. All the instructions I can find gloss over the techy bits and reference this nonexistent add-on that automagically configures it.

I tried mosquitto on openwrt but that package is borked, there’s no mosquitto_passwd utility in what it downloads. So I set it up as a docker image. It connects on 1883 and then immediately errors out. Says look in the logs but can’t find 'em inside the HA docker image.

I saw another thread on here about getting the .conf file out of one of the appliances, but the person who posted it owns one. Any suggestions on what else should go in that file? I can get the mqtt integration to login to my ip address on that port but then error. I’m quite certain the config I posted is incomplete, what am I missing to get it bare-bones running? I have a username and password setup.

Do I need to worry about creating a user for mqtt to run as since I think the service is running as root inside the container?

Have added a couple lines to the config file.

allow_anonymous false
persistence true
password_file /mosquitto/config/pwfile
listener 1883 192.168.100.1 

This is still the result after it logs in. Not sure what to do next.

Looks like it’s not running as root and the passwd file is owned by the mosquitto user and group.

Do I need to go in and edit the underlying YAML entry?

Did you create user password in mosquitto?

To do this in mosquitto docker you must connect command line of docker container

Yes I did.

Did you hash password file per instructions at my previous post link?

EDIT

In dont run mosquitto container as root. Permission issues possible but I believe root should be able to access passwd file owned by non root user

I was thinking maybe you just added password to file but did not run command that hashes it for use by mosquitto. That would cause your current issue. You can bypass use by setting “allow_anonymous” to true in config file I believe. This would at least allow your testing

Yeah the password file has been hashed, I mentioned the absence of mosquitto_passwd in the openwrt package for mosquitto in my original post. That’s why I’m messing around with mqtt in a docker container, it’s the only practical one I can get that’s intact. I definitely ran it to create that file.

Current config is

allow_anonymous false
persistence true
password_file /mosquitto/config/pwfile
http_dir /mosquitto/http_dir
user mosquitto
listener 1883
max_connections -1
protocol websockets

It serves up empty response bodies. mosquitto 2.0.20

allow_anonymous false
persistence true
password_file /mosquitto/config/pwfile
http_dir /mosquitto/http_dir
user mosquitto
listener 1883
max_connections -1
protocol websockets
persistence true
persistence_file mosquitto.db
persistence_location /mosquitto/data

It starts error free now

stderr: 1736429192: mosquitto version 2.0.20 terminating
stderr: 1736429192: Saving in-memory database to /mosquitto/data/mosquitto.db.
stderr: 1736429192: mosquitto version 2.0.20 starting
stderr: 1736429192: Config loaded from /mosquitto/config/mosquitto.conf.
stderr: 1736429192: Opening websockets listen socket on port 1883.
stderr: 1736429192: mosquitto version 2.0.20 running

But still empty response bodies.

Anybody got the mosquitto.conf file off one of the appliances???

my config below. all other items were commented out. It was too long to post

listener 1883
allow_anonymous false
password_file /mosquitto/config/pwfile
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log

I also suggest you add “allow_anonymous true” to ensure user/pass is not your issue.

are you running HA in docker?

mosquitto doesnt have a frontend webUI.

Add-ons are supported by:

  • Home Assistant OS
  • Home Assistant Supervised

They’re not supported by:

  • Home Assistant Container
  • Home Assistant Core

If you have chosen to use the Home Assistant Container installation method, it doesn’t support Add-ons so that’s why it doesn’t appear in any menus.

Home Assistant Container is considered to be an advanced installation method. It is assumed the user has chosen this method because they are familiar with Docker and want fine-grained control over all containers they install on their system.

Installing, configuring, upgrading, and maintaining docker containers is beyond the scope of Home Assistant’s documentation so that’s why there’s only minimal information. As you have already discovered, the community forum covers a broader range of topics, including docker administration.

It’s important to distinguish between Home Assistant’s MQTT integration, which effectively makes Home Assistant an MQTT client, and whatever other means is used (docker or “bare-metal”) to install an MQTT broker. So whereas all installation methods support the MQTT integration, only two support the MQTT Broker Add-on.

2 Likes

Yeah I’ve discovered that it doesn’t have a front-end UI. I think it’s a communications issue between docker containers at this point. I can get to the thing on port 8080 authenticated with MQTT explorer. I tried port 8080 from the web UI which would be trying docker-to-docker and it didn’t work. So I might have it working there’s just a firewall stopping it from getting between the containers. They’re all host network for what it’s worth. I’m going to look again and see if it’s getting another IP address on 192.168.100.x/24.

It’s docker running on Open WRT for what it’s worth.

At this point you need to check HA’s (core) log, to see what the problem is.

1 Like

Hi,
to integrate mosquitto in my HA Docker setup I followed this blog:

2 Likes

This was my second guess after user/pass issue

You cannon connect docker to docker on same host machine using your lan.

Give the docker container a hostname. Connect using the hostname and docker network. Hostname ensure the connection survives recreating container and ip changes

Both containers most use default bridge network or you can create one form them to use

1 Like

I have all of it working on the host network, none of my docker images know anything about ports.

I followed netdiver’s instructions, restarted docker, worked through the issues that suddenly cropped up after a black start and it worked from mqtt explorer.

Thank you, my first presence sensor is attached.

I felt like I had to do docker because the supply chain for the HA devices looks a little blurry to me, and correct me if I’m wrong but it’s the first product the group has launched. There are several sellers on Alibaba which led me to question - will I get an official device from a US seller, or did that US reseller source this device from the random Alibaba sellers I see in the wild.

I’m not trying to get any unwanted extras. If I hadn’t seen them on Alibaba I might have ordered from a reseller and not have had to ask.

Anyway I fully understand the difference now and have it working.

Maybe I have misunderstood your post but I don’t understand how Nabu Casa’s supply chain issues are related to the choice of installation method.

Home Assistant OS can be installed on any suitable hardware, not just the hardware Nabu Casa sells.

I’ve been running Home Assistant Supervised on Debian on a 14 year old Dell laptop (used to have it running on an RPI 3) for several years now.

I experimented briefly with Home Assistant Container on another old laptop but decided that I preferred to use Add-ons so chose Home Assistant Supervised. My next upgrade will be to a late model mini pc running Proxmox with Home Assistant OS.

FWIW, I think Nabu Casa has shipped three separate versions over the past few years: first Blue, then Amber (renamed Yellow), and now Green.

2 Likes