@matter/examples 0.16.0-alpha.0-20251006-3fe1e7c57 → 0.16.0-alpha.0-20251013-89bb7099d

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.
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @license
4
+ * Copyright 2022-2025 Matter.js Authors
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+ import { MqttServer, ServerNode } from "@matter/main";
8
+ import { OnOffLightDevice, OnOffLightRequirements } from "@matter/main/devices/on-off-light";
9
+ import "@matter/mqtt";
10
+ const node = await ServerNode.create(ServerNode.RootEndpoint.with(MqttServer));
11
+ class ReportingOnOffServer extends OnOffLightRequirements.OnOffServer {
12
+ initialize() {
13
+ this.events.onOff$Changed.on((value) => {
14
+ console.log(`Light is now ${value ? "ON" : "OFF"}`);
15
+ });
16
+ }
17
+ }
18
+ await node.add(OnOffLightDevice.with(ReportingOnOffServer));
19
+ await node.run();
20
+ //# sourceMappingURL=MqttDevice.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/mqtt-device/MqttDevice.ts"],
4
+ "mappings": ";AACA;AAAA;AAAA;AAAA;AAAA;AAQA,SAAS,YAAY,kBAAkB;AACvC,SAAS,kBAAkB,8BAA8B;AAGzD,OAAO;AAeP,MAAM,OAAO,MAAM,WAAW,OAAO,WAAW,aAAa,KAAK,UAAU,CAAC;AAG7E,MAAM,6BAA6B,uBAAuB,YAAY;AAAA,EACzD,aAAa;AAClB,SAAK,OAAO,cAAc,GAAG,WAAS;AAClC,cAAQ,IAAI,gBAAgB,QAAQ,OAAO,KAAK,EAAE;AAAA,IACtD,CAAC;AAAA,EACL;AACJ;AAEA,MAAM,KAAK,IAAI,iBAAiB,KAAK,oBAAoB,CAAC;AAE1D,MAAM,KAAK,IAAI;",
5
+ "names": []
6
+ }
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @license
4
+ * Copyright 2022-2025 Matter.js Authors
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+ import { ServerNode, WebSocketServer } from "@matter/main";
8
+ import { OnOffLightDevice, OnOffLightRequirements } from "@matter/main/devices/on-off-light";
9
+ import "@matter/nodejs-ws";
10
+ const node = await ServerNode.create(ServerNode.RootEndpoint.with(WebSocketServer));
11
+ class ReportingOnOffServer extends OnOffLightRequirements.OnOffServer {
12
+ initialize() {
13
+ this.events.onOff$Changed.on((value) => {
14
+ console.log(`Light is now ${value ? "ON" : "OFF"}`);
15
+ });
16
+ }
17
+ }
18
+ await node.add(OnOffLightDevice.with(ReportingOnOffServer));
19
+ await node.run();
20
+ //# sourceMappingURL=WebSocketDevice.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/web-socket-device/WebSocketDevice.ts"],
4
+ "mappings": ";AACA;AAAA;AAAA;AAAA;AAAA;AAQA,SAAS,YAAY,uBAAuB;AAC5C,SAAS,kBAAkB,8BAA8B;AAGzD,OAAO;AAcP,MAAM,OAAO,MAAM,WAAW,OAAO,WAAW,aAAa,KAAK,eAAe,CAAC;AAGlF,MAAM,6BAA6B,uBAAuB,YAAY;AAAA,EACzD,aAAa;AAClB,SAAK,OAAO,cAAc,GAAG,WAAS;AAClC,cAAQ,IAAI,gBAAgB,QAAQ,OAAO,KAAK,EAAE;AAAA,IACtD,CAAC;AAAA,EACL;AACJ;AAEA,MAAM,KAAK,IAAI,iBAAiB,KAAK,oBAAoB,CAAC;AAE1D,MAAM,KAAK,IAAI;",
5
+ "names": []
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matter/examples",
3
- "version": "0.16.0-alpha.0-20251006-3fe1e7c57",
3
+ "version": "0.16.0-alpha.0-20251013-89bb7099d",
4
4
  "description": "Matter.js examples and reference implementations",
5
5
  "keywords": [
6
6
  "iot",
@@ -55,14 +55,17 @@
55
55
  "matter-controller": "dist/esm/controller/ControllerNode.js"
56
56
  },
57
57
  "dependencies": {
58
- "@matter/main": "0.16.0-alpha.0-20251006-3fe1e7c57",
59
- "@matter/nodejs": "0.16.0-alpha.0-20251006-3fe1e7c57",
60
- "@matter/tools": "0.16.0-alpha.0-20251006-3fe1e7c57",
61
- "@project-chip/matter.js": "0.16.0-alpha.0-20251006-3fe1e7c57",
62
- "esbuild": "^0.25.9"
58
+ "@matter/main": "0.16.0-alpha.0-20251013-89bb7099d",
59
+ "@matter/nodejs": "0.16.0-alpha.0-20251013-89bb7099d",
60
+ "@matter/tools": "0.16.0-alpha.0-20251013-89bb7099d",
61
+ "@project-chip/matter.js": "0.16.0-alpha.0-20251013-89bb7099d",
62
+ "esbuild": "^0.25.9",
63
+ "@matter/nodejs-ble": "0.16.0-alpha.0-20251013-89bb7099d",
64
+ "@matter/mqtt": "0.16.0-alpha.0-20251013-89bb7099d",
65
+ "@matter/nodejs-ws": "0.16.0-alpha.0-20251013-89bb7099d"
63
66
  },
