Setup Mosquitto MQTT Broker - Step by Step

Hi,
I want to integrate my new Shelly H&T sensor to Home Assistant (running Hass.io on Raspberry Pi) and, therefore, want to set up a MQTT broker. I have tried to set up the Mosquitto MQTT broker and to integrate the Shelly H&T sensor in Home Assistant but I am a bit overwhelmed. Could somebody help me through the debugging process step by step?

At First, I went to Home Assistant frontend → Hass.io tab → Add-on store → and installed the Mosquitto broker. Then I followed the instructions on https://www.home-assistant.io/addons/mosquitto/, set up an username and password, left anything else as it was and restarted Home Assistant.

Now, under Developer tools I got a new MQTT symbol where I can Publish a packet (not really sure what to do here…).

I didn’t change the configuration.yaml as the instruction said there is no need for it.

After the installation of Mosquitto Broker, I activated MQTT Service on my Shelly device, put in username, password IP address and port of the installed Mosquitto Broker following the instructions of The Hook Up (https://www.youtube.com/watch?v=VqxCf3NjVDU).

Then I added some sensors to my configuration.yaml file following the instructions on https://github.com/thehookup/shelly1tasmota/blob/master/ShellyConfig.yaml

Now, I got three new shelly sensor entities, but the sensors seem to not receive any data.

How can I check whether the Mosquitto Broker receives any data from the Shelly Sensor? How can I test whether the Mosquito Broker is set up correctly and ready to receive MQTT data?

I do not really understand the instructions on https://www.home-assistant.io/docs/mqtt/testing/.

Thanks for your help!

5 Likes

Do you have the ssh server set up on hassio? If not you should. It is another addon like mosquitto is. It isn’t necessary for mosquitto, but it is good for lots of things.

Once you have ssh up and running, then you can run the test on the page you pointed to.

1 Like

thanks for your reply. No, have not set up a ssh server yet. But I am gonna do it.

However, the MQTT broker seems to work now as my shelly sensors in Home Assistant are receiving data. But I have not changed anything. Apparently, the Shelly H&T sends only data in certain time periods (standard is every hour) or on certain events (e.g. the temperature changes).

So, after set up the sensors in Home Assistant, you have to give it some time to see whether it works.

and I haven’t changed anything.

OK so it is working, great :slight_smile:

I recommend this question as a guide.
I spent so much time trying to get my setup to work and zilch.
I followed the steps you described in such great detail, worked perfectly.
Thank you OP!!

1 Like

I’m using The latest release of Hass.io in home assistant version 0.98.5. I read that I needed to add configuration.yaml entries like:

mqtt:
# discovery: true
  broker: 192.168.x.xxx
  port: 1883
  username: xuser
  password: xpwd!

I installed mosquitto and now I’m not sure I needed configuration.yaml entries. All my mqtt sensors from my 0.84.4 Hassio system no longer work. My confusion comes from the message that the built-in mqtt broker is deprecated, I have an mqtt tab on my Developer Tools page that doesn’t seem to do anything, I can’t add an mqtt user from configuration->mqtt-> manage users, but there is already one there as an administrator.

How do I figure out what’s going on with my mqtt broker, which broker is running, or if there is a conflict between the built in and mosquitto brokers?

I followed the mosquitto instructions page here but they seem to be different from what I see when using version 0.98.5 Hass.io system. Are these instructions still appropriate or updated for 0.98.5? Specifically,

  1. Install the Mosquitto add-on with the default configuration via ‘Hass.io > ADD-ON STORE’. (Don’t forget to start the add-on & verify that ‘Start on boot’ is enabled.) [DONE]
  2. Create a new user for MQTT via the Configuration > Users (manage users) . (Note: This name cannot be “homeassistant” or “addon”) [CAN’T CREATE A USER - JUST DELETE THE EXISTING ONE]
  3. Once back on-line, return to Configuration > Integrations and select configure next to MQTT . [IT’s EMPTY - THIS INTEGRATION HAS NO DEVICES]

Yes - I’m thoroughly confused here and could use some help. Like I said, mosquitto used to work fine on my 0.84.4 HA system.

Thanks in advance.

Take out the configuration.yaml stuff you quoted.

What do you mean by CAN’T CREATE USER - what happens when you try?

I mean there is options only to Rename the user or delete it. There is no add user button.

When I pull down the “Administrators” box and change to “User” the message appears:

The users group is a work in progress. The user will be unable to administer the instance via the UI. We’re still auditing all management API endpoints to ensure that they correctly limit access to administrators.

So it’s not clear what to do here on the manage users page.
My device still don’t communicate although I see the client connect in the mosquitto log.

Thanks

There should be a circle with + in the middle to add a user.

There is one on the main users page that has 4 names:


Home Assistant Cloud
Administrators - System Generated >
Hass.io
Administrators - System Generated >
Homexuser
Administrators                                  >
Mosquitto
Administrators                                  >

So when I go into Mosquitto, there is only one user and I can’t add another. Just rename or delete it.

Are you suggesting I add another Mosquitto user on the main user’s page? The Circle + dialog asks for Name, Username, Password. But no association with Mosquitto which I configured the client user in the Mosquitto parameters.

Sorry if I’m being thick here but all this used to work as expected by configuring the Mosquitto Add-on’s parameters in the config section before starting it.

EDIT: MADE IT WORK, SERVER RESTART HELPED (yet I have to edit all sensor info via configuration.yaml). LEAVING THIS COMMENT AS A TUTORIAL

Hi, I also have a problem with configuring Mosquitto with HA. So basically I’m running HA on old Android device (followed this great tutorial). It’s working fine and I wanted to add my USB meter with ESPeasy.
What I’ve done:

  1. Setup login and password with mosquitto_passwd -c logdata.txt hoplophile
  2. In ESPeasy:
  3. Checked the above with MQTTlens and it works - I’m receiving USB_monitor/PowerMeter/Power topic

And now the problem starts, because I don’t know how to pass data from mosquitto to HA. Please note that I don’t have tha Add-ons menu in my HA. I edited configuration.yaml file:

# Configure a default setup of Home Assistant (frontend, api, etc)                                  
default_config:                                                                                                                                                                                         

# Text to speech                                                                                    
tts:                                                                                                  
- platform: google_translate                                                                                                                                                                          

mobile_app:                                                                                         
group: !include groups.yaml                                                                         
automation: !include automations.yaml                                                               
script: !include scripts.yaml                                                                       
scene: !include scenes.yaml                                                                                                                                                                             

mqtt:                                                                                                 
  broker: 10.0.0.126                                                                                  
  port: 1883                                                                                         
  username: hoplophile
  password: h***e                                                                                                                                                                                                      

sensor:                                                                                               
  - platform: mqtt                                                                                      
    name: "USB Meter Power"                                                                             
    state_topic: "USB_monitor/PowerMeter/Power"                                                           

but still I can’t see any entities in HA.

As far as I know, Espeasy does not support HA MQTT-discovery. So you will have to configure your USB Meter Power in yaml.

If you can’t figure it out, post the messages you receive in MQTT Lens.