Koenkk / zigbee-herdsman

A Node.js Zigbee library
MIT License
481 stars 299 forks source link

deconz driver/adapter (for ConBee/RaspBee Zigbee Coordinator) does not support joining/pairing via install code (or qr code) #1184

Open Hedda opened 1 month ago

Hedda commented 1 month ago

deconz driver/adapter (for ConBee/RaspBee Zigbee Coordinator) does not support joining/pairing via install code (or qr code), but FYI; Dresden-Elektronik developer has now updated the deCONZ Serial Protocol documentation to v1.22 with info on install codes. See:

Originally posted by @manup in https://github.com/dresden-elektronik/deconz-serial-protocol/issues/20#issuecomment-2344518503

_Sorry this took a while, I had reworked the document since the former .docx based one was messy to update. The document references are in a bit rough shape but that's for another version. The new version 1.22 has now been uploaded http://deconz.dresden-elektronik.de/raspbian/deCONZ-Serial-Protocol_en_1.22.pdf_

There is a new small section 6.2.3 Zigbee Install Codes which describes the basic usage.

As reference how it works in deCONZ the following sources might be helpful as well:

Calculating the derived Link Key from Zigbee Install Code (I think ZHA and Z2M already have similar code): https://github.com/dresden-elektronik/deconz-rest-plugin/blob/master/crypto/mmohash.cpp

_How the install code is processed by the REST-API and set to the firmware: https://github.com/dresden-elektronik/deconz-rest-plugin/blob/0e2dc155e85893b439f354cd5d764e414ad0ed0c/rest_devices.cpp#L1090_

Originally posted by @manup in https://github.com/dresden-elektronik/deconz-serial-protocol/issues/20#issuecomment-2344518503

6.2.3 Zigbee Install Codes
The Serial Protocol and firmware doesn’t support Zigbee Install Codes directly. In order to join a
device via Install Code, a device specific Link Key needs to be derived from the Install Code by
the host application.
This 16-byte Link Key together with the device MAC address can than be configured by a Write Parameter Request (0×0B) for the Link Key parameter (0×19).
Once configured, during joining process, the device will receive the Network Key encrypted with
the Link Key instead of the global Truster Center Link Key.

A C++ OpenSSL reference implementation for the key derivation can be found at: https://github.com/dresden-elektronik/deconz-rest-plugin/blob/master/crypto/mmohash.cpp

Maginos2210 commented 1 month ago

@Hedda: Thank you for the information. I'm totally new in the field of home automation, so forgive my beginner question:

Is there any guide on what I have to do now to get my Bosch Thermostat 2 working with a conbee II stick? How can I calculate the Link Key from the file mmohash.cpp? And what do I have to do then?

Thank you for your help.

Maginos

Hedda commented 1 month ago

Is there any guide on what I have to do now to get my Bosch Thermostat 2 working with a conbee II stick?

As long as you using any ConBee adapter then you are out of luck until install codes function is added the deconz driver here. See:

"Support for commissioning Zigbee 3.0 devices via "Install Code" or "QR Code" has so far only been implemented for 'zstack' (Texas Instruments ZNP) and 'ember' (Silicon Labs EmberZNet) adapter type radios in Zigbee2MQTT. Other radio adapter types are either missing support in their respective adapter/driver for zigbee-herdsman or more likely missing in the manufacturer's firmware commands/APIs and documentation."

It means that unless you are a developer that program and can add that feature to the deconz driver/adapter code in zigbee-herdsman then there is nothing you can do as long as you are using a ConBee (or RaspBee) adapter as your Zigbee Coordinator.

So if you are an end-users looking for a work around that today without it being supported in the deconz driver/adapter you have to migrate to either a 'zstack' (Texas Instruments ZNP) or 'ember' (Silicon Labs EmberZNet) adapter, ...but there is a catch with migrations to/from deconz adapters as well because the deconz driver/adapter in zigbee-herdsman (and thus Zigbee2MQTT) does yet not support backup and restore for Zigbee network from or to ConBee/RaspBee, and therefore you currently would need to use an unofficial third-party external tools (like example zigpy-cli) to backup and restore your Zigbee network from ConBee to a Texas Instruments ZNP or Silicon Labs EmberZNet adapter (which is doable but in turn will require you to also re-pair all your devices regardless). Please respect that this is not the place to to discuss such workarounds.

How can I calculate the Link Key from the file mmohash.cpp? And what do I have to do then?

While related I believe that question too is also off-topic here in regards to specifically calculate Link Key for Bosch Thermostat 2 if you are an end-users that is now no longer using the deconz driver/adapter with ConBee/RaspBee as have instead migrated to Texas Instruments ZNP or Silicon Labs EmberZNet adapter. Regardless we do not want to spam this zigbee-herdsman feature request issue with discussions about device specific questions.

Hence, if you are and end-user and go the way of migrating to Texas Instruments ZNP or Silicon Labs EmberZNet adapter and then still need help calculating Link Keys for your Bosch Thermostat 2 devices then please post in the Zigbee2MQTT's discussions instead -> https://github.com/Koenkk/zigbee2mqtt/discussions (or in zigbee-herdsman-converters if related to changing or extending the zigbee-herdsman-converter for that device -> https://github.com/Koenkk/zigbee-herdsman-converters/issues ).

Maginos2210 commented 1 month ago

Thank you @Hedda for your explanations. I ordered a Sonoff zigbee stick with a Texas Instruments chip. With this, it should work. Migration is not needed, since the Bosch thermostat is my first device.

Hedda commented 1 month ago

@ChrisHae @manup @Haerteleric any chance one of you guys would be interested and willing to spare some of your time to take a closer look at this requested feature/function of adding support for "install codes" provisioning in deconz driver (for ConBee/RaspBee Zigbee Coordinator adapters) inside the zigbee-herdsman framework so that Zigbee2MQTT users with ConBee/RaspBee adapters can provision Zigbee devices that require install code or QR code commissioning?

This is needed for feature parity with 'zstack' (Texas Instruments ZNP) or 'ember' (Silicon Labs EmberZNet) adapters which already support this.

PS: While I can only speak for myself, think I can still say that as it stands right now many of us who are a part of the Zigbee2MQTT and overall Zigbee open source projects communities can currently not with good conscience recommend ConBee II / RaspBee II or even the ConBee III to new Zigbee2MQTT end-users as they would not be able to add any Zigbee devices that require install code / QR code for provisioning. 😞

markusmauch commented 3 weeks ago

It looks to me as if Dresden Electronik already has implemented Zigbee Install Codes. Is it realistic to hope to see this implemented for a Conbee II stick and Zigbee2MQTT in the near future?