Zigbee2MQTT Initial Setup - MQTT Not Adding Devices

I have just setup Zigbee2MQTT for the first time and running into a snag. The Zigbee2MQTT addon appears to be functioning perfectly. I added devices, and can control them from there. Sadly I cant see any of them in Home Assistant devices. It is my understanding that the MQTT add on is what brings those into Home Assistant.

I am running Home Assistant Supervisor, added MQTT through the Supervisor add ons, and added Zigbee2MQTT via supervisor add ons.

In the MQTT settings, i grabbed the IP address and added that to the Zigbee2mqtt configuration as seen below.

data_path: /config/zigbee2mqtt
socat:
enabled: false
master: pty,raw,echo=0,link=/tmp/ttyZ2M,mode=777
slave: tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5
options: ‘-d -d’
log: false
mqtt:
server: mqtt://172.30.32.1:1883
serial:
port: /dev/ttyUSB0

here is a capture of the logs from the zigbee2mqtt add on

Zigbee2MQTT:info 2022-04-16 09:19:22: MQTT publish: topic ‘zigbee2mqtt/edited Garage Door’, payload ‘{“battery”:94,“battery_low”:null,“contact”:null,“linkquality”:109,“moving”:false,“tamper”:null,“temperature”:18.39,“voltage”:2700,“x_axis”:-2,“y_axis”:-1051,“z_axis”:-34}’
Zigbee2MQTT:info 2022-04-16 09:25:57: MQTT publish: topic ‘zigbee2mqtt/Master Bedroom Noise Fan’, payload ‘{“linkquality”:54,“state”:“ON”,“update”:{“state”:“idle”},“update_available”:false}’
Zigbee2MQTT:info 2022-04-16 09:25:57: MQTT publish: topic ‘zigbee2mqtt/Master Bedroom Noise Fan’, payload ‘{“linkquality”:47,“state”:“ON”,“update”:{“state”:“idle”},“update_available”:false}’
Zigbee2MQTT:info 2022-04-16 09:27:18: MQTT publish: topic ‘zigbee2mqtt/Garage Freezer’,

Sadly the Integration for MQTT shows no devices or entities.

What could I be missing? When i solve it will i need to remove and re-add all of my devices from the Zigbee2MQTT interface for them to show up in the MQTT Add on Integration (in other words to see them in Home Assistant)?

Is the mqtt broker actually receiving the messages?

Check the Mosquitto addon logs, and inspect the messages in the broker by using MQTT Explorer (free).

Also I have this as my mqtt server setting in the zigbee2mqtt config:

server: mqtt://core-mosquitto:1883

Here is what i see in the MQTT add on logs. One thought is that my config has .1 as the mqtt broker and this shows a lot of .2 What are your thoughts around that? I tried changing it to .2 in the past but the zigbee2mqtt add on wouldnt start correctly so i moved it back to .1. Is this something to look further into?

1650125484: New connection from 172.30.32.2 on port 1883.
1650125484: Socket error on client , disconnecting.
1650125604: New connection from 172.30.32.2 on port 1883.
1650125604: Socket error on client , disconnecting.
1650125724: New connection from 172.30.32.2 on port 1883.
1650125724: Socket error on client , disconnecting.
1650125844: New connection from 172.30.32.2 on port 1883.
1650125844: Socket error on client , disconnecting.
1650125964: New connection from 172.30.32.2 on port 1883.
1650125964: Socket error on client , disconnecting.
1650126084: New connection from 172.30.32.2 on port 1883.
1650126084: Socket error on client , disconnecting.
1650126204: New connection from 172.30.32.2 on port 1883.
1650126204: Socket error on client , disconnecting.
1650126324: New connection from 172.30.32.2 on port 1883.
1650126324: Socket error on client , disconnecting.
1650126444: New connection from 172.30.32.2 on port 1883.
1650126444: Socket error on client , disconnecting.
1650126564: New connection from 172.30.32.2 on port 1883.
1650126564: Socket error on client , disconnecting.
1650126684: New connection from 172.30.32.2 on port 1883.
1650126684: Socket error on client , disconnecting.
1650126804: New connection from 172.30.32.2 on port 1883.
1650126804: Socket error on client , disconnecting.
1650126892: Saving in-memory database to /data/mosquitto.db.
1650126924: New connection from 172.30.32.2 on port 1883.
1650126924: Socket error on client , disconnecting.
1650127046: New connection from 172.30.32.2 on port 1883.
1650127046: Socket error on client , disconnecting.
1650127166: New connection from 172.30.32.2 on port 1883.
1650127166: Socket error on client , disconnecting.
1650127286: New connection from 172.30.32.2 on port 1883.
1650127286: Socket error on client , disconnecting.

