MQTT Integration - No devices found

The Goal
Im in the process of setting up Homeassistant so I can manage all my zigbee devices through HA. I want to use zigbee2mqtt in combination of the mosquitto broker addon available in the addon store.

What is done so far
After some research I ended up buying a cc2531 usb sniffer and flashed it with the right firmware. I also installed the mosquitto broker addon using anonymous mode with the following configuration:

logins: []
anonymous: true
customize:
  active: true
  folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false

I also did create the accesscontrolllist file with the following content:

topic readwrite # 

I also installed the zigbee2mqtt addon from the addon store and configured it:

data_path: /share/zigbee2mqtt
devices: devices.yaml
groups: groups.yaml
homeassistant: true
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://192.168.1.145'
serial:
  port: /dev/ttyACM0
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: {}
socat:
  enabled: false
  master: 'pty,raw,echo=0,link=/dev/ttyZ2M,mode=777'
  slave: 'tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5'
  restartdelay: 1
  initialdelay: 1
  options: '-d -d'
  log: false

These are mostly standard values except for the setting of the mqtt server. I was able to pair a xiaomi contact sensor and i see the state reported in the zigbee2mqtt log:

zigbee2mqtt:info  2020-04-14 12:33:24: MQTT publish: topic 'zigbee2mqtt/HaustĂĽr', payload '{"contact":true,"linkquality":68,"battery":100,"voltage":3005}'

I then went in HA GUI to Settings -> Integrations and added the mqtt integration. it automatically detected mosquitto broker with the right settings (not much to set up there) and i ticked the box “enable autodiscovery” before saving. So far so good…

The problem
My problem is, even though I can see the state of the sensor reporting to zigbee2mqtt and zigbee2mqtt says its connected to the mosquitto server (I will show you the logs later in this post), the devices do not show up on the mqtt integration page in HA. I just feel like there is a small piece missing but i can’t figure out what it is…

Let me show you the logs when i restart the both the addons “mosquitto broker” and then “zigbee2mqtt”:

Log of Mosquitto broker:

[12:49:13] INFO: Setup mosquitto configuration
[12:49:13] WARNING: SSL not enabled - No valid certs found!
[12:49:13] INFO: No local user available
[12:49:14] INFO: Initialize Hass.io Add-on services
[12:49:14] INFO: Initialize Home Assistant discovery
[12:49:14] INFO: Start Mosquitto daemon
1586868554: Loading config file /share/mosquitto/acl.conf
1586868554: mosquitto version 1.6.3 starting
1586868554: Config loaded from /etc/mosquitto.conf.
1586868554: Loading plugin: /usr/share/mosquitto/auth-plug.so
1586868554:  ├── Username/password checking enabled.
1586868554:  ├── TLS-PSK checking enabled.
1586868554:  └── Extended authentication not enabled.
1586868554: |-- *** auth-plug: startup
1586868554: Opening ipv4 listen socket on port 1883.
1586868554: Opening ipv6 listen socket on port 1883.
1586868554: Opening websockets listen socket on port 1884.
1586868554: Warning: Mosquitto should not be run as root/administrator.
1586868554: New connection from 172.30.32.1 on port 1883.
1586868554: New client connected from 172.30.32.1 as mqttjs_d4862366 (p2, c1, k60).
1586868557: New connection from 172.30.32.1 on port 1883.
[INFO] found homeassistant on local database
1586868558: New client connected from 172.30.32.1 as auto-587D268B-DFF3-7213-BA3D-EEB3596202EF (p2, c1, k60, u'homeassistant').

