Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
11.79k stars 1.64k forks source link

Sonoff Zigbee3.0 USB Dongle pairing issues #9117

Closed notenoughtech closed 2 years ago

notenoughtech commented 2 years ago

I got serious pairing issues with various Zigbee 3.0 end devices. Sonoff Zigbee3.0 USB Dongle was using {"maintrel":1,"majorrel":2,"minorrel":7,"product":1,"revision":20210120,"transportrev":2},"type":"zStack3x0"} and the latest firmware after a successful flash. With the latest firmware, I was not able to get anything to pair - no MQTT messages about the interview process. So I reverted back to the 20210120 revision and I was able to pair Aqara TVOC and IKEA button, but Sonoff devices or Xiaomi buttons were not even entering the interview stage. The same devices were tested with ZZH and CC2531 and I was able to pair and use the devices.

There isn't much information I can share, as the log wasn't being populated. Happy to try things out

castorw commented 2 years ago

@Koenkk @oferwald It seems this fix didn't completely resolve this issue. I will be performing some more tests on this. However I suspect there is similar problem with the TCLK table and therefore joining a ZB3 device might fail due to inability to store APS link key information which is required by spec R21+.

The keyAttributes field is set to 0x00 but apparently this should be 0xff.

I will test this more thoroughly in the upcoming days. Thank you for your patience.

oferwald commented 2 years ago

Hi,

I want to thank @castorw for his amazing help in fixing this issue for me, I am writing the cause and process that was used that enabled me to pair devices again, having learned some more on zigbee and stuff. :)

NOTICE - This worked for me, YMMV!!! kids, don't do this at home unless you know what you are doing, it is probably easier to re-pair all routers (not in my case, with 30 routers that some are inside walls, when pairing seemed off)

PLEASE BACKUP BEFORE THIS, IF YOU ARE NOT SURE OF WHAT YOU ARE DOING, JUST DON'T!!!

backup your old coordinator_backup.json, and if things go awry, just clear nvram again, and use the old backup file

The root cause was apparently an EPID conflict, according to @castorw some CC2531 versions used "extended_pan_id": "dddddddddddddddd" instead of the ieee address of the device, and when a new device was trying to pair the coordinator and router were conflicting.

so, how do you fix this? shutdownz2m clear the nvram of your current coordinator with znp nvram_reset, for me it was: python zigpy_znp/tools/nvram_reset.py /dev/ttyUSB1

now edit your coordinator_backup.json add the line "extended_pan_id": "dddddddddddddddd",

for me it was just below "pan_id"

restart your z2m

live happily ever after (maybe)

I assume that a better fix will be provided in some near future. 👍

l0rda commented 2 years ago

I had great difficulties paiting Xiaomi Aquera devices with the stock firmware. Also when pairing was done half, or in another app, the only way to re-initiate the pairing seemed to be to reflash the device with new mac

I finally managed to pair the devices with the development branch version: CC1352P2_CC2652P_launchpad_coordinator_20220103.zip

So far seems to be working fine. Pairing took a lot of time, and only finished after 20 or so times clicking the buttons shortly to finish the process. Will continue monitoring if anything locks up after a while.

i confirm, successfully paired 5 xiaomi sensors with this stick firmware, but only after 20-30 times. I still cannot pair ikea bulbs.

danneh82 commented 2 years ago

I seem to be having the same issue but not 100% sure.

I migrated from a cc2531 to the zigbee3.0 following the below guide to copy the IEEE image

I had a few ikea switches batteries die which wouldn't pair again.

I've flashed the sniffer firmware on a spare cc2531. When putting the switch into pairing mode i see these errors:-

image

Checking Settings => raw and the coordinator backup the EPID is matching the coordinator IEEE image

image

oferwald so, how do you fix this? shutdownz2m clear the nvram of your current coordinator with znp nvram_reset, for me it was: python zigpy_znp/tools/nvram_reset.py /dev/ttyUSB1 now edit your coordinator_backup.json add the line "extended_pan_id": "dddddddddddddddd", restart your z2m

for the above fix can i do that from within home assistant or do i need to plug the dongle into a pc?

Does the dongle then pick up the EPID from the backup file and right it to nvram?

oferwald commented 2 years ago

The dongle should pick up the EPID from the backup file after you reset its nvram.

I ended up resetting most of my routers on the network anyhow, which was a huge pita, but things seem to work better now.

I believe that @castorw is probably working on a better fix for this.

SkarfyFPV commented 2 years ago

Hi there, I am having the same problem and trying to apply this fix, but I am new to all of this and I cannot find the way (or the shell) to run this command: python zigpy_znp/tools/nvram_reset.py /dev/ttyUSB1. I did the Home Assistant installation following the official doc: https://www.home-assistant.io/installation/raspberrypi but I didn't install Home Assistant Container... Please any help will be appreciated.

SkarfyFPV commented 2 years ago

How can I delete the NVRAM without access to the shell? Or how can I access the shell? Thanks

oferwald commented 2 years ago

@SkarfyFPV My suggestion is that you just take the stick out to any computer that you can install zigpy on and have shell access to.

SkarfyFPV commented 2 years ago

Thank you @oferwald, this is a good idea. Would you recommend using docker containers instead next time a start from scratch?

oferwald commented 2 years ago

@SkarfyFPV I am not sure I am in a position to recommend anything, I am a simple user of this great project. I have z2m and ha both running on docker, it was probably the simplest way for me personally to get going. It has its advantages and disadvantages (mainly for HA, as I am missing the controller). But I am ok with my current setup. It mostly works :). I don't think that there is really a one solution that fits everyone, so my suggestion is to just try and find out what is best for you.

