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

Fix: zStack adapter: Do not remove device when receiving a leave indication with rejoin flag set to true #830

Merged
merged 1 commit into from
Dec 17, 2023

Conversation

slugzero
Copy link
Contributor

This fixes the zigbee-herdsman zStack adapter to properly respect the rejoin=true flag of a leave request, instead of mistaking it as an actual leave request and removing the device from the database.

Why this is required?
When the connection to the coordinator is lost, some (all?) newer ZigBee devices use a mechanism to rediscover the route which is initiated by sending a leave request with the rejoin flag set to true. The current adapter code is not evaluating this flag and therefore removes the device from the database on any leave request. I noticed this as some devices disappearing for a couple of seconds. Occasionally, some of my devices also left for good.
I do not know exactly what caused the devices to leave for good instead of only for a couple of seconds. But I think we should in general not remove any device from the database on a leave request when the rejoin=true flag is set (this is completely handled by the adapter itself).

I am 99% certain that this will fix many issues with devices randomly disappearing from the network when using zStack adapters, e.g. Koenkk/zigbee2mqtt#2693, Koenkk/zigbee2mqtt#19694, and probably others.

I don't have any non-zStack adapters to test, but I checked the code on how other devices handle this (i.e., when do they emit an deviceLeave event):

  • From what I understand, the deconz code only emits the event on its own leave requests, not on any incoming leave requests.
  • the Zigate and ezsp code also does not check the rejoin flag. This means they might have the same issue. Or leave requests with rejoin=true are already filtered out by the devices and not passed on.

@Koenkk Koenkk merged commit fe8ebb7 into Koenkk:master Dec 17, 2023
1 check passed
@Koenkk
Copy link
Owner

Koenkk commented Dec 17, 2023

Many thanks for this fix! 😄

@kirovilya could you check if for EZSP?

@kirovilya
Copy link
Contributor

I cannot accurately confirm a similar case for EZSP.
The processed frames do not have such a attribute, but there is a device status. Only the device deletion status is processed, but there are other statuses that are not processed.

image

image

image

@slugzero slugzero deleted the leave-with-rejoin-fix branch December 17, 2023 12:49
@Cjkeenan
Copy link

I am 99% certain that this will fix many issues with devices randomly disappearing from the network when using zStack adapters, e.g. Koenkk/zigbee2mqtt#2693, Koenkk/zigbee2mqtt#19694, and probably others.

Has this been confirmed? Because I am still experiencing the same dropouts on my hue motion sensor after updating with the fix. Or does this fix also need a firmware update on the radio too?

Current Versions:
Zigbee2MQTT version
1.39.0 commit: 0326926
Coordinator type
zStack3x0
Coordinator revision
20220219
Coordinator IEEE Address
0x00124b0024c0f1e6
Frontend version
0.7.2
19.62.0
0.50.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants