From 69fb9f10fce4ab58a2add71dc43da4250cfe3479 Mon Sep 17 00:00:00 2001 From: koenkk Date: Sat, 7 Oct 2023 08:46:43 +0200 Subject: [PATCH] fix(ignore): Export ZclHeader type https://github.com/Koenkk/zigbee2mqtt/issues/19129 --- src/controller/model/endpoint.ts | 4 ++-- src/zcl/index.ts | 2 ++ src/zcl/zclFrame.ts | 10 ++-------- src/zcl/zclHeader.ts | 10 ++++++++++ 4 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 src/zcl/zclHeader.ts diff --git a/src/controller/model/endpoint.ts b/src/controller/model/endpoint.ts index 755e1a6a2b..d6e013c08d 100644 --- a/src/controller/model/endpoint.ts +++ b/src/controller/model/endpoint.ts @@ -883,7 +883,7 @@ class Endpoint extends Entity { public waitForCommand( clusterKey: number | string, commandKey: number | string, transactionSequenceNumber: number, timeout: number, - ): {promise: Promise<{header: KeyValue; payload: KeyValue}>; cancel: () => void} { + ): {promise: Promise<{header: Zcl.ZclHeader; payload: KeyValue}>; cancel: () => void} { const cluster = Zcl.Utils.getCluster(clusterKey); const command = cluster.getCommand(commandKey); const waiter = Entity.adapter.waitFor( @@ -891,7 +891,7 @@ class Endpoint extends Entity { transactionSequenceNumber, cluster.ID, command.ID, timeout ); - const promise = new Promise<{header: KeyValue; payload: KeyValue}>((resolve, reject) => { + const promise = new Promise<{header: Zcl.ZclHeader; payload: KeyValue}>((resolve, reject) => { waiter.promise.then( (payload) => resolve({header: payload.frame.Header, payload: payload.frame.Payload}), (error) => reject(error), diff --git a/src/zcl/index.ts b/src/zcl/index.ts index d79ea226b0..2dad440bdb 100644 --- a/src/zcl/index.ts +++ b/src/zcl/index.ts @@ -10,6 +10,7 @@ import PowerSource from './definition/powerSource'; import EndpointDeviceType from './definition/endpointDeviceType'; import ManufacturerCode from './definition/manufacturerCode'; import ZclFrame from './zclFrame'; +import ZclHeader from './zclHeader'; import ZclStatusError from './zclStatusError'; import * as TsType from './tstype'; @@ -28,4 +29,5 @@ export { FrameControl, EndpointDeviceType, ZclStatusError, + ZclHeader, }; \ No newline at end of file diff --git a/src/zcl/zclFrame.ts b/src/zcl/zclFrame.ts index c47077db0f..50df156084 100644 --- a/src/zcl/zclFrame.ts +++ b/src/zcl/zclFrame.ts @@ -1,4 +1,5 @@ -import {Direction, Foundation, DataType, BuffaloZclDataType, FrameControl} from './definition'; +import {Direction, Foundation, DataType, BuffaloZclDataType} from './definition'; +import ZclHeader from './zclHeader'; import * as Utils from './utils'; import BuffaloZcl from './buffaloZcl'; import {TsType as BuffaloTsType} from '../buffalo'; @@ -10,13 +11,6 @@ const MINIMAL_FRAME_LENGTH = 3; // eslint-disable-next-line type ZclPayload = any; -interface ZclHeader { - frameControl: FrameControl; - manufacturerCode: number; - transactionSequenceNumber: number; - commandIdentifier: number; -} - const ListTypes: number[] = [ BuffaloZclDataType.LIST_UINT8, BuffaloZclDataType.LIST_UINT16, diff --git a/src/zcl/zclHeader.ts b/src/zcl/zclHeader.ts new file mode 100644 index 0000000000..6411c8db10 --- /dev/null +++ b/src/zcl/zclHeader.ts @@ -0,0 +1,10 @@ +import {FrameControl} from './definition'; + +interface ZclHeader { + frameControl: FrameControl; + manufacturerCode: number; + transactionSequenceNumber: number; + commandIdentifier: number; +} + +export default ZclHeader;