Zigbee2mqtt entities work but are not showing in hass

Tags: #<Tag:0x00007f3f2e8efc50>

I am trying to setup zigbee2mqtt and I’m about to pull what hair I have left out. I purchase a CC2531 zigbee usb stick and reprogrammed it for zigbee2mqtt. I installed the zigbee2mqtt addon for homeassistant and configured it according to the instructions. I have read just about everyone’s posts in what they did to get there devices working and have tried all the suggestions I can find but I am at a loss. when I look at the log for zigbee2mqtt my motion sensor connects just fine and i can see it connected in the logs for mosquoitto also. both also show when the motion is triggered and when it goes back to a clear state. I can see all the stats…Low battery, temperature, connected state…everything. I can even publish to it and get responses back and i can use it in node-red just fine. my issue is that my devices…not even the bridge itself…show up in entities in hass.io. when I go to developer tools and select “states” all of my other devices are there except anything that has to do with zigbee2mqtt. Here is my configuration is anyone can tell me what I’m doing wrong.

zigbee2mqtt configuration

{
  "data_path": "/share/zigbee2mqtt",
  "devices": "devices.yaml",
  "groups": "groups.yaml",
  "homeassistant": true,
  "permit_join": false,
  "mqtt": {
    "base_topic": "zigbee2mqtt",
    "server": "mqtt://homeassistant:1883",
    "user": "I have my username here",
    "password": "I have my password here"
  },
  "serial": {
    "port": "/dev/ttyACM1"
  },
  "advanced": {
    "pan_id": 6754,
    "channel": 11,
    "network_key": [
      1,
      3,
      5,
      7,
      9,
      11,
      13,
      15,
      0,
      2,
      4,
      6,
      8,
      10,
      12,
      13
    ],
    "availability_blacklist": []
  },
  "ban": [],
  "whitelist": [],
  "queue": {}
}

config/configuration.yaml

mqtt:
  discovery: true
  broker: homeassitant # This will have to be your mqtt broker
  port: 1883
  client_id: homeassistant
  username: I have my username here
  password: I have my password here
  birth_message:
    topic: 'hass/status'
    payload: 'online'
  will_message:
    topic: 'hass/status'
    payload: 'offline'

I have even added the 2 files in the share/mosquitto folder. The accesscontrollist file with user [my user name] and topic readwrite # in it and the acl.conf file with acl_file /share/mosquitto/accesscontrollist in it. I have tried changing the server from mqtt://homeassistant:1883 to mqtt://localhost:1883 to mqtt:// 172.17.0.1:1883 all with no success.

I have hass.io running in a vm on a server with the zigbee usb stick plugged into the server. I am at a complete loss as to what is wrong or how to fix it. I tried to post everything that someone would nee to see what I was doing wrong but I am fairly new at home assistant and yaml so I am still learning. Can someone please help me. If I am missing info that is needed please let me know and I will post it. TIA

I run the same setup and have no problems. If you go into the menu on the left side of Home Assistant and goto Configuration, then Integrations, do you have something that says MQTT: Mosquito Broker ? If not, try clicking the plus sign and setup MQTT with your credentials. After this step your sensors should populate there as well as Entities.

@timpro thanks for the quick response. I double checked and I do have MQTT:Mosqitto configured however when I tap on it out says “this intigration has no devices”

When you subscribe to the appropriate topic via mosquitto_sub, do you see the discovery messages?

@nickrout yes I can subscribe to any of the topics and I see the responses or publish to any of the topics and get results whether it’s in node-red or thru HiveMQ which is the MQTT Server/Web client that was installed with Mosquito. That’s how I was able to pair my motion sensor. I had to manually publish to the topic zigbee2mqtt/bridge/configure/pair_enable true then pair the motion sensor then publish false to the same topic to turn pairing off. Everything works normally with it except that there are no entities even if I try to manually add them. For example I followed the directions to have the card in Lovelace with the switch, timer and link state of the bridge for device pairing. The switch is there as is the time remaining because those are just automations but the bridge state shows an error because it can’t find the entity and the switch doesn’t work for the same reason. That’s why I had to add the motion sensor manually.

as a side note, I do have other devices that I control thru MQTT that show up as entities but that’s because they were made from other integrations. for example I have a couple of ESP8266’s that I use to control my front door latch but I programmed them using ESPHome and they are setup as binary_sensors and switches and show up under integrations each ESP8266 as it’s own integration.

I was asking about the discovery messages. Subscribe to the topic homesassistsnt/#

But you have confused me now. What is this bridge you speak of?

