zigbee-herdsman 5.0.4 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/dependabot.yml +3 -0
- package/.github/workflows/ci.yml +1 -1
- package/.github/workflows/typedoc.yaml +1 -1
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +29 -0
- package/biome.json +1 -1
- package/dist/adapter/ember/ezsp/buffalo.d.ts +0 -2
- package/dist/adapter/ember/ezsp/buffalo.d.ts.map +1 -1
- package/dist/adapter/ember/ezsp/buffalo.js +0 -4
- package/dist/adapter/ember/ezsp/buffalo.js.map +1 -1
- package/dist/adapter/ember/uart/ash.d.ts.map +1 -1
- package/dist/adapter/ember/uart/ash.js +0 -2
- package/dist/adapter/ember/uart/ash.js.map +1 -1
- package/dist/buffalo/buffalo.d.ts +5 -0
- package/dist/buffalo/buffalo.d.ts.map +1 -1
- package/dist/buffalo/buffalo.js +7 -0
- package/dist/buffalo/buffalo.js.map +1 -1
- package/dist/controller/controller.d.ts.map +1 -1
- package/dist/controller/controller.js +8 -11
- package/dist/controller/controller.js.map +1 -1
- package/dist/controller/events.d.ts +2 -1
- package/dist/controller/events.d.ts.map +1 -1
- package/dist/controller/helpers/request.d.ts.map +1 -1
- package/dist/controller/helpers/request.js +2 -1
- package/dist/controller/helpers/request.js.map +1 -1
- package/dist/controller/helpers/zclFrameConverter.d.ts +2 -4
- package/dist/controller/helpers/zclFrameConverter.d.ts.map +1 -1
- package/dist/controller/helpers/zclFrameConverter.js +2 -0
- package/dist/controller/helpers/zclFrameConverter.js.map +1 -1
- package/dist/controller/model/device.d.ts +13 -24
- package/dist/controller/model/device.d.ts.map +1 -1
- package/dist/controller/model/device.js +88 -129
- package/dist/controller/model/device.js.map +1 -1
- package/dist/controller/model/endpoint.d.ts +17 -16
- package/dist/controller/model/endpoint.d.ts.map +1 -1
- package/dist/controller/model/endpoint.js +31 -16
- package/dist/controller/model/endpoint.js.map +1 -1
- package/dist/controller/model/group.d.ts +6 -6
- package/dist/controller/model/group.d.ts.map +1 -1
- package/dist/controller/model/group.js +5 -3
- package/dist/controller/model/group.js.map +1 -1
- package/dist/controller/model/index.d.ts +1 -0
- package/dist/controller/model/index.d.ts.map +1 -1
- package/dist/controller/model/index.js +3 -1
- package/dist/controller/model/index.js.map +1 -1
- package/dist/controller/model/zigbeeEntity.d.ts +8 -0
- package/dist/controller/model/zigbeeEntity.d.ts.map +1 -0
- package/dist/controller/model/zigbeeEntity.js +11 -0
- package/dist/controller/model/zigbeeEntity.js.map +1 -0
- package/dist/controller/tstype.d.ts +39 -0
- package/dist/controller/tstype.d.ts.map +1 -1
- package/dist/zspec/zcl/buffaloZcl.d.ts +32 -17
- package/dist/zspec/zcl/buffaloZcl.d.ts.map +1 -1
- package/dist/zspec/zcl/buffaloZcl.js +257 -121
- package/dist/zspec/zcl/buffaloZcl.js.map +1 -1
- package/dist/zspec/zcl/definition/cluster.d.ts.map +1 -1
- package/dist/zspec/zcl/definition/cluster.js +156 -33
- package/dist/zspec/zcl/definition/cluster.js.map +1 -1
- package/dist/zspec/zcl/definition/clusters-typegen.d.ts +2 -0
- package/dist/zspec/zcl/definition/clusters-typegen.d.ts.map +1 -0
- package/dist/zspec/zcl/definition/clusters-typegen.js +348 -0
- package/dist/zspec/zcl/definition/clusters-typegen.js.map +1 -0
- package/dist/zspec/zcl/definition/clusters-types.d.ts +7238 -0
- package/dist/zspec/zcl/definition/clusters-types.d.ts.map +1 -0
- package/dist/zspec/zcl/definition/clusters-types.js +3 -0
- package/dist/zspec/zcl/definition/clusters-types.js.map +1 -0
- package/dist/zspec/zcl/definition/enums.d.ts +14 -6
- package/dist/zspec/zcl/definition/enums.d.ts.map +1 -1
- package/dist/zspec/zcl/definition/enums.js +15 -6
- package/dist/zspec/zcl/definition/enums.js.map +1 -1
- package/dist/zspec/zcl/definition/foundation.d.ts.map +1 -1
- package/dist/zspec/zcl/definition/foundation.js +43 -15
- package/dist/zspec/zcl/definition/foundation.js.map +1 -1
- package/dist/zspec/zcl/definition/tstype.d.ts +105 -11
- package/dist/zspec/zcl/definition/tstype.d.ts.map +1 -1
- package/dist/zspec/zcl/index.d.ts +1 -0
- package/dist/zspec/zcl/index.d.ts.map +1 -1
- package/dist/zspec/zcl/index.js.map +1 -1
- package/dist/zspec/zcl/utils.d.ts +1 -1
- package/dist/zspec/zcl/utils.d.ts.map +1 -1
- package/dist/zspec/zcl/utils.js +1 -1
- package/dist/zspec/zcl/utils.js.map +1 -1
- package/dist/zspec/zcl/zclFrame.d.ts.map +1 -1
- package/dist/zspec/zcl/zclFrame.js +32 -20
- package/dist/zspec/zcl/zclFrame.js.map +1 -1
- package/dist/zspec/zdo/buffaloZdo.d.ts +0 -6
- package/dist/zspec/zdo/buffaloZdo.d.ts.map +1 -1
- package/dist/zspec/zdo/buffaloZdo.js +0 -8
- package/dist/zspec/zdo/buffaloZdo.js.map +1 -1
- package/package.json +3 -3
- package/src/adapter/ember/ezsp/buffalo.ts +0 -5
- package/src/adapter/ember/uart/ash.ts +0 -2
- package/src/adapter/ezsp/driver/driver.ts +1 -1
- package/src/buffalo/buffalo.ts +8 -0
- package/src/controller/controller.ts +13 -16
- package/src/controller/events.ts +2 -1
- package/src/controller/greenPower.ts +4 -4
- package/src/controller/helpers/request.ts +3 -1
- package/src/controller/helpers/zclFrameConverter.ts +13 -17
- package/src/controller/model/device.ts +103 -148
- package/src/controller/model/endpoint.ts +112 -64
- package/src/controller/model/group.ts +33 -9
- package/src/controller/model/index.ts +1 -0
- package/src/controller/model/zigbeeEntity.ts +30 -0
- package/src/controller/tstype.ts +251 -16
- package/src/zspec/zcl/buffaloZcl.ts +323 -238
- package/src/zspec/zcl/definition/cluster.ts +156 -33
- package/src/zspec/zcl/definition/clusters-typegen.ts +588 -0
- package/src/zspec/zcl/definition/clusters-types.ts +7331 -0
- package/src/zspec/zcl/definition/enums.ts +14 -5
- package/src/zspec/zcl/definition/foundation.ts +43 -15
- package/src/zspec/zcl/definition/tstype.ts +118 -8
- package/src/zspec/zcl/index.ts +1 -0
- package/src/zspec/zcl/utils.ts +1 -1
- package/src/zspec/zcl/zclFrame.ts +37 -19
- package/src/zspec/zdo/buffaloZdo.ts +0 -9
- package/test/controller.test.ts +356 -896
- package/test/greenpower.test.ts +0 -12
- package/test/zcl.test.ts +13 -11
- package/test/zspec/zcl/buffalo.test.ts +216 -74
- package/test/zspec/zcl/frame.test.ts +62 -28
- package/test/zspec/zcl/utils.test.ts +4 -4
|
@@ -97,10 +97,10 @@ export enum DataType {
|
|
|
97
97
|
/** class=composite, length=0x0000-0xFFFE, non-value=0xFFFF */
|
|
98
98
|
LONG_CHAR_STR = 0x44,
|
|
99
99
|
|
|
100
|
-
/** class=composite, length=variable, non-value=
|
|
100
|
+
/** class=composite, length=variable, non-value=(length=0xFFFF) */
|
|
101
101
|
ARRAY = 0x48,
|
|
102
102
|
|
|
103
|
-
/** class=composite, length=variable, non-value=(length) */
|
|
103
|
+
/** class=composite, length=variable, non-value=(length=0xFFFF) */
|
|
104
104
|
STRUCT = 0x4c,
|
|
105
105
|
|
|
106
106
|
/** class=composite, length=max(0xFFFE * DataType) non-value=(length=0xFFFF) */
|
|
@@ -157,14 +157,12 @@ export enum BuffaloZclDataType {
|
|
|
157
157
|
|
|
158
158
|
/** @TODO strings for backwards compat in tests. Should be moved to numbers. */
|
|
159
159
|
export enum ParameterCondition {
|
|
160
|
-
STATUS_EQUAL = "statusEquals",
|
|
161
|
-
STATUS_NOT_EQUAL = "statusNotEquals",
|
|
162
160
|
MINIMUM_REMAINING_BUFFER_BYTES = "minimumRemainingBufferBytes",
|
|
163
|
-
DIRECTION_EQUAL = "directionEquals",
|
|
164
161
|
BITMASK_SET = "bitMaskSet",
|
|
165
162
|
BITFIELD_ENUM = "bitFieldEnum",
|
|
166
163
|
DATA_TYPE_CLASS_EQUAL = "dataTypeValueTypeEquals",
|
|
167
164
|
FIELD_EQUAL = "fieldEquals",
|
|
165
|
+
FIELD_GT = "fieldGT",
|
|
168
166
|
}
|
|
169
167
|
|
|
170
168
|
export enum FrameType {
|
|
@@ -192,3 +190,14 @@ export enum StructuredIndicatorType {
|
|
|
192
190
|
/** Remove element from the set/bag */
|
|
193
191
|
WriteRemove = 0x20,
|
|
194
192
|
}
|
|
193
|
+
|
|
194
|
+
/** Mapping of descriptive string power to source bits. */
|
|
195
|
+
export enum PowerSource {
|
|
196
|
+
Unknown = 0,
|
|
197
|
+
"Mains (single phase)" = 1,
|
|
198
|
+
"Mains (3 phase)" = 2,
|
|
199
|
+
Battery = 3,
|
|
200
|
+
"DC Source" = 4,
|
|
201
|
+
"Emergency mains constantly powered" = 5,
|
|
202
|
+
"Emergency mains and transfer switch" = 6,
|
|
203
|
+
}
|
|
@@ -49,8 +49,12 @@ export const Foundation: Readonly<Record<FoundationCommandName, Readonly<Foundat
|
|
|
49
49
|
parameters: [
|
|
50
50
|
{name: "attrId", type: DataType.UINT16},
|
|
51
51
|
{name: "status", type: DataType.UINT8},
|
|
52
|
-
{name: "dataType", type: DataType.UINT8, conditions: [{type: ParameterCondition.
|
|
53
|
-
{
|
|
52
|
+
{name: "dataType", type: DataType.UINT8, conditions: [{type: ParameterCondition.FIELD_EQUAL, field: "status", value: Status.SUCCESS}]},
|
|
53
|
+
{
|
|
54
|
+
name: "attrData",
|
|
55
|
+
type: BuffaloZclDataType.USE_DATA_TYPE,
|
|
56
|
+
conditions: [{type: ParameterCondition.FIELD_EQUAL, field: "status", value: Status.SUCCESS}],
|
|
57
|
+
},
|
|
54
58
|
],
|
|
55
59
|
},
|
|
56
60
|
/** Write Attributes */
|
|
@@ -80,7 +84,11 @@ export const Foundation: Readonly<Record<FoundationCommandName, Readonly<Foundat
|
|
|
80
84
|
parseStrategy: "repetitive",
|
|
81
85
|
parameters: [
|
|
82
86
|
{name: "status", type: DataType.UINT8},
|
|
83
|
-
{
|
|
87
|
+
{
|
|
88
|
+
name: "attrId",
|
|
89
|
+
type: DataType.UINT16,
|
|
90
|
+
conditions: [{type: ParameterCondition.FIELD_EQUAL, field: "status", reversed: true, value: Status.SUCCESS}],
|
|
91
|
+
},
|
|
84
92
|
],
|
|
85
93
|
},
|
|
86
94
|
/** Write Attributes No Response */
|
|
@@ -100,26 +108,34 @@ export const Foundation: Readonly<Record<FoundationCommandName, Readonly<Foundat
|
|
|
100
108
|
parameters: [
|
|
101
109
|
{name: "direction", type: DataType.UINT8},
|
|
102
110
|
{name: "attrId", type: DataType.UINT16},
|
|
103
|
-
{
|
|
111
|
+
{
|
|
112
|
+
name: "dataType",
|
|
113
|
+
type: DataType.UINT8,
|
|
114
|
+
conditions: [{type: ParameterCondition.FIELD_EQUAL, field: "direction", value: Direction.CLIENT_TO_SERVER}],
|
|
115
|
+
},
|
|
104
116
|
{
|
|
105
117
|
name: "minRepIntval",
|
|
106
118
|
type: DataType.UINT16,
|
|
107
|
-
conditions: [{type: ParameterCondition.
|
|
119
|
+
conditions: [{type: ParameterCondition.FIELD_EQUAL, field: "direction", value: Direction.CLIENT_TO_SERVER}],
|
|
108
120
|
},
|
|
109
121
|
{
|
|
110
122
|
name: "maxRepIntval",
|
|
111
123
|
type: DataType.UINT16,
|
|
112
|
-
conditions: [{type: ParameterCondition.
|
|
124
|
+
conditions: [{type: ParameterCondition.FIELD_EQUAL, field: "direction", value: Direction.CLIENT_TO_SERVER}],
|
|
113
125
|
},
|
|
114
126
|
{
|
|
115
127
|
name: "repChange",
|
|
116
128
|
type: BuffaloZclDataType.USE_DATA_TYPE,
|
|
117
129
|
conditions: [
|
|
118
|
-
{type: ParameterCondition.
|
|
130
|
+
{type: ParameterCondition.FIELD_EQUAL, field: "direction", value: Direction.CLIENT_TO_SERVER},
|
|
119
131
|
{type: ParameterCondition.DATA_TYPE_CLASS_EQUAL, value: DataTypeClass.ANALOG},
|
|
120
132
|
],
|
|
121
133
|
},
|
|
122
|
-
{
|
|
134
|
+
{
|
|
135
|
+
name: "timeout",
|
|
136
|
+
type: DataType.UINT16,
|
|
137
|
+
conditions: [{type: ParameterCondition.FIELD_EQUAL, field: "direction", value: Direction.SERVER_TO_CLIENT}],
|
|
138
|
+
},
|
|
123
139
|
],
|
|
124
140
|
response: 0x07, // configReportRsp
|
|
125
141
|
},
|
|
@@ -153,26 +169,34 @@ export const Foundation: Readonly<Record<FoundationCommandName, Readonly<Foundat
|
|
|
153
169
|
{name: "status", type: DataType.UINT8},
|
|
154
170
|
{name: "direction", type: DataType.UINT8},
|
|
155
171
|
{name: "attrId", type: DataType.UINT16},
|
|
156
|
-
{
|
|
172
|
+
{
|
|
173
|
+
name: "dataType",
|
|
174
|
+
type: DataType.UINT8,
|
|
175
|
+
conditions: [{type: ParameterCondition.FIELD_EQUAL, field: "direction", value: Direction.CLIENT_TO_SERVER}],
|
|
176
|
+
},
|
|
157
177
|
{
|
|
158
178
|
name: "minRepIntval",
|
|
159
179
|
type: DataType.UINT16,
|
|
160
|
-
conditions: [{type: ParameterCondition.
|
|
180
|
+
conditions: [{type: ParameterCondition.FIELD_EQUAL, field: "direction", value: Direction.CLIENT_TO_SERVER}],
|
|
161
181
|
},
|
|
162
182
|
{
|
|
163
183
|
name: "maxRepIntval",
|
|
164
184
|
type: DataType.UINT16,
|
|
165
|
-
conditions: [{type: ParameterCondition.
|
|
185
|
+
conditions: [{type: ParameterCondition.FIELD_EQUAL, field: "direction", value: Direction.CLIENT_TO_SERVER}],
|
|
166
186
|
},
|
|
167
187
|
{
|
|
168
188
|
name: "repChange",
|
|
169
189
|
type: BuffaloZclDataType.USE_DATA_TYPE,
|
|
170
190
|
conditions: [
|
|
171
|
-
{type: ParameterCondition.
|
|
191
|
+
{type: ParameterCondition.FIELD_EQUAL, field: "direction", value: Direction.CLIENT_TO_SERVER},
|
|
172
192
|
{type: ParameterCondition.DATA_TYPE_CLASS_EQUAL, value: DataTypeClass.ANALOG},
|
|
173
193
|
],
|
|
174
194
|
},
|
|
175
|
-
{
|
|
195
|
+
{
|
|
196
|
+
name: "timeout",
|
|
197
|
+
type: DataType.UINT16,
|
|
198
|
+
conditions: [{type: ParameterCondition.FIELD_EQUAL, field: "direction", value: Direction.SERVER_TO_CLIENT}],
|
|
199
|
+
},
|
|
176
200
|
],
|
|
177
201
|
},
|
|
178
202
|
/** Report attributes */
|
|
@@ -240,12 +264,16 @@ export const Foundation: Readonly<Record<FoundationCommandName, Readonly<Foundat
|
|
|
240
264
|
// contains only one SUCCESS record for all written attributes if all written successfully
|
|
241
265
|
parameters: [
|
|
242
266
|
{name: "status", type: DataType.UINT8},
|
|
243
|
-
{
|
|
267
|
+
{
|
|
268
|
+
name: "attrId",
|
|
269
|
+
type: DataType.UINT16,
|
|
270
|
+
conditions: [{type: ParameterCondition.FIELD_EQUAL, field: "status", reversed: true, value: Status.SUCCESS}],
|
|
271
|
+
},
|
|
244
272
|
// always one zero-octet if failed attribute not of type array or structure, otherwise can also be zero if no info on which element caused failure
|
|
245
273
|
{
|
|
246
274
|
name: "selector",
|
|
247
275
|
type: BuffaloZclDataType.STRUCTURED_SELECTOR,
|
|
248
|
-
conditions: [{type: ParameterCondition.
|
|
276
|
+
conditions: [{type: ParameterCondition.FIELD_EQUAL, field: "status", reversed: true, value: Status.SUCCESS}],
|
|
249
277
|
},
|
|
250
278
|
],
|
|
251
279
|
},
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type {BuffaloZclDataType, DataType, DataTypeClass, Direction, FrameType, ParameterCondition, StructuredIndicatorType} from "./enums";
|
|
2
|
-
import type {Status} from "./status";
|
|
3
2
|
|
|
4
3
|
export interface BuffaloZclOptions {
|
|
5
4
|
length?: number;
|
|
@@ -23,6 +22,120 @@ export interface StructuredSelector {
|
|
|
23
22
|
indicatorType?: StructuredIndicatorType;
|
|
24
23
|
}
|
|
25
24
|
|
|
25
|
+
export interface KeyZclValue {
|
|
26
|
+
[s: string | number]: number | string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Struct {
|
|
30
|
+
elmType: DataType;
|
|
31
|
+
elmVal: unknown;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ZclTimeOfDay {
|
|
35
|
+
/** [0-23] */
|
|
36
|
+
hours?: number;
|
|
37
|
+
/** [0-59] */
|
|
38
|
+
minutes?: number;
|
|
39
|
+
/** [0-59] */
|
|
40
|
+
seconds?: number;
|
|
41
|
+
/** [0-99] */
|
|
42
|
+
hundredths?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ZclDate {
|
|
46
|
+
/** [1900-2155], converted to/from [0-255] => value+1900=year */
|
|
47
|
+
year?: number;
|
|
48
|
+
/** [1-12] */
|
|
49
|
+
month?: number;
|
|
50
|
+
/** [1-31] */
|
|
51
|
+
dayOfMonth?: number;
|
|
52
|
+
/** [1-7] */
|
|
53
|
+
dayOfWeek?: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface ZoneInfo {
|
|
57
|
+
zoneID: number;
|
|
58
|
+
zoneStatus: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface ExtensionFieldSet {
|
|
62
|
+
clstId: number;
|
|
63
|
+
len: number;
|
|
64
|
+
extField: unknown[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface ThermoTransition {
|
|
68
|
+
transitionTime: number;
|
|
69
|
+
heatSetpoint?: number;
|
|
70
|
+
coolSetpoint?: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface Gpd {
|
|
74
|
+
deviceID: number;
|
|
75
|
+
options: number;
|
|
76
|
+
extendedOptions: number;
|
|
77
|
+
securityKey: Buffer;
|
|
78
|
+
keyMic: number;
|
|
79
|
+
outgoingCounter: number;
|
|
80
|
+
applicationInfo: number;
|
|
81
|
+
manufacturerID: number;
|
|
82
|
+
modelID: number;
|
|
83
|
+
numGpdCommands: number;
|
|
84
|
+
gpdCommandIdList: Buffer;
|
|
85
|
+
numServerClusters: number;
|
|
86
|
+
numClientClusters: number;
|
|
87
|
+
gpdServerClusters: Buffer;
|
|
88
|
+
gpdClientClusters: Buffer;
|
|
89
|
+
genericSwitchConfig: number;
|
|
90
|
+
currentContactStatus: number;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface GpdChannelRequest {
|
|
94
|
+
nextChannel: number;
|
|
95
|
+
nextNextChannel: number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface GpdChannelConfiguration {
|
|
99
|
+
commandID: number;
|
|
100
|
+
operationalChannel: number;
|
|
101
|
+
basic: boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface GpdCommissioningReply {
|
|
105
|
+
commandID: number;
|
|
106
|
+
options: number;
|
|
107
|
+
/** expected valid if corresponding `options` bits set */
|
|
108
|
+
panID?: number;
|
|
109
|
+
/** expected valid if corresponding `options` bits set */
|
|
110
|
+
securityKey?: Buffer;
|
|
111
|
+
/** expected valid if corresponding `options` bits set */
|
|
112
|
+
keyMic?: number;
|
|
113
|
+
/** expected valid if corresponding `options` bits set */
|
|
114
|
+
frameCounter?: number;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface GpdCustomReply {
|
|
118
|
+
commandID: number;
|
|
119
|
+
buffer: Buffer;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface GpdAttributeReport {
|
|
123
|
+
manufacturerCode: number;
|
|
124
|
+
clusterID: number;
|
|
125
|
+
attributes: KeyZclValue;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface TuyaDataPointValue {
|
|
129
|
+
dp: number;
|
|
130
|
+
datatype: number;
|
|
131
|
+
data: Buffer;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface MiboxerZone {
|
|
135
|
+
zoneNum: number;
|
|
136
|
+
groupId: number;
|
|
137
|
+
}
|
|
138
|
+
|
|
26
139
|
export interface FrameControl {
|
|
27
140
|
reservedBits: number;
|
|
28
141
|
frameType: FrameType;
|
|
@@ -58,14 +171,12 @@ export interface AttributeDefinition {
|
|
|
58
171
|
|
|
59
172
|
export interface ParameterDefinition extends Parameter {
|
|
60
173
|
conditions?: (
|
|
61
|
-
| {type: ParameterCondition.STATUS_EQUAL; value: Status}
|
|
62
|
-
| {type: ParameterCondition.STATUS_NOT_EQUAL; value: Status}
|
|
63
174
|
| {type: ParameterCondition.MINIMUM_REMAINING_BUFFER_BYTES; value: number}
|
|
64
|
-
| {type: ParameterCondition.DIRECTION_EQUAL; value: Direction}
|
|
65
175
|
| {type: ParameterCondition.BITMASK_SET; param: string; mask: number /* not set */; reversed?: boolean}
|
|
66
176
|
| {type: ParameterCondition.BITFIELD_ENUM; param: string; offset: number; size: number; value: number}
|
|
67
177
|
| {type: ParameterCondition.DATA_TYPE_CLASS_EQUAL; value: DataTypeClass}
|
|
68
|
-
| {type: ParameterCondition.FIELD_EQUAL; field: string; value: unknown}
|
|
178
|
+
| {type: ParameterCondition.FIELD_EQUAL; field: string; value: unknown; reversed?: boolean}
|
|
179
|
+
| {type: ParameterCondition.FIELD_GT; field: string; value: number /*; reversed?: boolean*/}
|
|
69
180
|
)[];
|
|
70
181
|
}
|
|
71
182
|
|
|
@@ -239,8 +350,8 @@ export type ClusterName =
|
|
|
239
350
|
| "manuSpecificTuya"
|
|
240
351
|
| "manuSpecificLumi"
|
|
241
352
|
| "liXeePrivate"
|
|
242
|
-
| "
|
|
243
|
-
| "
|
|
353
|
+
| "manuSpecificTuya2"
|
|
354
|
+
| "manuSpecificTuya3"
|
|
244
355
|
| "manuSpecificCentraliteHumidity"
|
|
245
356
|
| "manuSpecificSmartThingsArrivalSensor"
|
|
246
357
|
| "manuSpecificSamsungAccelerometer"
|
|
@@ -253,7 +364,6 @@ export type ClusterName =
|
|
|
253
364
|
| "elkoSwitchConfigurationClusterServer"
|
|
254
365
|
| "manuSpecificSchneiderLightSwitchConfiguration"
|
|
255
366
|
| "manuSpecificSchneiderFanSwitchConfiguration"
|
|
256
|
-
| "sprutDevice"
|
|
257
367
|
| "sprutVoc"
|
|
258
368
|
| "sprutNoise"
|
|
259
369
|
| "sprutIrBlaster"
|
package/src/zspec/zcl/index.ts
CHANGED
package/src/zspec/zcl/utils.ts
CHANGED
|
@@ -264,7 +264,7 @@ function createCluster(name: string, cluster: ClusterDefinition, manufacturerCod
|
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
export function getCluster(key: string | number, manufacturerCode: number | undefined, customClusters: CustomClusters): Cluster {
|
|
267
|
+
export function getCluster(key: string | number, manufacturerCode: number | undefined = undefined, customClusters: CustomClusters = {}): Cluster {
|
|
268
268
|
const {name, cluster} = getClusterDefinition(key, manufacturerCode, customClusters);
|
|
269
269
|
return createCluster(name, cluster, manufacturerCode);
|
|
270
270
|
}
|
|
@@ -3,7 +3,6 @@ import "../../utils/patchBigIntSerialization";
|
|
|
3
3
|
import {BuffaloZcl} from "./buffaloZcl";
|
|
4
4
|
import {BuffaloZclDataType, DataType, Direction, FrameType, ParameterCondition} from "./definition/enums";
|
|
5
5
|
import type {FoundationCommandName} from "./definition/foundation";
|
|
6
|
-
import type {Status} from "./definition/status";
|
|
7
6
|
import type {BuffaloZclOptions, Cluster, ClusterName, Command, CustomClusters, ParameterDefinition} from "./definition/tstype";
|
|
8
7
|
import * as Utils from "./utils";
|
|
9
8
|
import {ZclHeader} from "./zclHeader";
|
|
@@ -195,7 +194,11 @@ export class ZclFrame {
|
|
|
195
194
|
}
|
|
196
195
|
}
|
|
197
196
|
|
|
198
|
-
|
|
197
|
+
try {
|
|
198
|
+
payload[parameter.name] = buffalo.read(parameter.type, options);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
throw new Error(`Cannot parse '${command.name}:${parameter.name}' (${(error as Error).message})`);
|
|
201
|
+
}
|
|
199
202
|
}
|
|
200
203
|
|
|
201
204
|
return payload;
|
|
@@ -286,38 +289,53 @@ export class ZclFrame {
|
|
|
286
289
|
if (parameter.conditions) {
|
|
287
290
|
for (const condition of parameter.conditions) {
|
|
288
291
|
switch (condition.type) {
|
|
289
|
-
case ParameterCondition.
|
|
290
|
-
if (
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
case ParameterCondition.DIRECTION_EQUAL: {
|
|
298
|
-
if ((entry.direction as Direction) !== condition.value) return false;
|
|
292
|
+
case ParameterCondition.FIELD_EQUAL: {
|
|
293
|
+
if (condition.reversed) {
|
|
294
|
+
if (entry[condition.field] === condition.value) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
} else if (entry[condition.field] !== condition.value) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
299
300
|
break;
|
|
300
301
|
}
|
|
301
302
|
case ParameterCondition.BITMASK_SET: {
|
|
302
303
|
if (condition.reversed) {
|
|
303
|
-
if ((entry[condition.param] & condition.mask) === condition.mask)
|
|
304
|
-
|
|
304
|
+
if ((entry[condition.param] & condition.mask) === condition.mask) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
} else if ((entry[condition.param] & condition.mask) !== condition.mask) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
305
310
|
break;
|
|
306
311
|
}
|
|
307
312
|
case ParameterCondition.BITFIELD_ENUM: {
|
|
308
|
-
if (((entry[condition.param] >> condition.offset) & ((1 << condition.size) - 1)) !== condition.value)
|
|
313
|
+
if (((entry[condition.param] >> condition.offset) & ((1 << condition.size) - 1)) !== condition.value) {
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
309
316
|
break;
|
|
310
317
|
}
|
|
311
318
|
case ParameterCondition.MINIMUM_REMAINING_BUFFER_BYTES: {
|
|
312
|
-
if (remainingBufferBytes !== undefined && remainingBufferBytes < condition.value)
|
|
319
|
+
if (remainingBufferBytes !== undefined && remainingBufferBytes < condition.value) {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
313
322
|
break;
|
|
314
323
|
}
|
|
315
324
|
case ParameterCondition.DATA_TYPE_CLASS_EQUAL: {
|
|
316
|
-
if (Utils.getDataTypeClass(entry.dataType) !== condition.value)
|
|
325
|
+
if (Utils.getDataTypeClass(entry.dataType) !== condition.value) {
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
317
328
|
break;
|
|
318
329
|
}
|
|
319
|
-
case ParameterCondition.
|
|
320
|
-
if (
|
|
330
|
+
case ParameterCondition.FIELD_GT: {
|
|
331
|
+
/*if (condition.reversed) {
|
|
332
|
+
if (entry[condition.field] >= condition.value) {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
} else */
|
|
336
|
+
if (entry[condition.field] <= condition.value) {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
321
339
|
break;
|
|
322
340
|
}
|
|
323
341
|
}
|
|
@@ -74,15 +74,6 @@ const NS = "zh:zdo:buffalo";
|
|
|
74
74
|
const MAX_BUFFER_SIZE = 255;
|
|
75
75
|
|
|
76
76
|
export class BuffaloZdo extends Buffalo {
|
|
77
|
-
/**
|
|
78
|
-
* Set the position of the internal position tracker.
|
|
79
|
-
* TODO: move to base `Buffalo` class
|
|
80
|
-
* @param position
|
|
81
|
-
*/
|
|
82
|
-
public setPosition(position: number): void {
|
|
83
|
-
this.position = position;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
77
|
/**
|
|
87
78
|
* Set the byte at given position without affecting the internal position tracker.
|
|
88
79
|
* TODO: move to base `Buffalo` class
|