Fix: zStack adapter: Do not remove device when receiving a leave indication with rejoin flag set to true #830
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 therejoin
flag set totrue
. 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):rejoin
flag. This means they might have the same issue. Or leave requests withrejoin=true
are already filtered out by the devices and not passed on.