Problems getting HA to work with password protected MQTT broker

Hi

It seems that HA won’t play nice with a password protected MQTT broker.
Here’s my setup:

System Health

version: core-2021.11.5
installation_type: Home Assistant Core
dev: false
hassio: false
docker: false
user: homeassistant
virtualenv: true
python_version: 3.9.2
os_name: Linux
os_version: 5.10.63-v7+
arch: armv7l
timezone: ****

When I add a password to mqtt like so:

sudo mosquitto_passwd -c /etc/mosquitto/password_file ha

then add these lines to mosquitto.conf:

listener 1883
password_file /etc/mosquitto/password_file

I can test and it works from command line:

pi@raspberrypi:/etc/mosquitto $ mosquitto_pub -t topic -m testmessage
Connection error: Connection Refused: not authorised.
Error: The connection was refused.
pi@raspberrypi:/etc/mosquitto $ mosquitto_pub -t topic -m testmessage -u ha -P "password"
...

pi@raspberrypi:~ $ mosquitto_sub -t topic
Connection error: Connection Refused: not authorised.
pi@raspberrypi:~ $ mosquitto_sub -t topic -u ha -P "password"
testmessage

I then tried to get it working with HA, editing my configuration.yaml:

mqtt:
  discovery: true
  broker: localhost
  port: 1883
  birth_message:
    topic: 'hass/status'
    payload: 'online'
  will_message:
    topic: 'hass/status'
    payload: 'offline'
  username: ha
  password: 'password'

The authentication step is happening, because if put in the wrong password it will refuse to connect. So there are no errors but my devices are not available.

Nov 23 12:06:11 raspberrypi hass[28238]: 2021-11-23 12:06:11 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to etrv/Frontroom/state, mid: 43
Nov 23 12:06:11 raspberrypi hass[28238]: 2021-11-23 12:06:11 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on etrv/state (retained): b'offline'
Nov 23 12:06:11 raspberrypi hass[28238]: 2021-11-23 12:06:11 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on etrv/state (retained): b'offline'
Nov 23 12:06:11 raspberrypi hass[28238]: 2021-11-23 12:06:11 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to etrv/Frontroom/state, mid: 44
Nov 23 12:06:11 raspberrypi hass[28238]: 2021-11-23 12:06:11 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on etrv/state (retained): b'offline'
Nov 23 12:06:11 raspberrypi hass[28238]: 2021-11-23 12:06:11 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to etrv/Frontroom/state, mid: 45
Nov 23 12:06:11 raspberrypi hass[28238]: 2021-11-23 12:06:11 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on etrv/state (retained): b'offline'
Nov 23 12:06:11 raspberrypi hass[28238]: 2021-11-23 12:06:11 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to etrv/Frontroom/state, mid: 46
Nov 23 12:06:11 raspberrypi hass[28238]: 2021-11-23 12:06:11 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to etrv/Frontroom/state, mid: 47
Nov 23 12:06:13 raspberrypi hass[28238]: 2021-11-23 12:06:13 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on hass/status: 'online', mid: 48

I am using etrv2mqtt to bridge my danfoss thermostats, and it all works fine with no auth. Any ideas?

Did you configure etrv2mqtt to use username and password as well?

Do you see something posted in the topics when you use a tool such as MQTT explorer?

doh! that’s obvious. Worked once I added the credentials to etrv2mqtt config. thanks