The log of the zigbee2mqtt addon:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
./run.sh: line 17: [Info] Configuration backup found in /share/zigbee2mqtt/.configuration.yaml.bk. Skipping config backup.: No such file or directory
[Info] Socat is DISABLED and not started
2020-04-14T13:02:36: PM2 log: Launching in no daemon mode
2020-04-14T13:02:36: PM2 log: App [npm:0] starting in -fork mode-
2020-04-14T13:02:36: PM2 log: App [npm:0] online
> [email protected] start /zigbee2mqtt-1.12.2
> node index.js
zigbee2mqtt:info  2020-04-14 13:02:42: Logging to console and directory: '/share/zigbee2mqtt/log/2020-04-14.13-02-42' filename: log.txt
zigbee2mqtt:info  2020-04-14 13:02:43: Starting zigbee2mqtt version 1.12.2 (commit #unknown)
zigbee2mqtt:info  2020-04-14 13:02:43: Starting zigbee-herdsman...
zigbee2mqtt:info  2020-04-14 13:02:45: zigbee-herdsman started
zigbee2mqtt:info  2020-04-14 13:02:45: Coordinator firmware version: '{"type":"zStack12","meta":{"transportrev":2,"product":0,"majorrel":2,"minorrel":6,"maintrel":3,"revision":20190109}}'
zigbee2mqtt:info  2020-04-14 13:02:45: Currently 6 devices are joined:
zigbee2mqtt:info  2020-04-14 13:02:45: HaustĂĽr (0x00158d0002e9d384): MCCGQ01LM - Xiaomi MiJia door & window contact sensor (EndDevice)
zigbee2mqtt:info  2020-04-14 13:02:45: 0x00158d0002ea0a02 (0x00158d0002ea0a02): MCCGQ01LM - Xiaomi MiJia door & window contact sensor (EndDevice)
zigbee2mqtt:info  2020-04-14 13:02:45: 0x00158d0002e2bcdf (0x00158d0002e2bcdf): WSDCGQ01LM - Xiaomi MiJia temperature & humidity sensor (EndDevice)
zigbee2mqtt:info  2020-04-14 13:02:45: 0x00158d0002e6e87a (0x00158d0002e6e87a): WSDCGQ01LM - Xiaomi MiJia temperature & humidity sensor (EndDevice)
zigbee2mqtt:info  2020-04-14 13:02:45: 0x00158d0002f38b2c (0x00158d0002f38b2c): WXKG02LM - Xiaomi Aqara double key wireless wall switch (EndDevice)
zigbee2mqtt:info  2020-04-14 13:02:45: 0x00178801062cc88d (0x00178801062cc88d): 9290022169 - Philips Hue white ambiance E27 with Bluetooth (Router)
zigbee2mqtt:warn  2020-04-14 13:02:45: `permit_join` set to  `true` in configuration.yaml.
zigbee2mqtt:warn  2020-04-14 13:02:45: Allowing new devices to join.
zigbee2mqtt:warn  2020-04-14 13:02:45: Set `permit_join` to `false` once you joined all devices.
zigbee2mqtt:info  2020-04-14 13:02:45: Zigbee: allowing new devices to join.
zigbee2mqtt:info  2020-04-14 13:02:45: Connecting to MQTT server at mqtt://192.168.1.145
zigbee2mqtt:info  2020-04-14 13:02:45: Connected to MQTT server
zigbee2mqtt:info  2020-04-14 13:02:45: MQTT publish: topic 'zigbee2mqtt/bridge/state', payload 'online'
zigbee2mqtt:info  2020-04-14 13:02:45: MQTT publish: topic 'zigbee2mqtt/HaustĂĽr', payload '{"contact":true,"linkquality":68,"battery":100,"voltage":3005}'
zigbee2mqtt:info  2020-04-14 13:02:45: MQTT publish: topic 'zigbee2mqtt/0x00158d0002ea0a02', payload '{"contact":false,"linkquality":0,"battery":97,"voltage":2995}'
zigbee2mqtt:info  2020-04-14 13:02:45: MQTT publish: topic 'zigbee2mqtt/0x00158d0002e2bcdf', payload '{"temperature":23.13,"linkquality":63,"humidity":36.84,"battery":100,"voltage":3005}'
zigbee2mqtt:info  2020-04-14 13:02:45: MQTT publish: topic 'zigbee2mqtt/0x00158d0002e6e87a', payload '{"temperature":23.26,"linkquality":81,"humidity":36.51,"battery":100,"voltage":3005}'
zigbee2mqtt:info  2020-04-14 13:02:45: MQTT publish: topic 'zigbee2mqtt/0x00158d0002f38b2c', payload '{"battery":100,"voltage":3035,"linkquality":68}'
zigbee2mqtt:info  2020-04-14 13:02:45: MQTT publish: topic 'zigbee2mqtt/bridge/config', payload '{"version":"1.12.2","commit":"unknown","coordinator":{"type":"zStack12","meta":{"transportrev":2,"product":0,"majorrel":2,"minorrel":6,"maintrel":3,"revision":20190109}},"log_level":"info","permit_join":true}'

After that there are a lot of messages for what I understand reporting the current state of the paired devices.

I just checked the mosquitto broker log again after restarting the zigbee2mqtt addon and i can see the following error:

1586869348: Socket error on client mqttjs_d4862366, disconnecting.
1586869365: New connection from 172.30.32.1 on port 1883.
1586869365: New client connected from 172.30.32.1 as mqttjs_36963777 (p2, c1, k60).

I don’t know if this is related to my problem. For me it’s not clear what this “client mqttjs_d4862366” is…

But so for me it seems like zigbee2mqtt is able to talk to the mosquitto broker and HA also was able to detect the mosquitto broker when I added the MQTT integration. I just don’t know what triggers HA to add the devices which are already paired… I hope someone can clear this up for me.

At this point: Thanks for reading through all of this and i wish you great day!

  1. Go to Developer Tools > MQTT > Listen to a topic
  2. In Topic to subscribe to enter #
  3. Click Start Listening
  4. Restart zigbee2mqtt

You should observe a flurry of MQTT messages upon zigbee2mqtt’s startup. Some of the messages should contain MQTT topics in this format:

homeassistant/sensor/whatever/config

homeassistant/binary_sensor/something/config

homeassistant/switch/namegoeshere/config

Those are “discovery topics” (published by zigbee2mqtt) and their payloads contain information that Home Assistant uses to create entities:

sensor.whatever
binary_sensor.something
switch.namegoeshere
  • If you not seeing any messages then Home Assistant isn’t connected to the MQTT broker.
  • If you’re not seeing any discovery topics being published then Home Assistant isn’t receiving the information it needs to create entities.

This is from the documentation:


The discovery topic need to follow a specific format:

<discovery_prefix>/<component>/[<node_id>/]<object_id>/config
  • <component> : One of the supported MQTT components, eg. binary_sensor .
  • <node_id> ( Optional ): ID of the node providing the topic, this is not used by Home Assistant but may be used to structure the MQTT topic. The ID of the node must only consist of characters from the character class [a-zA-Z0-9_-] (alphanumerics, underscore and hyphen).
  • <object_id> : The ID of the device. This is only to allow for separate topics for each device and is not used for the entity_id . The ID of the device must only consist of characters from the character class [a-zA-Z0-9_-] (alphanumerics, underscore and hyphen).

1 Like

Thanks for the fast answer :+1:t3:

I was able to solve it now.

I tested if I get any messages in the developer tools while restarting zigbee2mqtt but nothing happened.
I then deleted the mqtt integration and restarted HA. After that I manually added the mqtt integration via the “+” button. I entered the correct IP address of the mosquitto broker and all devices got automatically discovered.

I don’t know what the problem is when adding the integration through the automated process of automatically discovered integrations but adding it manually did the trick.

Thanks again for that valuable post :+1:t3:

1 Like

Glad to hear my instructions helped you resolve the problem.

Please mark my post (containing the instructions) with the Solution tag. Only you, the author of this topic, can select and mark a post as the Solution. This will automatically place a check-mark next to the topic’s title which signals to others that your question has been resolved. It also helps others find answers to similar questions.