I am an IT pro but have done windows my whole life. I am horrible with linux. LOL. Is there a way to place the mqtt explorer on my windows device to look at the messages? My local subnet is 192.168.1.x and based on what I am seeing the broker would be at 172.30.32.1 (or .2). I assume the windows device wont be able to reach that :(.

I am running Supervisor so i have not had to deal with linux as much lol.

There is a windows version of Mqtt Explorer you can download and install.

From that error log Zigbee2mqtt is unable to connect to the broker. Check your credentials (user and password) and change the server setting to what I showed.

I made that change but credentials could be my issue. So i know that there are creds that can be set in MQTT (which i have not changed since the setup). How do those get set in MQTT? where does that authentication happen?

I opened the windows app and connected to my home assistants ip address 192.168.1.xxx with no username and no password. I then tried with test and test and it failed. So it appears that the instance is open.

When in MQTT explorer, i saw absolutely nothing.

Maybe there are incorrect creds connecting Zigbee2MQTT to MQTT? Where can i see what its using? I didnt see it in the config file.

config/zigbee2mqtt/configuration.yaml

When i changed the path to the one you recommended, the messages in the add on logs are as follows. Does this look like its succeeding now? I still cant see anything in mqtt explorer however.

Zigbee2MQTT:info 2022-04-16 13:17:37: MQTT publish: topic ‘zigbee2mqtt/Alisha’s Garage Door’, payload ‘{“battery”:91.5,“battery_low”:null,“contact”:null,“linkquality”:null,“moving”:false,“tamper”:null,“temperature”:18.9,“x_axis”:15,“y_axis”:-1036,“z_axis”:56}’
Zigbee2MQTT:info 2022-04-16 13:18:37: MQTT publish: topic ‘zigbee2mqtt/Living Room Lamp’, payload ‘{“color_mode”:“xy”,“linkquality”:112,“state”:null,“update”:{“state”:“available”},“update_available”:true}’
Zigbee2MQTT:info 2022-04-16 13:18:37: Update available for ‘Living Room Lamp’
Zigbee2MQTT:info 2022-04-16 13:20:27: MQTT publish: topic ‘zigbee2mqtt/Neils Garage Door’, payload ‘{“battery”:93,“battery_low”:null,“contact”:null,“linkquality”:109,“moving”:false,“tamper”:null,“temperature”:19.22,“voltage”:2700,“x_axis”:4,“y_axis”:-1050,“z_axis”:-39}’
Zigbee2MQTT:info 2022-04-16 13:20:27: MQTT publish: topic ‘zigbee2mqtt/Neils Garage Door’, payload ‘{“battery”:93,“battery_low”:null,“contact”:null,“linkquality”:109,“moving”:false,“tamper”:null,“temperature”:19.22,“voltage”:2700,“x_axis”:4,“y_axis”:-1050,“z_axis”:-39}’
Zigbee2MQTT:info 2022-04-16 13:20:37: MQTT publish: topic ‘zigbee2mqtt/Neils Garage Door’, payload ‘{“battery”:93,“battery_low”:null,“contact”:null,“linkquality”:109,“moving”:false,“tamper”:null,“temperature”:19.22,“voltage”:2700,“x_axis”:4,“y_axis”:-1050,“z_axis”:-39}’
Zigbee2MQTT:info 2022-04-16 13:20:37: MQTT publish: topic ‘zigbee2mqtt/Neils Garage Door’, payload ‘{“battery”:93,“battery_low”:null,“contact”:null,“linkquality”:109,“moving”:false,“tamper”:null,“temperature”:19.22,“voltage”:2700,“x_axis”:4,“y_axis”:-1050,“z_axis”:-39}’

SUCCESS!!!

You were dead on. The issue was with the creds. I was able to connect with MQTT explorer with no un and pass but the Zigbee2MQTT was not working.

I changed my MQTT setup to have a UN and Pass by changing the config on the add on as seen below. Really only added the user and password lines.

certfile: fullchain.pem
customize:
active: false
folder: mosquitto
keyfile: privkey.pem
logins:

  • username: user_i_made_up
    password: pass_i_made_up
    require_certificate: false

I then connected with MQTT explorer to verify (i used the IP of my home assistant server and the standard MQTT port) which worked.

I used your recommendation for the server in the Zigbee2MQTT add on config as seen below:
mqtt:
server: mqtt://core-mosquitto:1883

I then had to add the following to my Zigbee configuration file that you mentioned above

homeassistant: true
mqtt:
server: mqtt://core-mosquitto:1883
user: user_i_made_up
password: pass_i_made_up

Thank you so much for helping me get this going! I really really appreciate it. I hope my notes above are able to help someone in the future that may run into something similar.

1 Like

I’m having what seems to be a similar problem however I can confirm that I see in the Zigbee2MQTT logs that it is connecting the the MQTT Broker and publishing messages, however I still see nothing showing up in HA under devices. Do I need to tell the MQTT Broker Integration to listen on the Z2M Topic? That field is empty when I go to Configure on the MQTT Broker Integration.

Do you have Home Assistant discovery enabled in the zigbee2mqtt settings? My new devices are added immediately. Also, are you giving devices a “friendly name” in zigbee2mqtt? The default long coded name I think sometimes causes issues - if changing the name be sure to toggle on the “update Home Assistant entity” option. These are what my settings look like:

@mwav3 I didn’t have the “Home Assistant legacy entity attributes” option checked, but even after doing that I’m not seeing the plugin I added showing up in HA. I had given it a new name right after it was paired with Z2M. However, now I’m looking at the logs for “Mosquitto broker” and I’m seeing a ton of these errors:

1652368063: New connection from 172.30.32.1:34763 on port 1883.
1652368063: Client <unknown> disconnected, not authorised.
1652368098: New connection from 172.30.32.2:34734 on port 1883.
1652368098: Client <unknown> closed its connection.
1652368183: New connection from 172.30.32.1:52043 on port 1883.
1652368183: Client <unknown> disconnected, not authorised.
1652368218: New connection from 172.30.32.2:34736 on port 1883.
1652368218: Client <unknown> closed its connection.
1652368303: New connection from 172.30.32.1:33001 on port 1883.
1652368303: Client <unknown> disconnected, not authorised.
1652368338: New connection from 172.30.32.2:34738 on port 1883.
1652368338: Client <unknown> closed its connection.
1652368428: New connection from 172.30.32.1:58685 on port 1883.
1652368428: Client <unknown> disconnected, not authorised.
1652368458: New connection from 172.30.32.2:34740 on port 1883.
1652368458: Client <unknown> closed its connection.

So now it seems like something isn’t working again.

@mwav3 hmm, actually, I think now that I look at it that is just normal MQTT connections happening. I’m going to just try and reboot my whole HA Raspberry Pi and see if that makes any difference. Maybe later I’ll try to remove the plugin from Z2M, reset it, and try to add it back in.

I don’t believe that is normal behavior. It appears auth is not configured properly for the broker - possibly some sort of password issue.

Are you using the mosquitto addon or something else for your broker? If the addon take a look at this post and the one’s under it from someone with a similar issue.

1 Like

So I just entered in the credentials for MQTT into Z2M and restarted the add-on. I’m seeing this in the logs for Z2M which looks right:

Zigbee2MQTT:info  2022-05-12 13:55:51: Starting zigbee-herdsman (0.14.27)
Zigbee2MQTT:info  2022-05-12 13:55:52: zigbee-herdsman started (resumed)
Zigbee2MQTT:info  2022-05-12 13:55:52: Coordinator firmware version: '{"meta":{"maintrel":1,"majorrel":2,"minorrel":7,"product":1,"revision":20210320,"transportrev":2},"type":"zStack3x0"}'
Zigbee2MQTT:info  2022-05-12 13:55:53: Currently 1 devices are joined:
Zigbee2MQTT:info  2022-05-12 13:55:53: Washing Machine (0xb0ce1814036be02d): E1C-NB7 - Sengled Smart plug with energy tracker (Router)
Zigbee2MQTT:info  2022-05-12 13:55:53: Zigbee: disabling joining new devices.
Zigbee2MQTT:info  2022-05-12 13:55:53: Connecting to MQTT server at mqtt://core-mosquitto
Zigbee2MQTT:info  2022-05-12 13:55:53: Connected to MQTT server
Zigbee2MQTT:info  2022-05-12 13:55:53: MQTT publish: topic 'zigbee2mqtt/bridge/state', payload '{"state":"online"}'
Zigbee2MQTT:info  2022-05-12 13:55:54: Started frontend on port 0.0.0.0:8099
Zigbee2MQTT:info  2022-05-12 13:55:54: MQTT publish: topic 'homeassistant/switch/0xb0ce1814036be02d/switch/config',

I paired an additional plug and again nothing is showing up in HA under Devices.

@mwav3 OK, so I checked out the “Mosquitto broker” Configuration and noticed when I clicked next it was prefilled with homeassistant and some password and it failed to authenticate. I changed this to the same credentials as I setup Z2M to be using and then it connected and now my devices are showing up. It’s strange as it’s seemed like I hadn’t seen this step outlined in any of the YouTube videos or other guides. It looks like things are working now though. Woot!

1 Like

This response right here was the key to this exact problem I had. Thank you for taking the time to post the fix!

1 Like

The ‘homeassistant:true’ part was missing after I did an update of Z2M. It fixed my similar MQTT connection issue.

Thanks!