64
67
  "optionalDependencies": {
65
- "@matter/nodejs-ble": "0.16.0-alpha.0-20251006-3fe1e7c57"
68
+ "@matter/nodejs-ble": "0.16.0-alpha.0-20251013-89bb7099d"
66
69
  },
67
70
  "engines": {
68
71
  "node": ">=20.19.0 <22.0.0 || >=22.13.0"
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @license
4
+ * Copyright 2022-2025 Matter.js Authors
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+
8
+ // This demonstrates a matter.js device that supports an MQTT API on Node.js
9
+
10
+ import { MqttServer, ServerNode } from "@matter/main";
11
+ import { OnOffLightDevice, OnOffLightRequirements } from "@matter/main/devices/on-off-light";
12
+
13
+ // This plugin installs MQTT support for matter.js
14
+ import "@matter/mqtt";
15
+
16
+ /**
17
+ * Create node with MQTT APIs enabled.
18
+ *
19
+ * This requires an MQTT 5 broker. By default we configure the broker on localhost.
20
+ *
21
+ * You may configure the broker address here, or use environment variables:
22
+ *
23
+ * MATTER_MQTT_ADDRESS=mqtt://localhost/matter/light01
24
+ *
25
+ * or command line arguments:
26
+ *
27
+ * --mqtt-address=mqtt://localhost/matter/light01
28
+ */
29
+ const node = await ServerNode.create(ServerNode.RootEndpoint.with(MqttServer));
30
+
31
+ // For demonstration purposes, this server prints state changes to the console
32
+ class ReportingOnOffServer extends OnOffLightRequirements.OnOffServer {
33
+ override initialize() {
34
+ this.events.onOff$Changed.on(value => {
35
+ console.log(`Light is now ${value ? "ON" : "OFF"}`);
36
+ });
37
+ }
38
+ }
39
+
40
+ await node.add(OnOffLightDevice.with(ReportingOnOffServer));
41
+
42
+ await node.run();
@@ -0,0 +1,13 @@
1
+ # Example device with MQTT control enabled
2
+
3
+ This example demonstrates how to implement a matter.js device that you can control via MQTT.
4
+
5
+ This requires an MQTT 5 broker. The example is configured for a broker on localhost by default.
6
+
7
+ You may modify {@link MqttDevice.ts} to change the default address, or override using environment variables:
8
+
9
+ MATTER_MQTT_ADDRESS=mqtt://localhost/matter/light01
10
+
11
+ or command line arguments:
12
+
13
+ --mqtt-address=mqtt://localhost/matter/light01
package/src/tsconfig.json CHANGED
@@ -12,9 +12,15 @@
12
12
  {
13
13
  "path": "../../matter.js/src"
14
14
  },
15
+ {
16
+ "path": "../../mqtt/src"
17
+ },
15
18
  {
16
19
  "path": "../../nodejs-ble/src"
17
20
  },
21
+ {
22
+ "path": "../../nodejs-ws/src"
23
+ },
18
24
  {
19
25
  "path": "../../nodejs/src"
20
26
  },
@@ -0,0 +1,12 @@
1
+ # Example device with WebSocket control enabled
2
+
3
+ This example demonstrates how to implement a matter.js device that you can control via WebSockets.
4
+
5
+ By default the device listens on a UNIX socket under ~/.matter/matter.sock. You can change by modifying {@link
6
+ WebSocketDevice.ts} or override with environment variables:
7
+
8
+ MATTER_WEBSOCKET_ADDRESS=ws://localhost
9
+
10
+ or command line arguments:
11
+
12
+ --websocket-address=ws://localhost
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @license
4
+ * Copyright 2022-2025 Matter.js Authors
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+
8
+ // This demonstrates a matter.js device that supports a WebSocket API on Node.js
9
+
10
+ import { ServerNode, WebSocketServer } from "@matter/main";
11
+ import { OnOffLightDevice, OnOffLightRequirements } from "@matter/main/devices/on-off-light";
12
+
13
+ // This plugin installs WebSocket support for matter.js on Node.js
14
+ import "@matter/nodejs-ws";
15
+
16
+ /**
17
+ * Create node with WebSocket APIs enabled.
18
+ *
19
+ * By default these listen on a UNIX socket under ~/.matter/matter.sock. You can change this here or by using
20
+ * environment variables:
21
+ *
22
+ * MATTER_WEBSOCKET_ADDRESS=ws://localhost
23
+ *
24
+ * or command line arguments:
25
+ *
26
+ * --websocket-address=ws://localhost
27
+ */
28
+ const node = await ServerNode.create(ServerNode.RootEndpoint.with(WebSocketServer));
29
+
30
+ // For demonstration purposes, this server prints state changes to the console
31
+ class ReportingOnOffServer extends OnOffLightRequirements.OnOffServer {
32
+ override initialize() {
33
+ this.events.onOff$Changed.on(value => {
34
+ console.log(`Light is now ${value ? "ON" : "OFF"}`);
35
+ });
36
+ }
37
+ }
38
+
39
+ await node.add(OnOffLightDevice.with(ReportingOnOffServer));
40
+
41
+ await node.run();