SkarfyFPV commented 2 years ago

Thank you @oferwald I really appreciate your help. I have been some time thinking about trying with docker and I think I will just get another SD and try it. Also, I see a great advantage with docker, as you can have a few containers and just run the ones you need, which seems quite good to me for quick testing. Thanks again!

danneh82 commented 2 years ago

Finally managed to reset the nvram and changed the EPID in the coordinator backup file. Happy to report that i have been able to get devices to pair again.

Almost completely back up and running bar one stubborn light which is refusing to go in pairing mode!

drogfild commented 2 years ago

@danneh82 Just to make sure (before I'm doing the same), you edited EPID in the backup file to be "dddddddddddddddd"? Previous it was same as your coordinator IEEE?

danneh82 commented 2 years ago

Yep exactly :)

SkarfyFPV commented 2 years ago

Hi! apologies, it took me more than expected to be able to test this. The result for me was unsuccessful, executed a few times :(

As I have directly installed HASS on my Pi I don't have access to the shell to run this commands, for this reason, I had to unplug my CC2652P and plug it into another Pi where I am running Debian to be able to clear the NVRAM. Maybe this is the reason for my failure.

These are the steps I followed:

  1. Shutdown z2mqtt
  2. Unplug CC2652P from HASS and plug it into another Pi with Debian
  3. Clear the NVRAM of the coordinator with znp nvram_reset, for me it was: python zigpy_znp/tools/nvram_reset.py /dev/ttyUSB0
  4. Edit my coordinator_backup.json
  5. Modify the line with tag "extended_pan_id" to show as this: "extended_pan_id": "dddddddddddddddd",
  6. Plug CC2652P into HASS Pi.
  7. Restart your z2mqtt

After these steps, my network was working with the already set devices but I could NOT pair anything else. I tried a couple of different bulbs and switches without any luck.

Any other idea that comes to your mind which may help me to sort the problem?

Thank you all!

l0rda commented 2 years ago

@SkarfyFPV i changed channel to 25 and it works as expected

SkarfyFPV commented 2 years ago

@l0rda if I change the channel then nothing works. None of the previously set devices are recognised.

rvt commented 2 years ago

Just my two cents if somebody finds this.., clearing the nvram only did not work for me but I did the below steps, but I am not sure what step really did the fix:

After this all pairing did work directly, not even I had to keep items close to the coordinator.

This was after I upgraded from the good old CC2531 chip to the sonoff zigbee3 CC2652P stick.

lordlala commented 2 years ago

I am having the exact same issue as @SkarfyFPV .

All of a sudden my zigbee devices stop working and become unresponsive. If I try and remove and re-add, they never seem to repair.

What a trainwreck zigbee is :(

Hedda commented 2 years ago

There are still several issues/problems when upgrading from any CC2530/CC2531 adapter to any CC2652/CC1352 adapter.

If you upgraded from CC2530/CC2531 to CC2652/CC1352 in a "production environment" and therefore do not want to spend a lot of time troubleshooting to try to find the root causes then the general recommendation today is to just remove and re-repair all of your mains-powered Zigbee Router devices, starting with the Zigbee Router devices closest to the Zigbee Coordinator adapter and then continue moving your aways outwards. That is not quite like starting from scratch but will still take a while if you have a lot of Zigbee Router devices.

lordlala commented 2 years ago

So, to be clear in my case I've been running this for months with absolutely no issue then all of a sudden devices stop communicating and if I remove them from zigbee2mqtt, I can never seem to re-add them, which never used to be an issue. I have no idea what changed.

rvt commented 2 years ago

I wonder if there was somebody else that did set up a coordinators, perhaps somebody in the neighborhood... wel, at least in my DB I found coordinators that where still old, perhaps U used them once... after I removed them all and restarted zigbee2mqtt things started to work again

hunterdrayman commented 2 years ago

Just adding my experience of upgrading from CC2531 to CC2562P. I have all the woes mentioned here with devices not re-pairing. I removed all the routers and I do see a successful interview of a router. It appears in configuration.yaml and in the zigbee2mqtt device map but not in the front end device list. All of the sensors etc that were registered before the swap continue to talk to the new coordinator but no new ones can be added. This is after resetting the coordinator NVRAM etc.

Fortunately I took a VM snapshot of the host before replacing my trusty old CC2531 coordinator so it's now time to do a device swap and restore. Amusingly, I sent back a recently purchased switch as being DOA - I wonder if I should admit my mistake to the vendor. Ooops!

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

SkarfyFPV commented 2 years ago

Thank you guys for chipping in. I honestly didn't find a solution for my problem and I am just waiting for a moment where I have time enough to build the HASS again from scratch... I did try all your suggestions but sadly none worked for me.

Hedda commented 2 years ago

Tip before troubleshooting further is to be sure to follow all these general advice and best practices to get a more optimal setup.

Improving Zigbee network range

Poor signal quality or interference can lead to transmission problems and show symptoms such as or errors when sending and/or receiving Zigbee messages that will cause significant degradation in Zigbee network performance. Below is some fundamental background information and tips for a Zigbee setup starting point to achieve better signal quality, coverage and range.

Following these essential optimization tips will typically resolve many known issues caused by a bad setup of Zigbee Coordinator adapter and Zigbee network mesh or Zigbee devices. At the very least taking these actions should improve most message transmitting and receiving issues caused by not knowing the basics needed to workaround related Zigbee limitations.

Understanding common causes of problems in Zigbee setups

Simple actions that should improve most Zigbee setups

Best practices to avoid pairing/connection difficulties

Verify that you try to follow recommended best practices to avoid pairing and/or connection issues:

External resources for initial Zigbee setup optimizations:

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days