Hi there,
i have some trouble setting up an mqtt broker. (Actually, this is part of my trouble with setting up the Tasmota integration…)
I use the integration as described here: MQTT Broker - Home Assistant
But every time i try to configure it, it says ‘connection failed’.
For testing i try test.mosquitto.org.
I tried various ports, but it won´t work out.
Do you have any suggestions? Thanks,
Are you using mosquito? if not I would suggest you do as in the 4th line in the page you linked. If you are I can’t really help without knowing more about how it is setup.
I wanted to test it with the online-broker of test.mosquitto.org first. Before digging into just another integration…
It will be difficult to connect to an external MQTT broker even for testing, as you then have to deal with port forwarding, firewall, and networking issues. You will spend more time trouble shooting and configuring external access for it then you would just installing mosquito somewhere locally.
Mosquitto is fairly light weight and installs quickly. How are you running Home Assistant? if HAOS, ideally use the Mosquitto addon - addons/DOCS.md at 174f8e66d0eaa26f01f528beacbde0bd111b711c · home-assistant/addons · GitHub which is the recommended method.
Other options include running Mosquitto on the “bare metal” of a machine (that’s how mine is on Ubuntu), or Mosquitto in docker -
installed mosquitto now, but still no luck. I think i should use “core-mosquitto” as a hostname, but it can´t connect. I also tried localhost or the ip adresses.
If using the addon, in the MQTT integration it should be “core-mosquitto” as host, 1883 as port, but also be sure to configure your MQTT username and password.
See this documentation for configuration
Or this video is helpful (just jump to around 5 minutes in)
Been there, done that, but for me it already fails at around 6:40
If i click on “Configure”, the MQTT integration immediately asks for the Server, Port and credentials.
And whatever i enter, it will fail.
Unfortunately you did not answer:
If you run HA Supervised on Debian make sure you have the file:
/etc/mosquitto/conf.d/mosquitto.conf
with the content of:
allow_anonymous false
password_file /etc/mosquitto/conf.d/pwfile
port 1883
Also make sure you have run:
sudo mosquitto_passwd -c /etc/mosquitto/conf.d/pwfile whateverusername
Make a note about the username and password you chose.
Now run:
sudo service mosquitto restart
Also make sure you have nothing mqtt-related inside
/usr/share/hassio/homeassistant/configuration.yaml
because configuration of MQTT is done through the HA Integration when first added to HA.
Sorry, i was a little frustrated yesterday.
This is my system so far:
System Health
version | core-2022.4.7 |
---|---|
installation_type | Home Assistant OS |
dev | false |
hassio | true |
docker | true |
user | root |
virtualenv | false |
python_version | 3.9.9 |
os_name | Linux |
os_version | 5.10.103-v7 |
arch | armv7l |
timezone | Europe/Berlin |
Home Assistant Supervisor
host_os | Home Assistant OS 7.6 |
---|---|
update_channel | stable |
supervisor_version | supervisor-2022.05.0 |
docker_version | 20.10.9 |
disk_total | 109.3 GB |
disk_used | 10.3 GB |
healthy | true |
supported | true |
board | rpi3 |
supervisor_api | ok |
version_api | ok |
installed_addons | Custom deps deployment (1.3.1), File editor (5.3.3), Samba share (9.6.1), deCONZ (6.13.0), PSA Car Controller (v2.6.0), Terminal & SSH (9.4.0), Zigbee2mqtt (1.25.1-1), Mosquitto broker (6.1.1) |
This was very helpful! There was a setting, remaining from a former try. After i deleted it, i was able to configure the MQTT integration like shown in the video. Thank you!
core-mosquitto
worked, do you have any idea why is it not mentioned anywhere in the docs?