Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zigbee Examples are not fully working with Hubitat and HomeAssistant with ConbeeIII zigbee dongle #10868

Open
1 task done
ilker-aktuna opened this issue Jan 16, 2025 · 22 comments
Assignees
Labels
Area: Zigbee Issues and Feature Request about Zigbee Status: To be implemented Selected for Development Type: For reference Common questions & problems

Comments

@ilker-aktuna
Copy link

ilker-aktuna commented Jan 16, 2025

Board

esp32-c6 dev module

Device Description

esp32-c6 with zigbee

Hardware Configuration

zigbee end device

Version

latest master (checkout manually)

IDE Name

Arduino IDE

Operating System

Windows 11

Flash frequency

40

PSRAM enabled

yes

Upload speed

115200

Description

I am trying the Arduino zigbee examples with esp32-c6 board.
I used the on/off switch , color dimmer.
I also tried the motion sensor template from this post:
#10684

On my Hubitat C7 and C8 hubs, the device is being detected. Then sometimes, it completes the pairing , sometimes gets stuck at pairing.
If the pairing completes, sometimes I can control the device (on/off , or level commands)
Sometimes, it does not work. If I start pairing again on Hubitat, it can control the device (while pairing is active) but then starts failing.

What I see on Arduino logs is that the device restarts pairing.
if I put the log level to "verbose" , I get this line before restart:

13:08:27.383 -> Connecting to network
13:08:27.383 -> .............................[ 5289][V][ZigbeeCore.cpp:344] factoryReset(): Factory resetting Zigbee stack, device will reboot
13:08:30.300 -> .ESP-ROM:esp32c6-20220919

I see in the code:

case ESP_ZB_ZDO_SIGNAL_LEAVE:  // End Device + Router
      // Device was removed from the network, factory reset the device
      if ((zigbee_role_t)Zigbee.getRole() != ZIGBEE_COORDINATOR) {
        Zigbee.factoryReset();
      }
      break;

But Hubitat does not remove the device. So how does it go into that ?

@P-R-O-C-H-Y was trying to help me identify the problem before Christmas. But for the last 3 weeks I didn't receive anything from him.
I hope he's OK.

I also tried the same device with same examples on a friend's HomeAssistant (Raspberry PI) with Conbee III zigbee dongle.
On HE, pairing never completes. I assume these examples are not tested on 3rd party devices. So this issue is not specific to me and would occur on most of the setups with 3rd party Zigbee devices.

pairing_2.zip

Btw, @P-R-O-C-H-Y had asked me to get a zigbee sniff using another esp32-c6 and sent me a guide. Following the guide, I was able to get the attached capture. I am not familiar with Zigbee sniffs so I'm not sure if this helps.
If anything else is required, I'd be glad to capture.

About the attached traces:
Hubitat actually detects the device and pairs successfully. But the device (esp32) reports it has failed.
So the first file is capture when my hub has already paired and shows a motion sensor.
Then I removed the sensor from zigbee network (Hubitat) and restarted capture (and esp32) to record a full failing scenario.
That is the second capture file. I hope it is clear for you and you can see the problem in these traces.

pairing_2.zip

Sketch

zigbee ED examples
last tested the following one (Occupancy Sensor):
https://github.com/espressif/arduino-esp32/pull/10720/commits/77df256f5db51c139715cc73927dccd38d652cfb#diff-03e926d0f636dc753b1e0aad6f247e66376e60289d89800dde02525f747d2d62

Debug Message

-

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@ilker-aktuna ilker-aktuna added the Status: Awaiting triage Issue is waiting for triage label Jan 16, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y self-assigned this Jan 16, 2025
@P-R-O-C-H-Y
Copy link
Member

Hello @ilker-aktuna, don't worry I am fine, but there were a lot of issues and ongoing tasks after Christmas vacation, so I did not get yet to your issue. Sorry about that.

I am using the HomeAssistant running on a RPi, and I am using the SONOFF Zigbee 3.0 USB Dongle Plus. I did not face any issues with this combo. Also there are other guys with other 3rd party Dongles running a Zigbee2MQTT or HA successfully.
We cannot guarantee that all combinations or providers will work 100%.

I will check the logs from the sniffer and try to figure out what is happening there.

Regarding:

But Hubitat does not remove the device. So how does it go into that ?

It must have and a leave command, otherwise this won't happen. Let me check the logs :)

@ilker-aktuna
Copy link
Author

ok. I am here if you ask for more zigbee sniff.
Also my friend will prepare a zigbee sniff setup with his HA + Conbee III dongle.

@P-R-O-C-H-Y P-R-O-C-H-Y added Area: Zigbee Issues and Feature Request about Zigbee and removed Status: Awaiting triage Issue is waiting for triage labels Jan 16, 2025
@P-R-O-C-H-Y
Copy link
Member

@ilker-aktuna Will you be able to try with a esp-zigbee-sdk example? To check if there is something in the Zigbee library missing (or not working) or the same behavior is when using the esp-zigbee-skd directly. You can check the examples here. Just one notice, currently the esp-zigbee-sdk latest version is 1.6.2, in Arduino we use for now the 1.6.0 so that may be the only difference. But I plan to update it soon.

