@matter/create 0.12.0-alpha.0-20250101-22e7c1044 → 0.12.0-alpha.0-20250103-ba0c01a01

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.
@@ -21,6 +21,7 @@
21
21
  */
22
22
 
23
23
  import {
24
+ Bytes,
24
25
  DeviceTypeId,
25
26
  Endpoint,
26
27
  EndpointServer,
@@ -34,7 +35,7 @@ import {
34
35
  logLevelFromString,
35
36
  singleton,
36
37
  } from "@matter/main";
37
- import { NetworkCommissioningServer, OnOffServer } from "@matter/main/behaviors";
38
+ import { OnOffServer } from "@matter/main/behaviors";
38
39
  import { GeneralDiagnostics, NetworkCommissioning } from "@matter/main/clusters";
39
40
  import { OnOffLightDevice, OnOffPlugInUnitDevice } from "@matter/main/devices";
40
41
  import { RootRequirements } from "@matter/main/endpoints";
@@ -164,6 +165,7 @@ class OnOffShellExecServer extends OnOffServer {
164
165
  class TestGeneralDiagnosticsServer extends RootRequirements.GeneralDiagnosticsServer {
165
166
  override initialize() {
166
167
  this.state.testEventTriggersEnabled = true; // set to true if you support test triggers ...
168
+ this.state.deviceTestEnableKey = Bytes.fromHex("0102030405060708090a0b0c0d0e0f10");
167
169
  super.initialize();
168
170
  }
169
171
 
@@ -205,12 +207,8 @@ class MyFancyOwnFunctionalityServer extends MyFancyOwnFunctionalityBehavior {
205
207
  // In this case we are using with() to install our On/Off cluster behavior.
206
208
  // .with("Lighting") not needed because we always have it in by default because we have default implementation
207
209
  const OnOffDevice = isSocket
208
- ? vendorId === 0xfff4
209
- ? OnOffPlugInUnitDevice.with(OnOffShellExecServer, MyFancyOwnFunctionalityServer)
210
- : OnOffPlugInUnitDevice.with(OnOffShellExecServer)
211
- : vendorId === 0xfff4
212
- ? OnOffLightDevice.with(OnOffShellExecServer, MyFancyOwnFunctionalityServer)
213
- : OnOffLightDevice.with(OnOffShellExecServer);
210
+ ? OnOffPlugInUnitDevice.with(OnOffShellExecServer)
211
+ : OnOffLightDevice.with(OnOffShellExecServer);
214
212
 
215
213
  /**
216
214
  * Modify automatically added clusters of the Root endpoint if needed
@@ -222,32 +220,8 @@ const OnOffDevice = isSocket
222
220
  */
223
221
 
224
222
  // We use the Basic Root Endpoint without a NetworkCommissioning cluster
225
- let RootEndpoint = ServerNode.RootEndpoint.with(TestGeneralDiagnosticsServer);
223
+ const RootEndpoint = ServerNode.RootEndpoint.with(TestGeneralDiagnosticsServer);
226
224
 
227
- let wifiOrThreadAdded = false;
228
- let threadAdded = false;
229
- if (Ble.enabled) {
230
- // matter.js will create a Ethernet-only device by default when ut comes to Network Commissioning Features.
231
- // To offer e.g. a "Wi-Fi only device" (or any other combination) we need to override the Network Commissioning
232
- // cluster and implement all the need handling here. This is a "static implementation" for pure demonstration
233
- // purposes and just "simulates" the actions to be done. In a real world implementation this would be done by
234
- // the device implementor based on the relevant networking stack.
235
- // The NetworkCommissioningCluster and all logics are described in Matter Core Specifications section 11.8
236
- if (environment.vars.has("ble.wifi.fake")) {
237
- RootEndpoint = RootEndpoint.with(DummyWifiNetworkCommissioningServer);
238
- wifiOrThreadAdded = true;
239
- } else if (environment.vars.has("ble.thread.fake")) {
240
- RootEndpoint = RootEndpoint.with(DummyThreadNetworkCommissioningServer);
241
- wifiOrThreadAdded = true;
242
- threadAdded = true;
243
- }
244
- } else {
245
- RootEndpoint = RootEndpoint.with(
246
- NetworkCommissioningServer.with(NetworkCommissioning.Feature.EthernetNetworkInterface),
247
- );
248
- }
249
-
250
- const networkId = new Uint8Array(32);
251
225
  // Physical devices appear as "nodes" on a Matter network. As a device implementer you use a NodeServer to bring a
252
226
  // device online.
253
227
  //
@@ -281,28 +255,54 @@ const server = await ServerNode.create(RootEndpoint, {
281
255
  serialNumber: `node-matter-${uniqueId}`,
282
256
  uniqueId,
283
257
  },
258
+ });
284
259
 
285
- // @ts-expect-error ... TS do not see the types because both next clusters was added conditionally
286
- networkCommissioning: {
287
- maxNetworks: 1,
288
- interfaceEnabled: true,
289
- lastConnectErrorValue: 0,
290
- lastNetworkId: wifiOrThreadAdded ? null : networkId,
291
- lastNetworkingStatus: wifiOrThreadAdded ? null : NetworkCommissioning.NetworkCommissioningStatus.Success,
292
- networks: [{ networkId: networkId, connected: !wifiOrThreadAdded }],
293
- scanMaxTimeSeconds: wifiOrThreadAdded ? 3 : undefined,
294
- connectMaxTimeSeconds: wifiOrThreadAdded ? 3 : undefined,
295
- supportedWifiBands: wifiOrThreadAdded && !threadAdded ? [NetworkCommissioning.WiFiBand["2G4"]] : undefined,
296
- supportedThreadFeatures: wifiOrThreadAdded && threadAdded ? { isFullThreadDevice: true } : undefined,
297
- threadVersion: wifiOrThreadAdded && threadAdded ? 4 : undefined, // means: Thread 1.3
298
- },
299
- myFancyFunctionality: {
260
+ const networkId = new Uint8Array(32);
261
+ if (Ble.enabled) {
262
+ // matter.js will create an Ethernet-only device by default when it comes to Network Commissioning Features.
263
+ // To offer e.g. a "Wi-Fi only device" (or any other combination) we need to override the Network Commissioning
264
+ // cluster and implement all the need handling here. This is a "static implementation" for pure demonstration
265
+ // purposes and just "simulates" the actions to be done. In a real world implementation this would be done by
266
+ // the device implementor based on the relevant networking stack.
267
+ // The NetworkCommissioningCluster and all logics are described in Matter Core Specifications section 11.8
268
+ if (environment.vars.has("ble.wifi.fake")) {
269
+ server.behaviors.require(DummyWifiNetworkCommissioningServer, {
270
+ maxNetworks: 1,
271
+ interfaceEnabled: true,
272
+ lastConnectErrorValue: 0,
273
+ lastNetworkId: networkId,
274
+ lastNetworkingStatus: null,
275
+ networks: [{ networkId: networkId, connected: false }],
276
+ scanMaxTimeSeconds: 3,
277
+ connectMaxTimeSeconds: 3,
278
+ supportedWiFiBands: [NetworkCommissioning.WiFiBand["2G4"]],
279
+ });
280
+ } else if (environment.vars.has("ble.thread.fake")) {
281
+ server.behaviors.require(DummyThreadNetworkCommissioningServer, {
282
+ maxNetworks: 1,
283
+ interfaceEnabled: true,
284
+ lastConnectErrorValue: 0,
285
+ lastNetworkId: null,
286
+ lastNetworkingStatus: null,
287
+ networks: [{ networkId: networkId, connected: false }],
288
+ scanMaxTimeSeconds: 3,
289
+ connectMaxTimeSeconds: 3,
290
+ supportedThreadFeatures: { isFullThreadDevice: true },
291
+ threadVersion: 4, // means: Thread 1.3
292
+ });
293
+ }
294
+ }
295
+
296
+ // Also add our Custom behavior when vendor id is 0xfff4 (just to show how it works)
297
+ if (vendorId === 0xfff4) {
298
+ server.behaviors.require(MyFancyOwnFunctionalityServer, {
300
299
  myFancyValue: 0,
301
- },
302
- });
300
+ });
301
+ }
303
302
 
304
303
  // Nodes are a composition of endpoints. Add a single endpoint to the node, our example light device.
305
304
  const endpoint = new Endpoint(OnOffDevice, { id: "onoff" });
305
+
306
306
  await server.add(endpoint);
307
307
 
308
308
  /**
@@ -317,7 +317,7 @@ server.lifecycle.decommissioned.on(() => console.log("Server was fully decommiss
317
317
  /** This event is triggered when the device went online. This means that it is discoverable in the network. */
318
318
  server.lifecycle.online.on(() => console.log("Server is online"));
319
319
 
320
- /** This event is triggered when the device went offline. it is not longer discoverable or connectable in the network. */
320
+ /** This event is triggered when the device went offline. It is no longer discoverable or connectable in the network. */
321
321
  server.lifecycle.offline.on(() => console.log("Server is offline"));
322
322
 
323
323
  /**
@@ -5,9 +5,9 @@
5
5
  {
6
6
  "name": "controller",
7
7
  "dependencies": {
8
- "@matter/main": "~0.12.0-alpha.0-20250101-22e7c1044",
9
- "@matter/nodejs-ble": "~0.12.0-alpha.0-20250101-22e7c1044",
10
- "@project-chip/matter.js": "~0.12.0-alpha.0-20250101-22e7c1044"
8
+ "@matter/main": "~0.12.0-alpha.0-20250103-ba0c01a01",
9
+ "@matter/nodejs-ble": "~0.12.0-alpha.0-20250103-ba0c01a01",
10
+ "@project-chip/matter.js": "~0.12.0-alpha.0-20250103-ba0c01a01"
11
11
  },
12
12
  "description": "Controller example to commission and connect devices",
13
13
  "entrypoint": "ControllerNode.ts"
@@ -15,7 +15,7 @@
15
15
  {
16
16
  "name": "device-bridge-onoff",
17
17
  "dependencies": {
18
- "@matter/main": "~0.12.0-alpha.0-20250101-22e7c1044"
18
+ "@matter/main": "~0.12.0-alpha.0-20250103-ba0c01a01"
19
19
  },
20
20
  "description": "Bridge for multiple OnOff light/sockets with a CLI command execution interface",
21
21
  "entrypoint": "BridgedDevicesNode.ts"
@@ -23,7 +23,7 @@
23
23
  {
24
24
  "name": "device-composed-onoff",
25
25
  "dependencies": {
26
- "@matter/main": "~0.12.0-alpha.0-20250101-22e7c1044"
26
+ "@matter/main": "~0.12.0-alpha.0-20250103-ba0c01a01"
27
27
  },
28
28
  "description": "Composed device for multiple OnOff light/sockets with a CLI command execution interface",
29
29
  "entrypoint": "ComposedDeviceNode.ts"
@@ -31,7 +31,7 @@
31
31
  {
32
32
  "name": "device-composed-wc-light",
33
33
  "dependencies": {
34
- "@matter/main": "~0.12.0-alpha.0-20250101-22e7c1044"
34
+ "@matter/main": "~0.12.0-alpha.0-20250103-ba0c01a01"
35
35
  },
36
36
  "description": "Composed device with Window covering and a light endpoint that logs changes",
37
37
  "entrypoint": "IlluminatedRollerShade.ts"
@@ -39,7 +39,7 @@
39
39
  {
40
40
  "name": "device-measuring-socket",
41
41
  "dependencies": {
42
- "@matter/main": "~0.12.0-alpha.0-20250101-22e7c1044"
42
+ "@matter/main": "~0.12.0-alpha.0-20250103-ba0c01a01"
43
43
  },
44
44
  "description": "Socket device that reports random Energy and Power measurements",
45
45
  "entrypoint": "MeasuredSocketDevice.ts"
@@ -47,7 +47,7 @@
47
47
  {
48
48
  "name": "device-multiple-onoff",
49
49
  "dependencies": {
50
- "@matter/main": "~0.12.0-alpha.0-20250101-22e7c1044"
50
+ "@matter/main": "~0.12.0-alpha.0-20250103-ba0c01a01"
51
51
  },
52
52
  "description": "Multiple OnOff light/socket nodes in one process with a CLI command execution interface",
53
53
  "entrypoint": "MultiDeviceNode.ts"
@@ -55,7 +55,7 @@
55
55
  {
56
56
  "name": "device-onoff",
57
57
  "dependencies": {
58
- "@matter/main": "~0.12.0-alpha.0-20250101-22e7c1044"
58
+ "@matter/main": "~0.12.0-alpha.0-20250103-ba0c01a01"
59
59
  },
60
60
  "description": "OnOff light/socket device with a CLI command execution interface",
61
61
  "entrypoint": "DeviceNode.ts"
@@ -63,9 +63,9 @@
63
63
  {
64
64
  "name": "device-onoff-advanced",
65
65
  "dependencies": {
66
- "@matter/main": "~0.12.0-alpha.0-20250101-22e7c1044",
67
- "@matter/nodejs": "~0.12.0-alpha.0-20250101-22e7c1044",
68
- "@matter/nodejs-ble": "~0.12.0-alpha.0-20250101-22e7c1044"
66
+ "@matter/main": "~0.12.0-alpha.0-20250103-ba0c01a01",
67
+ "@matter/nodejs": "~0.12.0-alpha.0-20250103-ba0c01a01",
68
+ "@matter/nodejs-ble": "~0.12.0-alpha.0-20250103-ba0c01a01"
69
69
  },
70
70
  "description": "OnOff light/socket device with BLE support and advanced API usage",
71
71
  "entrypoint": "DeviceNodeFull.ts"
@@ -73,7 +73,7 @@
73
73
  {
74
74
  "name": "device-onoff-light",
75
75
  "dependencies": {
76
- "@matter/main": "~0.12.0-alpha.0-20250101-22e7c1044"
76
+ "@matter/main": "~0.12.0-alpha.0-20250103-ba0c01a01"
77
77
  },
78
78
  "description": "OnOff light example which logs the state changes to the console",
79
79
  "entrypoint": "LightDevice.ts"
@@ -81,7 +81,7 @@
81
81
  {
82
82
  "name": "device-sensor",
83
83
  "dependencies": {
84
- "@matter/main": "~0.12.0-alpha.0-20250101-22e7c1044"
84
+ "@matter/main": "~0.12.0-alpha.0-20250103-ba0c01a01"
85
85
  },
86
86
  "description": "Temperature/Humidity sensor with a CLI command interface to get the value",
87
87
  "entrypoint": "SensorDeviceNode.ts"
@@ -89,7 +89,7 @@
89
89
  {
90
90
  "name": "device-simple",
91
91
  "dependencies": {
92
- "@matter/main": "~0.12.0-alpha.0-20250101-22e7c1044"
92
+ "@matter/main": "~0.12.0-alpha.0-20250103-ba0c01a01"
93
93
  },
94
94
  "description": "A simple on/off device",
95
95
  "entrypoint": "main.ts"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matter/create",
3
- "version": "0.12.0-alpha.0-20250101-22e7c1044",
3
+ "version": "0.12.0-alpha.0-20250103-ba0c01a01",
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/project-chip/matter.js#readme",
34
34
  "devDependencies": {
35
- "@matter/tools": "0.12.0-alpha.0-20250101-22e7c1044",
35
+ "@matter/tools": "0.12.0-alpha.0-20250103-ba0c01a01",
36
36
  "@types/node": "^22.10.1",
37
37
  "@types/tar-stream": "^3.1.3"
38
38
  },