You say you have a switch in Lovelace? Is this your zigbee device?

What is this timer you refer to?

@nickrout yes…the bridge is the zigbee device. and the switch in lovelace is supposed to be for turning on the pairing function of that zigbee device and it also has a timer that turns the pairing function of the zigbee device back off to keep traffic down. But yes I see the discovery messages when I subscribe to the appropriate topics

Interesting! My other MQTT devices don’t show under integrations as yours do… I have a few blinds and relays that I control via MQTT, they each have their own .yaml configuration file, I wasn’t aware they would show here. Only my zigbee2mqtt sensors seem to show here?

I’ll take a look at my config and post it here, maybe it’ll help you out. I never set up the switch and timer portion for pairing, all I did was change permit_join to true in the zigbee config and I was able to pair. Heads up, some devices are way more difficult to pair than others. I have Xiaomi door sensors that paired instantly, but my vibration sensors took many many tries.

Here is my config, compare it with yours and see if there are any differences?

Working zigbee2mqtt config:

{
  "data_path": "/share/zigbee2mqtt",
  "devices": "devices.yaml",
  "groups": "groups.yaml",
  "homeassistant": true,
  "permit_join": false,
  "mqtt": {
    "base_topic": "zigbee2mqtt",
    "server": "mqtt://192.168.0.131:1883",
    "user": "z2m",
    "password": "password"
  },
  "serial": {
    "port": "/dev/ttyACM0"
  },
  "advanced": {
    "pan_id": 6754,
    "channel": 11,
    "network_key": [
      100,
      131,
      4,
      254,
      233,
      45,
      31,
      12,
      129,
      168,
      192,
      112,
      52,
      114,
      221,
      82
    ],
    "availability_blacklist": []
  },
  "ban": [],
  "whitelist": [],
  "queue": {}
}

Mosquitto config:

{
  "logins": [
    {
      "username": "pi",
      "password": "password"
    },
    {
      "username": "esp1",
      "password": "password"
    },
    {
      "username": "z2m",
      "password": "password"
    }
  ],
  "anonymous": false,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "plain": true,
  "plain_websockets": false,
  "ssl": false,
  "ssl_websockets": false
}

Do you have your zigbee2mqtt configured to use a devices.yaml file? And if so, are your devices populating in there?

the devices.yaml looks like this inside:

'0x00158d0002e69376':
  friendly_name: '0x00158d0002e69376'
  retain: false

@timpro it’s funny that I never noticed it before. I have the “data_path”: “/share/zigbee2mqtt” in my config for zigbee2mqtt addon page but it was missing from the zigbee2mqtt configuration.yaml file. When I try to add it zigbee stops working so I restart it and it gets removed. I checked the backup file and it is in the backup file so I’m not sure what is removing it. Other then that the only difference is the network key, I just left the default value there (1, 3, 5, 7, 9, 11, 13, 15, 0, 2, 4, 6, 8, 10, 12, 13) oh and I’m using mqtt://homeassistant:1883 for my server. As for the MQTT configuration mine is quite a bit different. I didn’t install just Mosquitto, I installed Mosquitto with the HiveMQ Server and Web Client. I do have the devices.yaml and groups.yaml in the share folder and it did populate the devices folder with the connected devices. There is also a states folder with the state topics of the different devices that are connected.

I just wanted to post that i finally got everything working so that my zigbee2mqtt devices show up as entities. One thing that I think was a culprit was in the zigbee2mqtt hass.io add-on documentation it mentions to add to your configuration.yaml this

mqtt:
  broker: homeassistant # This will have to be your mqtt broker
  discovery: true

I’m pretty sure this was the main thing that broke mqtt from auto discovering. In reading the Mosquitto documentation it mentions that you don’t have to make any configuration.yaml changes for mqtt to work. so I went ahead and deleted that entry. Then for good measure I uninstalled Mosquitto and installed a different version. I had a different Mosquitto setup then everyone else that I saw that had trouble with zigbee2mqtt and then got it fixed. My setup had the addition of the HiveMQ in the add-on which added a server/ web client to the sidebar for publishing and subscribing manually to multiple topics. So i installed just the standard Mosquitto and when I restarted hass all of my devices showed up. Thank you to @timpro and @nickrout for responding and helping me figure this out. Believe it or not as much of a pain as this was I’m glad it happened. I think you learn so much more when you have something that doesn’t work because you have to research a lot to find out what is wrong and in doing so you discover things you didn’t know that you weren’t even looking for. Thanks again guys…I can now go to sleep.

1 Like