Mosquito MQTT update v3 broke my hassio

The official core-mosquitto addon is required.
The integration handles discovering it and configuring for it.

ok cool, thanks for the clarification

There’s is not much in the log:

1542147406: Saving in-memory database to /data/mosquitto.db.
1542149207: Saving in-memory database to /data/mosquitto.db.
1542151008: Saving in-memory database to /data/mosquitto.db.
1542152809: Saving in-memory database to /data/mosquitto.db.
1542154611: Saving in-memory database to /data/mosquitto.db.
1542156412: Saving in-memory database to /data/mosquitto.db.
1542158213: Saving in-memory database to /data/mosquitto.db.
1542160014: Saving in-memory database to /data/mosquitto.db.

I think i figured it out.
MQTT integration - by default - is set up with “homeassistant” username, regardless of MQTT addon config. The key is to remove that integration and create a new one, but this time instead of adding “autodiscovered” MQTT integration, user must scroll down and set up a new one from scratch - this will allow user to enter all the details including the correct username. After i’ve done this ebusd and HA could finally talk to each other.

This being said:

  1. Originally the both usernames were correct - both HA and the other account existed and worked, i dont see a reason why the “homeassistant” user could only subscribe but not publish.
  2. Mosquitto_sub and mosquitto_pub commands still dont work.
1 Like

homeassistant and addon are reserved usernames and can no longer be used for mqtt - this was clearly noted in the docs I believe.

Right, but if so, why the integration is set up by default (adding a “discovered” integration, instead of setting it up from scratch) with “homeassistant” user and UI doesnt even offer a way of changing it?

My integration was setup prior to v3 or v4 of the addon using configuration.yaml. I deleted that when I updated the add-on and configured it.

I think you’ll find it was ‘legacy’

Hmm, ive been using the community MQTT addon until today and it was set up in configuration.yaml. Today i uninstalled community MQTT addon, removed the config grom configuration.yaml, enabled core MQTT addon (which ive been using before in 2.x version) and set up the credentials in config:
27
After that i reset everything, went to integrations menu and found a “Discovered: MQTT” button on the top of the screen. So i just clicked it and was not asked for any details or credentials. At first, i assumed that HA fetched the credentials from core mqtt addon configuration, but no - it just used homeassistant credentials

Perhaps a hold over from when you had settings in configuration.yaml. When you removed the integration it should ask if you want to restart (it did for me) If you didn’t restart before adding it back that might be why?

Yeah, im pretty sure that it asked me and i restarted HA at that point.
Anyhow, i know i should try to reproduce this problem and fill in an issue, but it’s 2:45am and im getting up to work at 5, so i will just leave those posts for other users with same problem.
If MQTT integration was auto discovered by HA and it’s behaving in an unexpected way, it’s worth checking .storage/core.config_entries file to see what credentials HA integration tries to use

I think if you restart the addon and check the logs on a setup that uses HA user credentials and no other users, you’ll see that the reserved ‘homeassistant’ user is connecting on an internal docker ip address. (172.30.32.1 or something like it).

What I see is

[WARN] SSL not enabled - No valid certs found!
[INFO] No local user available

“no local user available” means that no users were set in “logins” in the addon config.

[INFO] Initialize Hass.io Add-on services
[INFO] Initialize Home Assistant discovery
[INFO] Start Mosquitto daemon

The broker starts and then immediately, a device checks in with HA user creds:

1542206296: New connection from 192.168.1.146 on port 1883.
[INFO] found blarg on Home Assistant  <--- ("blarg" is an HA user)
1542206297: New client connected from 192.168.1.146 as ESPClient_84:F3:EB:B3:3A:DA (c1, k10, u'blarg').

and soon after that this ‘homeassistant’ user connects on the internal ip, which for some reason is refused at first:

1542206297: New connection from 172.30.32.1 on port 1883.
1542206298: Socket error on client <unknown>, disconnecting.
1542206298: New connection from 172.30.32.1 on port 1883.
[INFO] found homeassistant on local database
1542206298: New client connected from 172.30.32.1 as 46a90dfd-ade6-4e30-8469-2930543fgbdb (c1, k60, u'homeassistant').

That is the reserved ‘homeassistant’ user.

Stupid mistake, somehow one device (192.168.1.249) had a wrong MQTT username set.
Working now

I also have problems with the current version.
I am on hassio 0.82.0
Mosquitto broker v4

