Stuck with zigbee2mqtt. No pairing

Tags: #<Tag:0x00007f739b37deb0>

Hi, folks!

I am trying to pair a few devices (ikea switches and remotes and aqara cube) with zigbee2mqtt and I just cannot do it. These are the steps I made til now. Did I do something wrong?

These are the steps I took

-Prepare the USB dongle. There are a few steps I did here, but mainly I followed this tut right here https://notenoughtech.com/home-automation/flashing-cc2531-without-cc-debugger/
-Create a new user that will manage everything mqtt related by going to Configuration -> Users. Note: This name cannot be homeassistant or addon, those are reserved usernames. Use this name and password for Mosquitto Broker and zigbee2mqtt

Mosquitto broker

-Go to Supervisor -> Add-on store -> install MQTT broker.
-Set it up and start it
Configuration file should look something like this

logins:
  - username: USERNAME
    password: PASSWORD
anonymous: false
customize:
  active: false
  folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false

zigbee2mqtt

-Go to https://github.com/danielwelch/hassio-zigbee2mqtt and add it as a new repository
-Install zigbee2mqtt
-Go to configuration and change the user and password to match the one in the Mosquitto Broker and go to Superviser -> System and press the 3 dotted line on Host system and select Hardware. Copy the long string on serial. Something with Texas in it. (ex: /dev/serial/by-id/usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B0008B86866-if00) That is the serial port for the USB dongle
-Change the mqtt server address to ‘mqtt://[IP_of_HA]:[PORT]’. Port should be the port for mqtt. Same as the broker.
-Change the permi_join to true when pairing devices. Change it back to false afterwards for security reasons

Configuration file should look something like this:

data_path: /share/zigbee2mqtt
external_converters: []
devices: devices.yaml
groups: groups.yaml
homeassistant: true
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://[IP_of_HA]:1883'
  user: USERNAME
  password: PASSWORD
serial:
  port: >-
    /dev/serial/by-id/usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B0008B86866-if00
advanced:
  log_level: info
  pan_id: 6754
  channel: 11
  network_key:
    - 1
    - 3
    - 5
    - 7
    - 9
    - 11
    - 13
    - 15
    - 0
    - 2
    - 4
    - 6
    - 8
    - 10
    - 12
    - 13
  availability_blocklist: []
  availability_passlist: []
device_options: {}
blocklist: []
passlist: []
queue: {}
experimental: {}
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

-Save the config and restart the add-on
-Restart HA
-Go to the Mosquitto broker add-on and check the logs. Then go to ZigBee2MQTTand check the logs. There should not be any errors.

Some extra unnecessary steps

-Add this to your configuration.yaml to integrate in Lovelace on/off options for Allowing devices to join

mqtt:
  broker: core-mosquitto # This will have to be your MQTT broker, Mosquitto add-on is recommended.
  discovery: true

input_boolean:
  zigbee_permit_join:
    name: Allow devices to join
    initial: off
    icon: mdi:cellphone-wireless

timer:
  zigbee_permit_join:
    name: Time remaining
    duration: 600 # Updated this to the number of seconds you wish

sensor:
  - platform: mqtt
    name: Bridge state
    state_topic: "zigbee2mqtt/bridge/state"
    icon: mdi:router-wireless

And this to automations.yaml

automation:
  - id: enable_zigbee_join
    alias: Enable Zigbee joining
    trigger:
      platform: state
      entity_id: input_boolean.zigbee_permit_join
      to: 'on'
    action:
    - service: mqtt.publish
      data:
        topic: zigbee2mqtt/bridge/config/permit_join
        payload: 'true'
    - service: timer.start
      data:
        entity_id: timer.zigbee_permit_join
  - id: disable_zigbee_join
    alias: Disable Zigbee joining
    trigger:
    - entity_id: input_boolean.zigbee_permit_join
      platform: state
      to: 'off'
    action:
    - data:
        payload: 'false'
        topic: zigbee2mqtt/bridge/config/permit_join
      service: mqtt.publish
    - data:
        entity_id: timer.zigbee_permit_join
      service: timer.cancel
  - id: disable_zigbee_join_timer
    alias: Disable Zigbee joining by timer
    trigger:
    - platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.zigbee_permit_join
    action:
    - service: mqtt.publish
      data:
        topic: zigbee2mqtt/bridge/config/permit_join
        payload: 'false'
    - service: input_boolean.turn_off
      data:
        entity_id: input_boolean.zigbee_permit_join

And this as an entities:

type: entities
entities:
  - entity: input_boolean.zigbee_permit_join
  - entity: timer.zigbee_permit_join
  - entity: sensor.bridge_state
show_header_toggle: false
title: Zigbee

Ok, I got the ikea switch to work by resetting it with 4 fast presses, then waiting about 10 seconds, then a long press then a few short presses.

Pff! This zigbee thing is like magical incantations. Jeez!

Aaaand after pairing 3 Ikea switches, 1 Ikea remote and 1 Ikea bulb, I cannot pair other devices that I still have to pair (3 Ikea bulbs, 1 remote, 1 switch)

I am going crazy with this shitty technology. Any suggestions? I changed the battery on the remote as I was told that they might not pair if they have low battery. Still nothing.

Getting devices is pairing mode is hard to get as there is not much feedback. Sometimes when getting the procedure right requires uou to keep pressing the button every 1 second to keep the device up.

I got such problems using xiaomi devices (especially cubes). Make sure you are close to the coordinator or the closest router when doing this and as you mentioned, have a good baterry. I had a sensor pulsing blue on the status led, but didn’t want to pair until I put in a new baterry and paired on 1st try.

Also try putting you z2m log level to debug and watch logs for pairing try messages.

Thank you, Marius! In the end I went with Sonoff Zigbee Bridge and ZHA. It went smooth.