@ilker-aktuna
Copy link
Author

@P-R-O-C-H-Y
Do you want me to just use the examples from SDK ? Or do you want me to update the esp32 version on my Arduino IDE , then use them ?

@P-R-O-C-H-Y
Copy link
Member

@ilker-aktuna Please you their example directly. So you need to install ESP-IDF and build/flash the esp-Zigbee-sdk example.

@P-R-O-C-H-Y
Copy link
Member

P-R-O-C-H-Y commented Jan 17, 2025

@ilker-aktuna Also another test you can do is add esp_zb_secur_link_key_exchange_required_set(false); here before the esp_zb_start();

ESP_ERROR_CHECK(esp_zb_start(false));

Can you give it a try? Thanks

@ilker-aktuna
Copy link
Author

@P-R-O-C-H-Y
I am on vacation at my winterhouse and I don't have my main computer with IDF with me. I have a less powerful notebook with Arduino IDE. I can't install IDF at the moment to this notebook.
But I have my sniffer and 2 spare esp32c6 with me.
So I can do the test on your last post.
Is it ok if I just edit the cpp file ? Should I do something to compile it before building the Arduino sketch ?

Btw, you had asked me to use your unmerged code from P-R-O-C-H-Y:feat/zigbee-multi-sensor so I am still using it. Should I update ?
On my ZşgbeeCore.cpp , following line is not on 97 but on 98 :
ESP_ERROR_CHECK(esp_zb_start(false));

@P-R-O-C-H-Y
Copy link
Member

@ilker-aktuna The best will be to use the master branch of ESP32 Arduino Core for any future ongoing work :)
There were other fixes merged to the Zigbee library already.

Is it ok if I just edit the cpp file ? Should I do something to compile it before building the Arduino sketch ?
Yes, just edit the .cpp file and build/upload through the Arduino IDE.

@ilker-aktuna
Copy link
Author

I started with the simplest example (on/off switch)
it seems to work fine.
Moving to the dimmer...

@ilker-aktuna
Copy link
Author

ilker-aktuna commented Jan 17, 2025

Dimmable Light works as well.
And it is stable. It works even after pairing has stopped and even after power off/on.
To see if the solution was "esp_zb_secur_link_key_exchange_required_set(false);" , I removed it and recompiled.
It then fails completig pairing.
After setting it again, it works.

I also tried color light now. On/off and level commands work but color does not.
As described in this issue:
#10669

I guess my Zigbee hub (Hubitat) sends only Hue&Sat values.
But the examples do not include anything with hue and sat. How can I make the device receive HSL ?

Do you have any update on that ?

