Mosquitto configured, Home Assistant and sensors connect, discovery on, but no new MQTT entities

I’m running:

  • HassOS: 4.13
  • Home Assistant: 0.115.6
  • Mosquitto Broker: 5.1
  • Supervisor: 245

After installing the mosquitto broker, I created the /share/mosquitto/acl.conf and /share/mosquitto/accesscontrollist files. The ACL gives both the homeassistant and my sensors user r/w on all topics:

user homeassistant
topic readwrite #

user mqtt-sensors
topic readwrite #

I had to specifically create these files; I’d have expected the installation to provide at least a skeleton version, but even the /share/mosquitto/ folder had to be created. Some installation issue?

Anyway, I can now use mosquitto_pub and mosquitto_sub, plus the publish/listen controls in the integration’s configuration screen to verify that it works indeed. Messages are being passed from the sensors, and I can see them in the UI.

However, here’s where I’m stuck. All the tutorials I seen so far have new entities magically appear, to be used in new cards in the Lovelace UI. I, however, don’t see any new entities in configuration=>entities when I make my sensors send an update.

What am I doing wrong? Could it be because the installation semi-failed, and certain configuration files were never installed?

Just in case, here are some screenshots. Since a new user can only put one screenshot per post, I’m doing this in separate replies.

Mosquitto Broker configuration:

HomeAssistant seeing my device connect and report:

Mosquitto-pub on the laptop seeing the same:

I’m not gonna show my entire entities list, as that would be multiple screenshots, but rest assured that I don’t see any new entries pop up under Configuration => Entities

As you can see, the sensor in question is a Shelly device. It’s battery operated, and not well supported under the Shelly integration at the moment. It’s also configured under that integration, but even if I remove it from there, it only gets rediscovered as a Shelly device, never an MQTT device.

Out of the box, the shellies do not send auto discovery messages. In have, you can find ’ Shelly auto discovery script’ Install this.

1 Like

Did you add the MQTT Integration?

Thanks, getting closer. In the sense of still having the exact same problem, but with more stuff installed.

The Python script has been installed, and I restarted HA twice. Still no joy. Using mosquitto_sub on another machine to see what traffic comes by when I wake a device shows me the same stuff from the device itself that I could already see before installing the script. At this point I would expect the script to pick up on this and post something on a path under the discovery prefix (I’m guessing that’s what it does under the hood?), yet nothing happens.

Tangential question: the instructions gave this as an alternative to running the Shellies Announce automation “after installing the script and adding automations”. I have no clue what that means: where does this Shellies Announce automation come from? Is it something that should be automatically added, or is it one of the aforementioned automations that I need to add? Does “adding automations” mean as in, manually, not “as a side effect of installing the script”? If so, which automations do I need to ad and how do I need to define them? If not, where do these automations magically appear, because it’s not under Configuration => Automations.

Anyway, does anyone happen to have further tips? Because the Shellies Discovery documentation isn’t very helpful.

One potential avenue: looking at the script itself, it appears to automatically try to deduce the discovery prefix, falling back on a default prefix if not found. The documentation also mentions that the discovery prefix should match between the script and HA. However, I have no way of checking what the discovery prefix for the MQTT service in HA is as that info is not exposed to me. Perhaps the previous one did, but the new one that’s built into HA only exposes a boolean for whether to enable discovery or not. Could this be it? If so, does anyone happen to know how to make the script and the built-in Mosquitto MQTT integration agree?

Nevermind, found it. The automations one needs to add are at the bottom of the document. Managed to get it working despite the documentation. :wink: