@matter-server/custom-clusters 0.5.9 → 0.5.11
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/dist/esm/clusters/heiman.d.ts +11 -0
- package/dist/esm/clusters/heiman.d.ts.map +1 -1
- package/dist/esm/clusters/heiman.js +33 -20
- package/dist/esm/clusters/heiman.js.map +2 -2
- package/dist/esm/register.js +0 -4
- package/dist/esm/register.js.map +1 -1
- package/package.json +2 -2
- package/src/clusters/heiman.ts +15 -1
- package/src/register.ts +1 -6
- package/dist/esm/builder.d.ts +0 -9
- package/dist/esm/builder.d.ts.map +0 -1
- package/dist/esm/builder.js +0 -38
- package/dist/esm/builder.js.map +0 -6
- package/src/builder.ts +0 -45
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
* Copyright 2025-2026 Open Home Foundation
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* Input to the {@link HeimanCluster.mutingSensor} command.
|
|
8
|
+
*/
|
|
9
|
+
declare class MutingSensorCommand {
|
|
10
|
+
mutingTime: number;
|
|
11
|
+
}
|
|
6
12
|
export declare class HeimanCluster {
|
|
7
13
|
tamperAlarm?: number;
|
|
8
14
|
preheatingState?: number;
|
|
@@ -11,5 +17,10 @@ export declare class HeimanCluster {
|
|
|
11
17
|
sirenActive?: number;
|
|
12
18
|
alarmMute?: number;
|
|
13
19
|
lowPowerMode?: number;
|
|
20
|
+
/**
|
|
21
|
+
* This command is used for muting sensor for a specific period if there is an alarm, like a fire alarm.
|
|
22
|
+
*/
|
|
23
|
+
mutingSensor(_request: MutingSensorCommand): void;
|
|
14
24
|
}
|
|
25
|
+
export {};
|
|
15
26
|
//# sourceMappingURL=heiman.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heiman.d.ts","sourceRoot":"","sources":["../../../src/clusters/heiman.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,qBACa,aAAa;IAEtB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAG3B,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,YAAY,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"heiman.d.ts","sourceRoot":"","sources":["../../../src/clusters/heiman.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,cAAM,mBAAmB;IAErB,UAAU,EAAG,MAAM,CAAC;CACvB;AAED,qBACa,aAAa;IAEtB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAG3B,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IAEH,YAAY,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;CACpD"}
|
|
@@ -51,30 +51,43 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
51
51
|
* Copyright 2025-2026 Open Home Foundation
|
|
52
52
|
* SPDX-License-Identifier: Apache-2.0
|
|
53
53
|
*/
|
|
54
|
-
var _lowPowerMode_dec, _alarmMute_dec, _sirenActive_dec, _sensorType_dec, _noDisturbingState_dec, _preheatingState_dec, _tamperAlarm_dec, _HeimanCluster_decorators,
|
|
55
|
-
import { attribute, cluster, uint8, writable } from "@matter/main/model";
|
|
56
|
-
|
|
57
|
-
class
|
|
54
|
+
var _mutingTime_dec, _init, _mutingSensor_dec, _lowPowerMode_dec, _alarmMute_dec, _sirenActive_dec, _sensorType_dec, _noDisturbingState_dec, _preheatingState_dec, _tamperAlarm_dec, _HeimanCluster_decorators, _init2;
|
|
55
|
+
import { attribute, cluster, uint8, writable, command, uint16, field } from "@matter/main/model";
|
|
56
|
+
_mutingTime_dec = [field(uint16)];
|
|
57
|
+
class MutingSensorCommand {
|
|
58
58
|
constructor() {
|
|
59
|
-
__publicField(this, "
|
|
60
|
-
__publicField(this, "preheatingState", __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
|
|
61
|
-
__publicField(this, "noDisturbingState", __runInitializers(_init, 16, this)), __runInitializers(_init, 19, this);
|
|
62
|
-
__publicField(this, "sensorType", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this);
|
|
63
|
-
__publicField(this, "sirenActive", __runInitializers(_init, 24, this)), __runInitializers(_init, 27, this);
|
|
64
|
-
__publicField(this, "alarmMute", __runInitializers(_init, 28, this)), __runInitializers(_init, 31, this);
|
|
65
|
-
__publicField(this, "lowPowerMode", __runInitializers(_init, 32, this)), __runInitializers(_init, 35, this);
|
|
59
|
+
__publicField(this, "mutingTime", __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
|
|
66
60
|
}
|
|
67
61
|
}
|
|
68
62
|
_init = __decoratorStart(null);
|
|
69
|
-
__decorateElement(_init, 5, "
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
__runInitializers(
|
|
63
|
+
__decorateElement(_init, 5, "mutingTime", _mutingTime_dec, MutingSensorCommand);
|
|
64
|
+
__decoratorMetadata(_init, MutingSensorCommand);
|
|
65
|
+
_HeimanCluster_decorators = [cluster(302775297)], _tamperAlarm_dec = [attribute(16, uint8)], _preheatingState_dec = [attribute(17, uint8)], _noDisturbingState_dec = [attribute(18, uint8)], _sensorType_dec = [attribute(19, uint8)], _sirenActive_dec = [attribute(20, uint8, writable)], _alarmMute_dec = [attribute(21, uint8, writable)], _lowPowerMode_dec = [attribute(22, uint8, writable)], _mutingSensor_dec = [command(0, MutingSensorCommand)];
|
|
66
|
+
class HeimanCluster {
|
|
67
|
+
constructor() {
|
|
68
|
+
__runInitializers(_init2, 5, this);
|
|
69
|
+
__publicField(this, "tamperAlarm", __runInitializers(_init2, 8, this)), __runInitializers(_init2, 11, this);
|
|
70
|
+
__publicField(this, "preheatingState", __runInitializers(_init2, 12, this)), __runInitializers(_init2, 15, this);
|
|
71
|
+
__publicField(this, "noDisturbingState", __runInitializers(_init2, 16, this)), __runInitializers(_init2, 19, this);
|
|
72
|
+
__publicField(this, "sensorType", __runInitializers(_init2, 20, this)), __runInitializers(_init2, 23, this);
|
|
73
|
+
__publicField(this, "sirenActive", __runInitializers(_init2, 24, this)), __runInitializers(_init2, 27, this);
|
|
74
|
+
__publicField(this, "alarmMute", __runInitializers(_init2, 28, this)), __runInitializers(_init2, 31, this);
|
|
75
|
+
__publicField(this, "lowPowerMode", __runInitializers(_init2, 32, this)), __runInitializers(_init2, 35, this);
|
|
76
|
+
}
|
|
77
|
+
mutingSensor(_request) {
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
_init2 = __decoratorStart(null);
|
|
81
|
+
__decorateElement(_init2, 1, "mutingSensor", _mutingSensor_dec, HeimanCluster);
|
|
82
|
+
__decorateElement(_init2, 5, "tamperAlarm", _tamperAlarm_dec, HeimanCluster);
|
|
83
|
+
__decorateElement(_init2, 5, "preheatingState", _preheatingState_dec, HeimanCluster);
|
|
84
|
+
__decorateElement(_init2, 5, "noDisturbingState", _noDisturbingState_dec, HeimanCluster);
|
|
85
|
+
__decorateElement(_init2, 5, "sensorType", _sensorType_dec, HeimanCluster);
|
|
86
|
+
__decorateElement(_init2, 5, "sirenActive", _sirenActive_dec, HeimanCluster);
|
|
87
|
+
__decorateElement(_init2, 5, "alarmMute", _alarmMute_dec, HeimanCluster);
|
|
88
|
+
__decorateElement(_init2, 5, "lowPowerMode", _lowPowerMode_dec, HeimanCluster);
|
|
89
|
+
HeimanCluster = __decorateElement(_init2, 0, "HeimanCluster", _HeimanCluster_decorators, HeimanCluster);
|
|
90
|
+
__runInitializers(_init2, 1, HeimanCluster);
|
|
78
91
|
export {
|
|
79
92
|
HeimanCluster
|
|
80
93
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/clusters/heiman.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAAS,WAAW,SAAS,OAAO,
|
|
5
|
-
"names": []
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gNAAAA;AAMA,SAAS,WAAW,SAAS,OAAO,UAAU,SAAS,QAAQ,aAAa;AAMxE,mBAAC,MAAM,MAAM;AADjB,MAAM,oBAAoB;AAAA,EAA1B;AAEI;AAAA;AACJ;AAHA;AAEI,0CADA,iBADE;AAAN,2BAAM;AAKN,6BAAC,QAAQ,SAAU,IAEf,oBAAC,UAAU,IAAQ,KAAK,IAGxB,wBAAC,UAAU,IAAQ,KAAK,IAGxB,0BAAC,UAAU,IAAQ,KAAK,IAGxB,mBAAC,UAAU,IAAQ,KAAK,IAGxB,oBAAC,UAAU,IAAQ,OAAO,QAAQ,IAGlC,kBAAC,UAAU,IAAQ,OAAO,QAAQ,IAGlC,qBAAC,UAAU,IAAQ,OAAO,QAAQ,IAMlC,qBAAC,QAAQ,GAAM,mBAAmB;AAzB/B,MAAM,cAAc;AAAA,EAApB;AAAA,sBAAAA,QAAA;AAEH,yDAAAA,QAAA,6BAAAA,QAAA;AAGA,6DAAAA,QAAA,8BAAAA,QAAA;AAGA,+DAAAA,QAAA,8BAAAA,QAAA;AAGA,wDAAAA,QAAA,8BAAAA,QAAA;AAGA,yDAAAA,QAAA,8BAAAA,QAAA;AAGA,uDAAAA,QAAA,8BAAAA,QAAA;AAGA,0DAAAA,QAAA,8BAAAA,QAAA;AAAA;AAAA,EAMA,aAAa,UAAqC;AAAA,EAAC;AACvD;AA3BOA,SAAA;AA0BH,kBAAAA,QAAA,mBADA,mBAzBS;AAET,kBAAAA,QAAA,kBADA,kBADS;AAKT,kBAAAA,QAAA,sBADA,sBAJS;AAQT,kBAAAA,QAAA,wBADA,wBAPS;AAWT,kBAAAA,QAAA,iBADA,iBAVS;AAcT,kBAAAA,QAAA,kBADA,kBAbS;AAiBT,kBAAAA,QAAA,gBADA,gBAhBS;AAoBT,kBAAAA,QAAA,mBADA,mBAnBS;AAAA,gBAAN,kBAAAA,QAAA,oBADP,2BACa;AAAN,kBAAAA,QAAA,GAAM;",
|
|
5
|
+
"names": ["_init"]
|
|
6
6
|
}
|
package/dist/esm/register.js
CHANGED
|
@@ -4,13 +4,9 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { Matter, Schema } from "@matter/main/model";
|
|
7
|
-
import { ClusterRegistry } from "@matter/main/types";
|
|
8
|
-
import { ClusterTypeOfModel } from "./builder.js";
|
|
9
7
|
import * as Clusters from "./clusters/index.js";
|
|
10
8
|
for (const ClusterDefinition of Object.values(Clusters)) {
|
|
11
9
|
const ClusterSchema = Schema.Required(ClusterDefinition);
|
|
12
10
|
Matter.children.push(ClusterSchema);
|
|
13
|
-
const ClusterType = ClusterTypeOfModel(ClusterSchema);
|
|
14
|
-
ClusterRegistry.register(ClusterType);
|
|
15
11
|
}
|
|
16
12
|
//# sourceMappingURL=register.js.map
|
package/dist/esm/register.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/register.ts"],
|
|
4
|
-
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,
|
|
4
|
+
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAAS,QAAQ,cAAc;AAC/B,YAAY,cAAc;AAE1B,WAAW,qBAAqB,OAAO,OAAO,QAAQ,GAAG;AACrD,QAAM,gBAAgB,OAAO,SAAS,iBAAiB;AACvD,SAAO,SAAS,KAAK,aAAa;AACtC;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matter-server/custom-clusters",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Custom cluster definitions for matter.js based projects",
|
|
6
6
|
"bugs": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"node": ">=20.19.0 <22.0.0 || >=22.13.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@matter/main": "0.17.0-alpha.0-
|
|
25
|
+
"@matter/main": "0.17.0-alpha.0-20260401-1edc54c9a"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist/**/*",
|
package/src/clusters/heiman.ts
CHANGED
|
@@ -4,7 +4,15 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { attribute, cluster, uint8, writable } from "@matter/main/model";
|
|
7
|
+
import { attribute, cluster, uint8, writable, command, uint16, field } from "@matter/main/model";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Input to the {@link HeimanCluster.mutingSensor} command.
|
|
11
|
+
*/
|
|
12
|
+
class MutingSensorCommand {
|
|
13
|
+
@field(uint16)
|
|
14
|
+
mutingTime!: number;
|
|
15
|
+
}
|
|
8
16
|
|
|
9
17
|
@cluster(0x120bfc01)
|
|
10
18
|
export class HeimanCluster {
|
|
@@ -28,4 +36,10 @@ export class HeimanCluster {
|
|
|
28
36
|
|
|
29
37
|
@attribute(0x0016, uint8, writable)
|
|
30
38
|
lowPowerMode?: number;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* This command is used for muting sensor for a specific period if there is an alarm, like a fire alarm.
|
|
42
|
+
*/
|
|
43
|
+
@command(0x00, MutingSensorCommand)
|
|
44
|
+
mutingSensor(_request: MutingSensorCommand): void {}
|
|
31
45
|
}
|
package/src/register.ts
CHANGED
|
@@ -4,15 +4,10 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { ClusterRegistry } from "@matter/main/types";
|
|
9
|
-
import { ClusterTypeOfModel } from "./builder.js";
|
|
7
|
+
import { Matter, Schema } from "@matter/main/model";
|
|
10
8
|
import * as Clusters from "./clusters/index.js";
|
|
11
9
|
|
|
12
10
|
for (const ClusterDefinition of Object.values(Clusters)) {
|
|
13
11
|
const ClusterSchema = Schema.Required(ClusterDefinition);
|
|
14
12
|
Matter.children.push(ClusterSchema);
|
|
15
|
-
|
|
16
|
-
const ClusterType = ClusterTypeOfModel(ClusterSchema as ClusterModel);
|
|
17
|
-
ClusterRegistry.register(ClusterType);
|
|
18
13
|
}
|
package/dist/esm/builder.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025-2026 Open Home Foundation
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { ClusterModel } from "@matter/main/model";
|
|
7
|
-
import { ClusterType, MutableCluster } from "@matter/main/types";
|
|
8
|
-
export declare function ClusterTypeOfModel(model: ClusterModel): MutableCluster<ClusterType.Options<{}>, []>;
|
|
9
|
-
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,YAAY,EAA0B,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACH,WAAW,EACX,cAAc,EAIjB,MAAM,oBAAoB,CAAC;AAE5B,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,YAAY,+CA4BrD"}
|
package/dist/esm/builder.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025-2026 Open Home Foundation
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { camelize, capitalize } from "@matter/main";
|
|
7
|
-
import { ElementTag, GLOBAL_IDS } from "@matter/main/model";
|
|
8
|
-
import {
|
|
9
|
-
MutableCluster,
|
|
10
|
-
OptionalAttribute,
|
|
11
|
-
OptionalWritableAttribute,
|
|
12
|
-
TlvOfModel
|
|
13
|
-
} from "@matter/main/types";
|
|
14
|
-
function ClusterTypeOfModel(model) {
|
|
15
|
-
if (model.tag !== ElementTag.Cluster || model.id === void 0) {
|
|
16
|
-
throw new Error("Model is not a valid ClusterModel");
|
|
17
|
-
}
|
|
18
|
-
const cluster = {
|
|
19
|
-
id: model.id,
|
|
20
|
-
name: capitalize(model.name),
|
|
21
|
-
revision: model.revision,
|
|
22
|
-
attributes: {}
|
|
23
|
-
};
|
|
24
|
-
for (const attr of model.attributes) {
|
|
25
|
-
const id = attr.id;
|
|
26
|
-
if (GLOBAL_IDS.has(id)) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
const name = camelize(attr.name);
|
|
30
|
-
const tlv = TlvOfModel(attr);
|
|
31
|
-
cluster.attributes[name] = attr.writable ? OptionalWritableAttribute(id, tlv) : OptionalAttribute(id, tlv);
|
|
32
|
-
}
|
|
33
|
-
return MutableCluster(cluster);
|
|
34
|
-
}
|
|
35
|
-
export {
|
|
36
|
-
ClusterTypeOfModel
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=builder.js.map
|
package/dist/esm/builder.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/builder.ts"],
|
|
4
|
-
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAAS,UAAU,kBAAkB;AACrC,SAAuB,YAAY,kBAAkB;AACrD;AAAA,EAEI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEA,SAAS,mBAAmB,OAAqB;AACpD,MAAI,MAAM,QAAQ,WAAW,WAAW,MAAM,OAAO,QAAW;AAC5D,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACvD;AAEA,QAAM,UAA+B;AAAA,IACjC,IAAI,MAAM;AAAA,IACV,MAAM,WAAW,MAAM,IAAI;AAAA,IAC3B,UAAU,MAAM;AAAA,IAEhB,YAAY,CAAC;AAAA,EACjB;AAEA,aAAW,QAAQ,MAAM,YAAY;AACjC,UAAM,KAAK,KAAK;AAEhB,QAAI,WAAW,IAAI,EAAE,GAAG;AACpB;AAAA,IACJ;AACA,UAAM,OAAO,SAAS,KAAK,IAAI;AAE/B,UAAM,MAAM,WAAW,IAAI;AAC3B,YAAQ,WAAY,IAAI,IAAI,KAAK,WAAW,0BAA0B,IAAI,GAAG,IAAI,kBAAkB,IAAI,GAAG;AAAA,EAC9G;AAIA,SAAO,eAAe,OAAO;AACjC;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/src/builder.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025-2026 Open Home Foundation
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { camelize, capitalize } from "@matter/main";
|
|
8
|
-
import { ClusterModel, ElementTag, GLOBAL_IDS } from "@matter/main/model";
|
|
9
|
-
import {
|
|
10
|
-
ClusterType,
|
|
11
|
-
MutableCluster,
|
|
12
|
-
OptionalAttribute,
|
|
13
|
-
OptionalWritableAttribute,
|
|
14
|
-
TlvOfModel,
|
|
15
|
-
} from "@matter/main/types";
|
|
16
|
-
|
|
17
|
-
export function ClusterTypeOfModel(model: ClusterModel) {
|
|
18
|
-
if (model.tag !== ElementTag.Cluster || model.id === undefined) {
|
|
19
|
-
throw new Error("Model is not a valid ClusterModel");
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const cluster: ClusterType.Options = {
|
|
23
|
-
id: model.id,
|
|
24
|
-
name: capitalize(model.name),
|
|
25
|
-
revision: model.revision,
|
|
26
|
-
|
|
27
|
-
attributes: {},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
for (const attr of model.attributes) {
|
|
31
|
-
const id = attr.id;
|
|
32
|
-
// Exclude Global attributes
|
|
33
|
-
if (GLOBAL_IDS.has(id)) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
const name = camelize(attr.name);
|
|
37
|
-
// TODO respect mandatory flag when needed
|
|
38
|
-
const tlv = TlvOfModel(attr);
|
|
39
|
-
cluster.attributes![name] = attr.writable ? OptionalWritableAttribute(id, tlv) : OptionalAttribute(id, tlv);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// TODO also add events and commands when needed
|
|
43
|
-
|
|
44
|
-
return MutableCluster(cluster);
|
|
45
|
-
}
|