I will try the motion sensor when I'm back home. I don't have the sensor with me because my friend is keeping it :(

@ismetfaik
Copy link

Dear @P-R-O-C-H-Y , I have also tested Arduino Zigbee examples by adding the line "esp_zb_secur_link_key_exchange_required_set(false);". All three On/Off Light, Dimmable Light and Color Dimmable Light examples are working with the setup: RPi2 + Conbee III <-> Waveshare ESP32-C6 Zero.

My question is is there any security / vulnerability consequences of adding that line?

Thank you for your efforts and help.

@ilker-aktuna
Copy link
Author

@P-R-O-C-H-Y
this problem seems to be resolved by that setting.
Will you be merging it as an option on the Arduino libs ?
Is there anything else you suggest to test ? Or should we have a look at something on the hub side ? (both HA and Hubitat)

and also what about the HSL based commands for color light ?

@P-R-O-C-H-Y
Copy link
Member

P-R-O-C-H-Y commented Jan 20, 2025

@ismetfaik @ilker-aktuna
Hubitat supports the Zigbee 3.0 from the C8 model. So all models before are now a legacy devices. They can be added to the network but as the legacy device has not transported the APS key, and its security is not ensured.

So as this is "not recommended" I won't add any API to enable this. I will mark this issue as a "For Reference" if anybody have same issue and want to use a legacy device in Zigbee 3.0 network.

@P-R-O-C-H-Y
Copy link
Member

@ilker-aktuna about the HSL I have this in my backlog, will be added (no ETC yet).

@P-R-O-C-H-Y P-R-O-C-H-Y added the Type: For reference Common questions & problems label Jan 20, 2025
@ilker-aktuna
Copy link
Author

@ismetfaik @ilker-aktuna Hubitat supports the Zigbee 3.0 from the C8 model. So all models before are now a legacy devices. They can be added to the network but as the legacy device has not transported the APS key, and its security is not ensured.

I didn't know that. From the UI perspective it seems like C7 supports Zigbee 3.0 but if you're saying so, OK.
What about my friend's HA setup ? He has Conbee III and this dongle seems to support Zigbee 3.0 as well.
Yet it does not work without setting "esp_zb_secur_link_key_exchange_required_set(false);"

with your comment, we can close this issue.
Then, where can we follow up for HSL ?

@P-R-O-C-H-Y
Copy link
Member

@ismetfaik @ilker-aktuna Hubitat supports the Zigbee 3.0 from the C8 model. So all models before are now a legacy devices. They can be added to the network but as the legacy device has not transported the APS key, and its security is not ensured.

I didn't know that. From the UI perspective it seems like C7 supports Zigbee 3.0 but if you're saying so, OK. What about my friend's HA setup ? He has Conbee III and this dongle seems to support Zigbee 3.0 as well. Yet it does not work without setting "esp_zb_secur_link_key_exchange_required_set(false);"

with your comment, we can close this issue. Then, where can we follow up for HSL ?

Yes ConBee III supports the Zigbee 3.0, so I am not sure what's wrong there. But if this fixes the issue it may be on the ConBee side. Maybe good option would be to ask for support there.

HSL feature request is #10669 opened by you :)

@ilker-aktuna
Copy link
Author

ilker-aktuna commented Jan 20, 2025

@P-R-O-C-H-Y
Btw, for Hubitat I think we are in a HUGE mistake and we should not close this issue.
Because now I am at my winterhouse with the C8 hub installed. And all I wrote from friday to today is tests on the C8 hub.
See here:

Image

And this is the C7 hub that I use on my main house (before friday):

Image

So on the C8 (which has zigbee 3.0) esp32 zigbee does not work if we do not disable key exchange as you proposed.

I think this is not a zigbee 3.0 issue , and Conbee III results are supporting this.

Also on the C7 hub, even if Zigbee 3.0 is not supported, I would expect the esp32 zigbee to work , because I have many modern (new) zigbee devices connected to the C7 hub. The only thing that did not work is the esp32-c6 (when key exchange is not disabled)
Even if this WAS a Zigbee 3.0 issue, then I believe modern zigbee endpoint devices support fallback to Zigbee 2.0 or whatever the previous version is. maybe they do not force that key exchange method if the Hub doesn't support it.

@P-R-O-C-H-Y
Copy link
Member

P-R-O-C-H-Y commented Jan 20, 2025

@ilker-aktuna We know how to fix (workaround) it now by adding the line to the code.
Can you please ask on the Hubitat support if they have correctly implemented the exchange key (APS key)? I see no way of fixing it there in Zigbee library, so that why this issue can be closed.

@ilker-aktuna
Copy link
Author

ilker-aktuna commented Jan 20, 2025

@P-R-O-C-H-Y
I can ask it to Hubitat support, though I don't believe we'll receive an answer towards a resolution.

On the other hand, I believe this is not a Hubitat issue. Because now we have at least 2 devices which we know that supports Zigbee 3.0 (Hubitat C8 and Conbee III)
And I would like to emphasize again that my Hubitat hubs (C7 and C8) can pair and work with all other Zigbee endpoints (except esp32-c6). I believe Zigbee endpoint devices should be able to fall back to other methods when one method is not accepted on the coordinator side.

I see no way of fixing it there in Zigbee library, so that why this issue can be closed.

Maybe an option to disable that key exchange in Arduino sketch ? Or better , an automatic action if pairing does not complete when key exchange is enabled.
I think there are things that can be done, if we want to support as many devices as possible.

@P-R-O-C-H-Y
Copy link
Member

P-R-O-C-H-Y commented Jan 21, 2025

I will mostly add an API which can be added to the Sketch to enable/disable the key exchange. I am reopening this to see the issue open and don't forget on this.

The Hubitat may have something "wrongly" implemented (just guessing) or in esp-zigbee-sdk there is something wrong.

And I would like to emphasize again that my Hubitat hubs (C7 and C8) can pair and work with all other Zigbee endpoints (except esp32-c6). I believe Zigbee endpoint devices should be able to fall back to other methods when one method is not accepted on the coordinator side.

This needs to be done on the esp-zigbee-sdk side, not in the Arduino library I guess.

@P-R-O-C-H-Y P-R-O-C-H-Y reopened this Jan 21, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y added the Status: To be implemented Selected for Development label Jan 21, 2025
@ilker-aktuna
Copy link
Author

Thanks.
I already wrote this on Hubitat community forums.
Asked for attention from the staff.
I'm not sure if they will be interested or not. I'll write back here if I receive any response.

@ilker-aktuna
Copy link
Author

ilker-aktuna commented Feb 2, 2025

@P-R-O-C-H-Y
motion sensor example did not work in my scenario. I updated the thread here:
#10684

Btw, my sensor also has temperature capability. (and also most of the zigbee motion sensor devices/profiles have dual function as motion & temperature)
But I could not find a way of adding 2 capabilities to one device on Arduino sketch.
If I define another endpoint with a new endpoint number, my hub only gets the first endpoint.
If I define both endpoints with same number then code crashes.

Should we have a separate device type supporting both motion and temperature ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Zigbee Issues and Feature Request about Zigbee Status: To be implemented Selected for Development Type: For reference Common questions & problems
Projects
None yet
Development

No branches or pull requests

3 participants