@matter/create 0.16.0-alpha.0-20250912-0d12bf718 → 0.16.0-alpha.0-20250913-0bc2515df
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.
|
@@ -11,29 +11,21 @@
|
|
|
11
11
|
* because you need to adjust the code in any way depending on your use case.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { Diagnostic, Environment, Logger,
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
14
|
+
import { Diagnostic, Environment, Logger, StorageService, Time } from "@matter/main";
|
|
15
|
+
import { DescriptorClient } from "@matter/main/behaviors/descriptor";
|
|
16
|
+
import { OnOffClient } from "@matter/main/behaviors/on-off";
|
|
17
|
+
import { BasicInformationCluster, Descriptor, GeneralCommissioning } from "@matter/main/clusters";
|
|
17
18
|
import { ManualPairingCodeCodec, NodeId } from "@matter/main/types";
|
|
18
|
-
import { NodeJsBle } from "@matter/nodejs-ble";
|
|
19
19
|
import { CommissioningController, NodeCommissioningOptions } from "@project-chip/matter.js";
|
|
20
20
|
import { NodeStates } from "@project-chip/matter.js/device";
|
|
21
21
|
|
|
22
|
+
// This installs BLE support if configuration variable "ble.enable" is true
|
|
23
|
+
import "@matter/nodejs-ble";
|
|
24
|
+
|
|
22
25
|
const logger = Logger.get("Controller");
|
|
23
26
|
|
|
24
27
|
const environment = Environment.default;
|
|
25
28
|
|
|
26
|
-
if (environment.vars.get("ble")) {
|
|
27
|
-
// Initialize Ble
|
|
28
|
-
Ble.get = singleton(
|
|
29
|
-
() =>
|
|
30
|
-
new NodeJsBle({
|
|
31
|
-
environment,
|
|
32
|
-
hciId: environment.vars.number("ble.hci.id"),
|
|
33
|
-
}),
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
29
|
const storageService = environment.get(StorageService);
|
|
38
30
|
|
|
39
31
|
console.log(`Storage location: ${storageService.location} (Directory)`);
|
|
@@ -229,16 +221,28 @@ class ControllerNode {
|
|
|
229
221
|
|
|
230
222
|
node.logStructure();
|
|
231
223
|
|
|
232
|
-
// Example to
|
|
233
|
-
|
|
224
|
+
// Example to conveniently access cluster states in a typed manner and read the data from the local cache
|
|
225
|
+
// This is the new preferred way to access the latest known cluster data
|
|
226
|
+
const descriptorState = node.stateOf(DescriptorClient);
|
|
227
|
+
if (descriptorState !== undefined) {
|
|
228
|
+
console.log("deviceTypeList", descriptorState.deviceTypeList); // you can access the state that way
|
|
229
|
+
} else {
|
|
230
|
+
console.log("No Descriptor Cluster found. This should never happen!");
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Alternatively you can access concrete fields as API methods by creating a ClusterClient and
|
|
234
|
+
// reading the data from the device or local cache
|
|
235
|
+
const descriptor = node.getRootClusterClient(Descriptor.Complete);
|
|
234
236
|
if (descriptor !== undefined) {
|
|
235
|
-
console.log(
|
|
236
|
-
console.log(await descriptor.getServerListAttribute()); //
|
|
237
|
+
console.log(descriptor.getTagListAttributeFromCache()); // Convenient that way from local cache
|
|
238
|
+
console.log(await descriptor.getServerListAttribute()); // Convenient that way (async!)
|
|
239
|
+
console.log(await descriptor.attributes.clientList.get()); // or more low level that way (async!)
|
|
237
240
|
} else {
|
|
238
241
|
console.log("No Descriptor Cluster found. This should never happen!");
|
|
239
242
|
}
|
|
240
243
|
|
|
241
|
-
// Example to subscribe to a field and get the value
|
|
244
|
+
// Example to subscribe to a field and get the value, normally this is not needed because by default
|
|
245
|
+
// all attributes are subscribed automatically!
|
|
242
246
|
const info = node.getRootClusterClient(BasicInformationCluster);
|
|
243
247
|
if (info !== undefined) {
|
|
244
248
|
console.log(await info.getProductNameAttribute()); // This call is executed remotely
|
|
@@ -260,25 +264,23 @@ class ControllerNode {
|
|
|
260
264
|
//const attributesBasicInformation = await interactionClient.getMultipleAttributes([{ endpointId: 0, clusterId: BasicInformationCluster.id} ]);
|
|
261
265
|
//console.log("Attributes-BasicInformation:", JSON.stringify(attributesBasicInformation, null, 2));
|
|
262
266
|
|
|
263
|
-
const
|
|
264
|
-
if (
|
|
267
|
+
const endpointOne = node.parts.get(1);
|
|
268
|
+
if (endpointOne) {
|
|
265
269
|
// Example to subscribe to all Attributes of endpoint 1 of the commissioned node: */*/*
|
|
266
270
|
//await interactionClient.subscribeMultipleAttributes([{ endpointId: 1, /* subscribe anything from endpoint 1 */ }], 0, 180, data => {
|
|
267
271
|
// console.log("Subscribe-All Data:", Diagnostic.json(data));
|
|
268
272
|
//});
|
|
269
273
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
274
|
+
// Example using the new convenient typed access to state and commands of the OnOff cluster
|
|
275
|
+
const onOffState = endpointOne.stateOf(OnOffClient);
|
|
276
|
+
if (onOffState !== undefined) {
|
|
277
|
+
let onOffStatus = onOffState.onOff;
|
|
273
278
|
console.log("initial onOffStatus", onOffStatus);
|
|
274
279
|
|
|
275
|
-
|
|
276
|
-
console.log("subscription onOffStatus", value);
|
|
277
|
-
onOffStatus = value;
|
|
278
|
-
});
|
|
280
|
+
const onOffCommands = endpointOne.commandsOf(OnOffClient);
|
|
279
281
|
// read data every minute to keep up the connection to show the subscription is working
|
|
280
282
|
setInterval(() => {
|
|
281
|
-
|
|
283
|
+
onOffCommands
|
|
282
284
|
.toggle()
|
|
283
285
|
.then(() => {
|
|
284
286
|
onOffStatus = !onOffStatus;
|
|
@@ -32,7 +32,6 @@ import {
|
|
|
32
32
|
StorageService,
|
|
33
33
|
Time,
|
|
34
34
|
VendorId,
|
|
35
|
-
singleton,
|
|
36
35
|
} from "@matter/main";
|
|
37
36
|
import { OnOffServer } from "@matter/main/behaviors";
|
|
38
37
|
import { GeneralDiagnostics, NetworkCommissioning, OnOff } from "@matter/main/clusters";
|
|
@@ -41,7 +40,6 @@ import { RootRequirements } from "@matter/main/endpoints";
|
|
|
41
40
|
import { Ble, FabricAction } from "@matter/main/protocol";
|
|
42
41
|
import { QrCode } from "@matter/main/types";
|
|
43
42
|
import { createFileLogger } from "@matter/nodejs";
|
|
44
|
-
import { NodeJsBle } from "@matter/nodejs-ble";
|
|
45
43
|
import { execSync } from "node:child_process";
|
|
46
44
|
import { DummyThreadNetworkCommissioningServer } from "./cluster/DummyThreadNetworkCommissioningServer.js";
|
|
47
45
|
import { DummyWifiNetworkCommissioningServer } from "./cluster/DummyWifiNetworkCommissioningServer.js";
|
|
@@ -51,6 +49,13 @@ import {
|
|
|
51
49
|
MyFancyOwnFunctionalityBehavior,
|
|
52
50
|
} from "./cluster/MyFancyOwnFunctionality.js";
|
|
53
51
|
|
|
52
|
+
// This installs BLE support if:
|
|
53
|
+
//
|
|
54
|
+
// - The environment.vars value "ble.enable" is true
|
|
55
|
+
// - The command line flag "--ble-enable" is set
|
|
56
|
+
// - The system environment variable "BLE_ENABLE" is set
|
|
57
|
+
import "@matter/nodejs-ble";
|
|
58
|
+
|
|
54
59
|
const logger = Logger.get("DeviceNodeFull");
|
|
55
60
|
|
|
56
61
|
/**
|
|
@@ -68,19 +73,6 @@ const logger = Logger.get("DeviceNodeFull");
|
|
|
68
73
|
|
|
69
74
|
const environment = Environment.default;
|
|
70
75
|
|
|
71
|
-
// Alternatively "--ble-enable" or environment variable "BLE_ENABLED"
|
|
72
|
-
// Alternatively "--ble-hciId" or environment variable "BLE_HCIID"
|
|
73
|
-
if (environment.vars.get("ble.enable")) {
|
|
74
|
-
// Initialize Ble
|
|
75
|
-
Ble.get = singleton(
|
|
76
|
-
() =>
|
|
77
|
-
new NodeJsBle({
|
|
78
|
-
environment,
|
|
79
|
-
hciId: environment.vars.number("ble.hciId"),
|
|
80
|
-
}),
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
76
|
function executeCommand(scriptParamName: string) {
|
|
85
77
|
const script = environment.vars.string(scriptParamName);
|
|
86
78
|
if (script === undefined) return undefined;
|
|
@@ -261,7 +253,7 @@ const server = await ServerNode.create(RootEndpoint, {
|
|
|
261
253
|
});
|
|
262
254
|
|
|
263
255
|
const networkId = new Uint8Array(32);
|
|
264
|
-
if (Ble
|
|
256
|
+
if (environment.has(Ble)) {
|
|
265
257
|
// matter.js will create an Ethernet-only device by default when it comes to Network Commissioning Features.
|
|
266
258
|
// To offer e.g. a "Wi-Fi only device" (or any other combination) we need to override the Network Commissioning
|
|
267
259
|
// cluster and implement all the need handling here. This is a "static implementation" for pure demonstration
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
{
|
|
6
6
|
"name": "control-onoff",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@matter/main": "~0.16.0-alpha.0-
|
|
8
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
9
9
|
},
|
|
10
10
|
"description": "Simple light controller",
|
|
11
11
|
"entrypoint": "OnOffController.ts"
|
|
@@ -13,9 +13,8 @@
|
|
|
13
13
|
{
|
|
14
14
|
"name": "controller",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@matter/main": "~0.16.0-alpha.0-
|
|
17
|
-
"@matter
|
|
18
|
-
"@project-chip/matter.js": "~0.16.0-alpha.0-20250912-0d12bf718"
|
|
16
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df",
|
|
17
|
+
"@project-chip/matter.js": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
19
18
|
},
|
|
20
19
|
"description": "Controller example to commission and connect devices",
|
|
21
20
|
"entrypoint": "ControllerNode.ts"
|
|
@@ -23,7 +22,7 @@
|
|
|
23
22
|
{
|
|
24
23
|
"name": "device-air-quality-sensor",
|
|
25
24
|
"dependencies": {
|
|
26
|
-
"@matter/main": "~0.16.0-alpha.0-
|
|
25
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
27
26
|
},
|
|
28
27
|
"description": "Air quality sensor example",
|
|
29
28
|
"entrypoint": "AirQualitySensorDeviceNode.ts"
|
|
@@ -31,7 +30,7 @@
|
|
|
31
30
|
{
|
|
32
31
|
"name": "device-bridge-onoff",
|
|
33
32
|
"dependencies": {
|
|
34
|
-
"@matter/main": "~0.16.0-alpha.0-
|
|
33
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
35
34
|
},
|
|
36
35
|
"description": "Bridge for multiple OnOff light/sockets with a CLI command execution interface",
|
|
37
36
|
"entrypoint": "BridgedDevicesNode.ts"
|
|
@@ -39,7 +38,7 @@
|
|
|
39
38
|
{
|
|
40
39
|
"name": "device-composed-onoff",
|
|
41
40
|
"dependencies": {
|
|
42
|
-
"@matter/main": "~0.16.0-alpha.0-
|
|
41
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
43
42
|
},
|
|
44
43
|
"description": "Composed device for multiple OnOff light/sockets with a CLI command execution interface",
|
|
45
44
|
"entrypoint": "ComposedDeviceNode.ts"
|
|
@@ -47,7 +46,7 @@
|
|
|
47
46
|
{
|
|
48
47
|
"name": "device-composed-wc-light",
|
|
49
48
|
"dependencies": {
|
|
50
|
-
"@matter/main": "~0.16.0-alpha.0-
|
|
49
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
51
50
|
},
|
|
52
51
|
"description": "Composed device with Window covering and a light endpoint that logs changes",
|
|
53
52
|
"entrypoint": "IlluminatedRollerShade.ts"
|
|
@@ -55,7 +54,7 @@
|
|
|
55
54
|
{
|
|
56
55
|
"name": "device-measuring-socket",
|
|
57
56
|
"dependencies": {
|
|
58
|
-
"@matter/main": "~0.16.0-alpha.0-
|
|
57
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
59
58
|
},
|
|
60
59
|
"description": "Socket device that reports random Energy and Power measurements",
|
|
61
60
|
"entrypoint": "MeasuredSocketDevice.ts"
|
|
@@ -63,7 +62,7 @@
|
|
|
63
62
|
{
|
|
64
63
|
"name": "device-multiple-onoff",
|
|
65
64
|
"dependencies": {
|
|
66
|
-
"@matter/main": "~0.16.0-alpha.0-
|
|
65
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
67
66
|
},
|
|
68
67
|
"description": "Multiple OnOff light/socket nodes in one process with a CLI command execution interface",
|
|
69
68
|
"entrypoint": "MultiDeviceNode.ts"
|
|
@@ -71,7 +70,7 @@
|
|
|
71
70
|
{
|
|
72
71
|
"name": "device-onoff",
|
|
73
72
|
"dependencies": {
|
|
74
|
-
"@matter/main": "~0.16.0-alpha.0-
|
|
73
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
75
74
|
},
|
|
76
75
|
"description": "OnOff light/socket device with a CLI command execution interface",
|
|
77
76
|
"entrypoint": "DeviceNode.ts"
|
|
@@ -79,9 +78,8 @@
|
|
|
79
78
|
{
|
|
80
79
|
"name": "device-onoff-advanced",
|
|
81
80
|
"dependencies": {
|
|
82
|
-
"@matter/nodejs": "~0.16.0-alpha.0-
|
|
83
|
-
"@matter/
|
|
84
|
-
"@matter/main": "~0.16.0-alpha.0-20250912-0d12bf718"
|
|
81
|
+
"@matter/nodejs": "~0.16.0-alpha.0-20250913-0bc2515df",
|
|
82
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
85
83
|
},
|
|
86
84
|
"description": "OnOff light/socket device with BLE support and advanced API usage",
|
|
87
85
|
"entrypoint": "DeviceNodeFull.ts"
|
|
@@ -89,7 +87,7 @@
|
|
|
89
87
|
{
|
|
90
88
|
"name": "device-onoff-light",
|
|
91
89
|
"dependencies": {
|
|
92
|
-
"@matter/main": "~0.16.0-alpha.0-
|
|
90
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
93
91
|
},
|
|
94
92
|
"description": "OnOff light example which logs the state changes to the console",
|
|
95
93
|
"entrypoint": "LightDevice.ts"
|
|
@@ -97,7 +95,7 @@
|
|
|
97
95
|
{
|
|
98
96
|
"name": "device-robotic-vacuum-cleaner",
|
|
99
97
|
"dependencies": {
|
|
100
|
-
"@matter/main": "~0.16.0-alpha.0-
|
|
98
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
101
99
|
},
|
|
102
100
|
"description": "Robotic Vacuum Cleaner Example",
|
|
103
101
|
"entrypoint": "RoboticVacuumCleanerDevice.ts"
|
|
@@ -105,7 +103,7 @@
|
|
|
105
103
|
{
|
|
106
104
|
"name": "device-sensor",
|
|
107
105
|
"dependencies": {
|
|
108
|
-
"@matter/main": "~0.16.0-alpha.0-
|
|
106
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
109
107
|
},
|
|
110
108
|
"description": "Temperature/Humidity sensor with a CLI command interface to get the value",
|
|
111
109
|
"entrypoint": "SensorDeviceNode.ts"
|
|
@@ -113,7 +111,7 @@
|
|
|
113
111
|
{
|
|
114
112
|
"name": "device-simple",
|
|
115
113
|
"dependencies": {
|
|
116
|
-
"@matter/main": "~0.16.0-alpha.0-
|
|
114
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
117
115
|
},
|
|
118
116
|
"description": "A simple on/off device",
|
|
119
117
|
"entrypoint": "main.ts"
|
|
@@ -121,7 +119,7 @@
|
|
|
121
119
|
{
|
|
122
120
|
"name": "device-smoke-co-alarm",
|
|
123
121
|
"dependencies": {
|
|
124
|
-
"@matter/main": "~0.16.0-alpha.0-
|
|
122
|
+
"@matter/main": "~0.16.0-alpha.0-20250913-0bc2515df"
|
|
125
123
|
},
|
|
126
124
|
"description": "Smoke CO Alarm Example",
|
|
127
125
|
"entrypoint": "SmokeCOAlarmDeviceNode.ts"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matter/create",
|
|
3
|
-
"version": "0.16.0-alpha.0-
|
|
3
|
+
"version": "0.16.0-alpha.0-20250913-0bc2515df",
|
|
4
4
|
"description": "Matter.js skeleton project generator",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/matter-js/matter.js#readme",
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@matter/tools": "0.16.0-alpha.0-
|
|
35
|
+
"@matter/tools": "0.16.0-alpha.0-20250913-0bc2515df",
|
|
36
36
|
"@types/node": "^24.3.1",
|
|
37
37
|
"@types/tar-stream": "^3.1.4"
|
|
38
38
|
},
|