From 62c5fa6babfe2f8e71855aad7ca7e501377a21f5 Mon Sep 17 00:00:00 2001 From: yateeshc <96212247+yateeshc@users.noreply.github.com> Date: Tue, 22 Aug 2023 16:30:31 -0700 Subject: [PATCH] fix: emit disconnect event when zigate unplugged --- src/adapter/zigate/adapter/zigateAdapter.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/adapter/zigate/adapter/zigateAdapter.ts b/src/adapter/zigate/adapter/zigateAdapter.ts index 05ae02c7e7..9f91d3fda6 100644 --- a/src/adapter/zigate/adapter/zigateAdapter.ts +++ b/src/adapter/zigate/adapter/zigateAdapter.ts @@ -65,6 +65,7 @@ class ZiGateAdapter extends Adapter { this.driver.on('receivedRaw', this.rawDataListener.bind(this)); this.driver.on('LeaveIndication', this.leaveIndicationListener.bind(this)); this.driver.on('DeviceAnnounce', this.deviceAnnounceListener.bind(this)); + this.driver.on('close', this.onZiGateClose.bind(this)); } /** @@ -798,6 +799,13 @@ class ZiGateAdapter extends Adapter { matcher.commandIdentifier === payload.frame.Header.commandIdentifier && matcher.direction === payload.frame.Header.frameControl.direction; } + + private onZiGateClose(): void { + if (!this.closing) { + this.emit(Events.Events.disconnected); + } + } + } export default ZiGateAdapter;