Mosquitto broker shows me this error in the log:
1542293060: Socket error on client <unknown>, disconnecting.
1542293061: New connection from 192.168.1.249 on port 1883. [ERROR] Auth error with user
1542293068: Socket error on client <unknown>, disconnecting.
1542293068: New connection from 192.168.1.249 on port 1883. [ERROR] Auth error with user
… and so on

And my System log shows:
18-11-15 14:46:19 INFO (MainThread) [hassio.auth] Auth request from core_mosquitto for user
18-11-15 14:46:23 WARNING (MainThread) [hassio.auth] Wrong login from user
18-11-15 14:46:24 INFO (MainThread) [hassio.auth] Auth request from core_mosquitto for user
18-11-15 14:46:29 WARNING (MainThread) [hassio.auth] Wrong login from user
…and so on

I don’t have mqtt: defined in my configuration.yaml
My configuration for my Mosquitto broker:

{
  "logins": [
    {
      "username": "my_username",
      "password": "my_password"
    }
  ],
  "anonymous": false,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem"
}

In the Integration I have MQTT: core-mosquitto

My sensors are using the same password to log in to MQTT as the ones I defined in the Mosquitto broker Config: my_username and my_password

Not sure whats wrong with this setup, v2.x of Mosquitto worked without any problems.

The access control list (authentication) implementation of this is still broken in V4 as far as I can tell.

Setting “anonymous”: true does not actually tell it to disrecard the ACL.
Even when setting the config to:

"logins": [],
"anonymous": true,

I still get log-in errors:

1541828382: New connection from 192.168.1.220 on port 1883.
[ERROR] Auth error with DVES_USER
1541828382: Socket error on client , disconnecting.

As a previous commented noted, most my MQTT stuff is sonoff-tasmota so I just added the default “DVES_USER / DVES_PASS” to the config, and that “solves” the problem, but this is not proper behavior.

In version 2 this was not an issue. I did not have any ACL defined, and anonymous was set to true and it “just worked”. This is all in an internal segregated network, I do not want any type of authentication.

So how the heck do I make this new version functionally equivalent to V2? Am I missing something here?

Also the birth/will system seems broken.

In the previous V2, I could define it as the documentation states (which hasnt changed). In the current version, having MQTT defined via the integration following the example in the instructions results in a completely broken system. Did the dev team just forget to add birth/will messages to the integration, or is this just an issue with poor/not-updated documentation?

Were you able to restore the anoymous functionality like in V2? I stupidly upgraded from V2 to V4 without a snapshot.

I have not been able to. There’s an open issue for it in github, but it doesn’t look like any of the devs have looked at (or have just stopped responding at least) in the past 17 days.

I went from HA 76.2 to HA 84.6 with no changes in my .yaml files for MQTT.
(MQTT Addon revision 4 )
All my WIFI connected IOT devices worked as before.
Under HomeAssisant -> Configuration -> Integrations it shows
MQTT: configuration.yaml

So I guess that the backward compatibility issues back in Nov 2018 have been solved.

After putting this off for months I finally bit the bullet and updated from V2 to V4 although it still took me 2 hours to get working :cry:

The Sonoffs and ESPEasy sensors/switches were easy to get sorted but I still have 3 Bruh multisensors and an OMG sensor/IR/433 NodeMcu and none of them would OTA update. I had to locally update or swap each one with a new flashed ESP before I could get the rest of them updated.

After all this I still couldn’t get MQTT to work with my new credentials. I could see them all connecting via the Addon log and via the Sonoff consoles. I had removed the old integration settings/ restarted Hassio and added them back with my new login details but HA would still not see any of my sensors. In the end I updated my secrets file and got the old mqtt configuration.yaml back into service and then everything came back :open_mouth:

When I feel brave enough again I will try the integration route again but for now I am just glad to be working again and on V4.

DVES_USER / DVES_PASS worked for me on a new install, but if I create a user on Home Assistant and set his login/pass it is not recognized.
Home Assiatnt 103.5
Mosquitto 5.1
in Docker on Ubuntu 19.

If as I do, you don’t like standard user/pass I found where the settings are not retained.

I’m using Docker on Ubuntu, so for me the file is
from Ubuntu
/usr/share/hassio/addons/data/core_mosquitto/options.json
User and pass are here, even if I changed it from HA interface (Hassio Addons settings) it doesn’t change in this file, so I edited it, restart the addon changed user and pass on the Tasmota plug…Boom it works