Connect to existing Zigbee network

I’ve just installed zigbee2mqtt and I want to connect to my existing zigbee network. I’ve entered pan id, ext pan id, channel and the network key into the config, but my devices are not showing up. Paring is also enabled.

I’ve already tried this with the com.zsmartsystem.zigbee library before and there the software was able to detect the device without resetting or rejoining them. Is this also possible with zigbee2mqtt?

Edit: I’ve also tried to pair a Innr bulb by resetting it, but I got the following error:
Error while parsing to ZpiObject 'TypeError: Cannot read property ‘updateLastSeen’ of undefined

I found a workarround for my problem. I modified the controller.js in the zigbee_herdsman module so that when a device is announced it is automatically added to the devices. To do this I made the following changes to the onDeviceAnnounce method:

onDeviceAnnounce(payload) {
    debug.log(`Device announce '${payload.ieeeAddr}'`);
    const device = model_1.Device.byIeeeAddr(payload.ieeeAddr);

    if (!device) {

With this change I only have to disconnect and reconnect my lamps and then they are automatically added as new devices and they are working!

But I have now a different problem. I tried to group some of my Philipps Hue lamps, but when I send a command to a group all my lamps react to the command. In the description of the group configuration I found an info that a broadcast is sent for groups and that the lamps itself must know to which group they belong. I don’t know how the Hue bridge handles this. Is this something that simply doesn’t work for hue lamps?

I’ve now also used my code change to take over the network from my CC2531 coordinator to the CC1352P-2 coordinator that just arrived yesterday and it also worked perfectly. So I added an issue on the GitHub page to request that this will be added to the main repository:

With the CC1352P-2 I now get better performance when switching big groups of lamps than with the official Hue bridge! But the group commands are still switching all my lamps. So I guess this is something that does not work with Philipps Hue lamps or is at least only used to control all of the lamps at once.

I now also found out why the group commands did not work as expected. My lamps already had a bunch of groups configured and if the groups are only configured in the config file the software will assume that the lamps already know to which group they belong.

One solution to this is that there ist an “remove_all” mqtt command for the lamps that removes all groups. After that the lamps have to be added using the add mqtt command. With this command a configuration is sent to the lamp and it will be assigned to the group.

The solution I chose is just to try out different group id’s in the configuration until the right one is found. I had to try out 30 numbers until I got to a group id that was not used. I guess the Hue Disco app did create a whole bunch of groups. :slight_smile:

This looks awesome, thanks for the work. I’m also in the process of transitioning from cc2531 to the CC1352P-2. I’m wondering if you’re doing all of this on a Raspberry Pi? What’s your host machine?

I tried following these instructions recently to get Z2M working on a Pi, but it failed to start with the CC1352P-2. I used these instructions when I set up the CC2531.

Did you used some other set of instructions?

I’m using a Raspberry Pi 4 and I didn’t have to install anything. Maybe the device is under powered. Take a look at the dmesg messages after plugging the device in. The CC1352P-2 seems to need quite a lot of power and I attached it to a powered usb hub.

Hello @TheNetStriker
I know it’s been a long time since your post but you may be able to help me as you seem to master z2m. I’m trying to configure z2m on an existing network.

This is what I did:
1)remove coordinator_backup.json
2)modify configuration.yaml adding the following info:

  • channel: 20
  • pan_id: 0x89fb
  • ext_pan_id: [0xd2, 0x05, 0x8c, 0xdc, 0x93, 0x70, 0xac, 0x2d]
  • network_key: [ 0xe6, 0xff, 0x52, 0x32, 0x44, 0xb6, 0xed, 0x97, 0xcc, 0x00, 0x8d, 0x94, 0x89, 0x7c, 0x64, 0x12 ]

I reversed the order of the items in network_key and ext_pan_id. I’m not sure of what I should do so I tried both orders.

Unfortunately Z2M crashes. What did I do wrong?
I don’t need to include the existing devices, just join the existing network as you did.

This is my error log:

Z2M starts and run for a minute before crashing.
I can see in my LAN zigbee adapter that 2 sockets are open.
Then Z2M crashes with the following log:
`[08:37:49] INFO: Preparing to start...
[08:37:50] INFO: Socat not enabled
[08:37:53] INFO: Starting Zigbee2MQTT...
[2024-05-23 08:38:07] info: z2m: Logging to console, file (filename: log.log)
[2024-05-23 08:38:07] info: z2m: Starting Zigbee2MQTT version 1.37.1 (commit #unknown)
[2024-05-23 08:38:07] info: z2m: Starting zigbee-herdsman (0.46.6)
[2024-05-23 08:38:08] warning: zh:ezsp: Deprecated driver 'ezsp' currently in use, 'ember' will become the officially supported EmberZNet driver in next release. If using Zigbee2MQTT see #21462
[2024-05-23 08:38:11] error: zh:ezsp:uart: --> Error: Error: Recv NAK frame
[2024-05-23 08:38:11] error: zh:ezsp:uart: -!- break waiting (1)
[2024-05-23 08:38:11] error: zh:ezsp:uart: Can't send DATA frame (0,1,0): 00000004
[2024-05-23 08:38:22] error: z2m: Error while starting zigbee-herdsman
[2024-05-23 08:38:22] error: z2m: Failed to start zigbee
[2024-05-23 08:38:22] error: z2m: Check for possible solutions
[2024-05-23 08:38:22] error: z2m: Exiting...

[2024-05-23 08:38:22] error: z2m: Error: Failure send version:{"type":"Buffer","data":[0,0,0,4]}
at /app/node_modules/zigbee-herdsman/src/adapter/ezsp/driver/ezsp.ts:686:23
at Queue.execute (/app/node_modules/zigbee-herdsman/src/utils/queue.ts:35:20)
at Ezsp.version (/app/node_modules/zigbee-herdsman/src/adapter/ezsp/driver/ezsp.ts:466:24)
at Driver.startup (/app/node_modules/zigbee-herdsman/src/adapter/ezsp/driver/driver.ts:173:9)
at Controller.start (/app/node_modules/zigbee-herdsman/src/controller/controller.ts:124:29)
at Zigbee.start (/app/lib/zigbee.ts:62:27)
at Controller.start (/app/lib/controller.ts:109:27)
at start (/app/index.js:107:5)`

I advanced in my understanding of the situation.
The network configuration in z2m is actually correct. If I run z2m without ZHA, there is no problem.
But as soon as I start ZHA, Z2M crash as described in my previous message.

So the problem is eather coming from:

  • Z2M and ZHA interactions → but many people managed to make it work
  • Z2M seeing many unknown devices in the network ???

If someone has an explanation, that would be great!