@matter-server/dashboard 1.2.8 → 1.3.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.
Files changed (78) hide show
  1. package/dist/esm/client/models/descriptions.d.ts +8 -0
  2. package/dist/esm/client/models/descriptions.d.ts.map +1 -1
  3. package/dist/esm/client/models/descriptions.js +2049 -81
  4. package/dist/esm/client/models/descriptions.js.map +1 -1
  5. package/dist/esm/components/webrtc-stream-view.d.ts +35 -1
  6. package/dist/esm/components/webrtc-stream-view.d.ts.map +1 -1
  7. package/dist/esm/components/webrtc-stream-view.js +154 -90
  8. package/dist/esm/components/webrtc-stream-view.js.map +1 -1
  9. package/dist/esm/pages/camera-overlay.d.ts +1 -0
  10. package/dist/esm/pages/camera-overlay.d.ts.map +1 -1
  11. package/dist/esm/pages/camera-overlay.js +12 -14
  12. package/dist/esm/pages/camera-overlay.js.map +1 -1
  13. package/dist/esm/pages/cluster-commands/clusters/closure-control-commands.d.ts +35 -0
  14. package/dist/esm/pages/cluster-commands/clusters/closure-control-commands.d.ts.map +1 -0
  15. package/dist/esm/pages/cluster-commands/clusters/closure-control-commands.js +352 -0
  16. package/dist/esm/pages/cluster-commands/clusters/closure-control-commands.js.map +6 -0
  17. package/dist/esm/pages/cluster-commands/index.d.ts +1 -0
  18. package/dist/esm/pages/cluster-commands/index.d.ts.map +1 -1
  19. package/dist/esm/pages/cluster-commands/index.js +1 -0
  20. package/dist/esm/pages/cluster-commands/index.js.map +1 -1
  21. package/dist/esm/pages/components/node-details.d.ts.map +1 -1
  22. package/dist/esm/pages/components/node-details.js +17 -8
  23. package/dist/esm/pages/components/node-details.js.map +1 -1
  24. package/dist/esm/pages/matter-cluster-view.d.ts +1 -0
  25. package/dist/esm/pages/matter-cluster-view.d.ts.map +1 -1
  26. package/dist/esm/pages/matter-cluster-view.js +64 -0
  27. package/dist/esm/pages/matter-cluster-view.js.map +1 -1
  28. package/dist/esm/pages/matter-node-view.d.ts.map +1 -1
  29. package/dist/esm/pages/matter-node-view.js +10 -6
  30. package/dist/esm/pages/matter-node-view.js.map +1 -1
  31. package/dist/esm/util/camera.d.ts +22 -0
  32. package/dist/esm/util/camera.d.ts.map +1 -0
  33. package/dist/esm/util/camera.js +48 -0
  34. package/dist/esm/util/camera.js.map +6 -0
  35. package/dist/esm/util/closure-control.d.ts +57 -0
  36. package/dist/esm/util/closure-control.d.ts.map +1 -0
  37. package/dist/esm/util/closure-control.js +148 -0
  38. package/dist/esm/util/closure-control.js.map +6 -0
  39. package/dist/esm/util/cluster-features.d.ts +8 -0
  40. package/dist/esm/util/cluster-features.d.ts.map +1 -0
  41. package/dist/esm/util/cluster-features.js +14 -0
  42. package/dist/esm/util/cluster-features.js.map +6 -0
  43. package/dist/esm/util/device-icons.d.ts +0 -2
  44. package/dist/esm/util/device-icons.d.ts.map +1 -1
  45. package/dist/esm/util/device-icons.js +0 -6
  46. package/dist/esm/util/device-icons.js.map +1 -1
  47. package/dist/esm/util/endpoints.d.ts +11 -0
  48. package/dist/esm/util/endpoints.d.ts.map +1 -1
  49. package/dist/esm/util/endpoints.js +33 -1
  50. package/dist/esm/util/endpoints.js.map +1 -1
  51. package/dist/web/js/{attribute-write-dialog-CB7oucjt.js → attribute-write-dialog-UxEN5w8r.js} +1 -1
  52. package/dist/web/js/{command-invoke-dialog-C9rdQjTo.js → command-invoke-dialog-CVXU-ZoZ.js} +1 -1
  53. package/dist/web/js/{commission-node-dialog-BwkiZy8i.js → commission-node-dialog-D5HIBPy_.js} +5 -5
  54. package/dist/web/js/{commission-node-existing-BWTlMlwi.js → commission-node-existing-Bniw0yfY.js} +1 -1
  55. package/dist/web/js/{commission-node-thread-WDo3_tCy.js → commission-node-thread-D7w0p3f2.js} +1 -1
  56. package/dist/web/js/{commission-node-wifi-Drj7Z0rY.js → commission-node-wifi-DeTq4twp.js} +1 -1
  57. package/dist/web/js/{dialog-box-Dq6fTPQH.js → dialog-box-DkTPEszi.js} +1 -1
  58. package/dist/web/js/{fabric-label-dialog-FE4tGieS.js → fabric-label-dialog-8kIYOl4q.js} +1 -1
  59. package/dist/web/js/main.js +1 -1
  60. package/dist/web/js/{matter-dashboard-app-Ditf9BYC.js → matter-dashboard-app-BBGILOPg.js} +3303 -717
  61. package/dist/web/js/{node-acl-add-dialog-BA3u0qYj.js → node-acl-add-dialog-KiDTJk-M.js} +1 -1
  62. package/dist/web/js/{node-binding-dialog-BV_fMc0a.js → node-binding-dialog-DffAwr6H.js} +1 -1
  63. package/dist/web/js/{node-label-dialog-DG5CqG1e.js → node-label-dialog-DhRlTzGl.js} +1 -1
  64. package/dist/web/js/{settings-dialog-VafGbl7R.js → settings-dialog-BOy5I7JW.js} +1 -1
  65. package/package.json +4 -4
  66. package/src/client/models/descriptions.ts +2053 -78
  67. package/src/components/webrtc-stream-view.ts +216 -112
  68. package/src/pages/camera-overlay.ts +17 -18
  69. package/src/pages/cluster-commands/clusters/closure-control-commands.ts +393 -0
  70. package/src/pages/cluster-commands/index.ts +1 -0
  71. package/src/pages/components/node-details.ts +19 -9
  72. package/src/pages/matter-cluster-view.ts +73 -0
  73. package/src/pages/matter-node-view.ts +10 -6
  74. package/src/util/camera.ts +67 -0
  75. package/src/util/closure-control.ts +193 -0
  76. package/src/util/cluster-features.ts +17 -0
  77. package/src/util/device-icons.ts +0 -7
  78. package/src/util/endpoints.ts +50 -0
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025-2026 Open Home Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import type { MatterNode } from "@matter-server/ws-client";
8
+ import {
9
+ AVSM_FEAT_SNP,
10
+ AVSM_FEATURE_MAP_ATTR_ID,
11
+ CAMERA_AV_STREAM_MANAGEMENT_CLUSTER_ID,
12
+ isAudioOnlyAvsm,
13
+ readAvsmFeatures,
14
+ } from "../components/webrtc-stream-view.js";
15
+
16
+ export const WEBRTC_TRANSPORT_PROVIDER_CLUSTER_ID = 0x553;
17
+
18
+ const DESCRIPTOR_CLUSTER_ID = 29;
19
+ const SERVER_LIST_ATTR_ID = 1;
20
+ const ACCEPTED_COMMAND_LIST_ATTR_ID = 0xfff9;
21
+ const CAPTURE_SNAPSHOT_COMMAND_ID = 12;
22
+ const SNAPSHOT_CAPABILITIES_ATTR_ID = 10;
23
+
24
+ function serverClusters(node: MatterNode, endpoint: number): number[] {
25
+ const raw = node.attributes[`${endpoint}/${DESCRIPTOR_CLUSTER_ID}/${SERVER_LIST_ATTR_ID}`];
26
+ return Array.isArray(raw) ? raw.map(v => Number(v)) : new Array<number>();
27
+ }
28
+
29
+ /**
30
+ * Live view drives a WebRTC session (WebRtcTransportProvider) fed by a video stream allocated
31
+ * through CameraAvStreamManagement, so both clusters must be present on the endpoint.
32
+ */
33
+ export function supportsLiveView(node: MatterNode, endpoint: number): boolean {
34
+ const clusters = serverClusters(node, endpoint);
35
+ return (
36
+ clusters.includes(WEBRTC_TRANSPORT_PROVIDER_CLUSTER_ID) &&
37
+ clusters.includes(CAMERA_AV_STREAM_MANAGEMENT_CLUSTER_ID)
38
+ );
39
+ }
40
+
41
+ export function supportsSnapshot(node: MatterNode, endpoint: number): boolean {
42
+ const accepted =
43
+ node.attributes[`${endpoint}/${CAMERA_AV_STREAM_MANAGEMENT_CLUSTER_ID}/${ACCEPTED_COMMAND_LIST_ATTR_ID}`];
44
+ if (!Array.isArray(accepted) || !accepted.includes(CAPTURE_SNAPSHOT_COMMAND_ID)) return false;
45
+ // Some cameras set the SNP feature bit but leave SnapshotCapabilities empty, so the feature bit
46
+ // is authoritative and the capabilities list a fallback hint.
47
+ const featureMap =
48
+ node.attributes[`${endpoint}/${CAMERA_AV_STREAM_MANAGEMENT_CLUSTER_ID}/${AVSM_FEATURE_MAP_ATTR_ID}`];
49
+ if (typeof featureMap === "number" && (featureMap & AVSM_FEAT_SNP) !== 0) return true;
50
+ const caps =
51
+ node.attributes[`${endpoint}/${CAMERA_AV_STREAM_MANAGEMENT_CLUSTER_ID}/${SNAPSHOT_CAPABILITIES_ATTR_ID}`];
52
+ return Array.isArray(caps) && caps.length > 0;
53
+ }
54
+
55
+ export function supportsCameraOverlay(node: MatterNode, endpoint: number): boolean {
56
+ return supportsLiveView(node, endpoint) || supportsSnapshot(node, endpoint);
57
+ }
58
+
59
+ /**
60
+ * True when live view is available and the FeatureMap is known not to advertise Video (VDO) —
61
+ * e.g. Audio Doorbell, Intercom. The session streams audio only, so the UI should say "Listen"
62
+ * rather than "Live View". A device whose FeatureMap hasn't been read yet is not treated as
63
+ * audio-only, so a real camera isn't mislabelled while its attribute is still in flight.
64
+ */
65
+ export function supportsAudioOnlyLiveView(node: MatterNode, endpoint: number): boolean {
66
+ return supportsLiveView(node, endpoint) && isAudioOnlyAvsm(readAvsmFeatures(node, endpoint));
67
+ }
@@ -0,0 +1,193 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025-2026 Open Home Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import type { MatterClient, MatterNode } from "@matter-server/ws-client";
8
+ import { asObject, pickNumber } from "./attribute-shapes.js";
9
+
10
+ /** ClosureControl cluster (Matter spec §5.4). */
11
+ export const CLOSURE_CONTROL_CLUSTER_ID = 260; // 0x0104
12
+
13
+ const ATTR_COUNTDOWN_TIME = 0;
14
+ const ATTR_MAIN_STATE = 1;
15
+ const ATTR_CURRENT_ERROR_LIST = 2;
16
+ const ATTR_OVERALL_CURRENT_STATE = 3;
17
+ const ATTR_OVERALL_TARGET_STATE = 4;
18
+ const ATTR_LATCH_CONTROL_MODES = 5;
19
+ const ATTR_FEATURE_MAP = 0xfffc;
20
+
21
+ export const MAIN_STATE_LABELS: Record<number, string> = {
22
+ 0: "Stopped",
23
+ 1: "Moving",
24
+ 2: "Waiting for motion",
25
+ 3: "Error",
26
+ 4: "Calibrating",
27
+ 5: "Protected",
28
+ 6: "Disengaged",
29
+ 7: "Setup required",
30
+ };
31
+
32
+ export const CLOSURE_ERROR_LABELS: Record<number, string> = {
33
+ 0: "Physically blocked",
34
+ 1: "Blocked by sensor",
35
+ 2: "Temperature limited",
36
+ 3: "Maintenance required",
37
+ 4: "Internal interference",
38
+ };
39
+
40
+ /** MoveTo / OverallTargetState.position (TargetPositionEnum, spec §5.4.6.2). */
41
+ export const TARGET_POSITION_LABELS: Record<number, string> = {
42
+ 0: "Fully closed",
43
+ 1: "Fully open",
44
+ 2: "Pedestrian",
45
+ 3: "Ventilation",
46
+ 4: "Signature",
47
+ };
48
+
49
+ /** OverallCurrentState.position (CurrentPositionEnum, spec §5.4.6.1) — diverges from TargetPosition at 2+. */
50
+ export const CURRENT_POSITION_LABELS: Record<number, string> = {
51
+ 0: "Fully closed",
52
+ 1: "Fully open",
53
+ 2: "Partially open",
54
+ 3: "Pedestrian",
55
+ 4: "Ventilation",
56
+ 5: "Signature",
57
+ };
58
+
59
+ export const SPEED_LABELS: Record<number, string> = {
60
+ 0: "Auto",
61
+ 1: "Low",
62
+ 2: "Medium",
63
+ 3: "High",
64
+ };
65
+
66
+ export interface ClosureFeatures {
67
+ positioning: boolean;
68
+ motionLatching: boolean;
69
+ instantaneous: boolean;
70
+ speed: boolean;
71
+ ventilation: boolean;
72
+ pedestrian: boolean;
73
+ calibration: boolean;
74
+ protection: boolean;
75
+ manuallyOperable: boolean;
76
+ }
77
+
78
+ export interface ClosureState {
79
+ position: number | null;
80
+ latch: boolean | null;
81
+ speed: number | null;
82
+ }
83
+
84
+ export interface ClosureCurrentState extends ClosureState {
85
+ secureState: boolean | null;
86
+ }
87
+
88
+ function readAttr(node: MatterNode, endpoint: number, attrId: number): unknown {
89
+ return node.attributes[`${endpoint}/${CLOSURE_CONTROL_CLUSTER_ID}/${attrId}`];
90
+ }
91
+
92
+ /** ClosureControl FeatureMap bits per Matter spec §5.4.5 (PS=0, LT=1, IS=2, SP=3, VT=4, PD=5, CL=6, PT=7, MO=8). */
93
+ export function parseClosureFeatures(featureMap: number): ClosureFeatures {
94
+ return {
95
+ positioning: (featureMap & (1 << 0)) !== 0,
96
+ motionLatching: (featureMap & (1 << 1)) !== 0,
97
+ instantaneous: (featureMap & (1 << 2)) !== 0,
98
+ speed: (featureMap & (1 << 3)) !== 0,
99
+ ventilation: (featureMap & (1 << 4)) !== 0,
100
+ pedestrian: (featureMap & (1 << 5)) !== 0,
101
+ calibration: (featureMap & (1 << 6)) !== 0,
102
+ protection: (featureMap & (1 << 7)) !== 0,
103
+ manuallyOperable: (featureMap & (1 << 8)) !== 0,
104
+ };
105
+ }
106
+
107
+ export function readFeatures(node: MatterNode, endpoint: number): ClosureFeatures {
108
+ const v = readAttr(node, endpoint, ATTR_FEATURE_MAP);
109
+ return parseClosureFeatures(typeof v === "number" ? v : 0);
110
+ }
111
+
112
+ export function readMainState(node: MatterNode, endpoint: number): number | null {
113
+ const v = readAttr(node, endpoint, ATTR_MAIN_STATE);
114
+ return typeof v === "number" ? v : null;
115
+ }
116
+
117
+ export function readCurrentErrorList(node: MatterNode, endpoint: number): number[] {
118
+ const raw = readAttr(node, endpoint, ATTR_CURRENT_ERROR_LIST);
119
+ return Array.isArray(raw) ? raw.filter((v): v is number => typeof v === "number" && Number.isFinite(v)) : [];
120
+ }
121
+
122
+ export function readCountdownTime(node: MatterNode, endpoint: number): number | null {
123
+ const v = readAttr(node, endpoint, ATTR_COUNTDOWN_TIME);
124
+ return typeof v === "number" ? v : null;
125
+ }
126
+
127
+ function readBoolField(obj: Record<string, unknown>, name: string, tag: string): boolean | null {
128
+ const v = obj[name] ?? obj[tag];
129
+ return typeof v === "boolean" ? v : null;
130
+ }
131
+
132
+ export function readOverallCurrentState(node: MatterNode, endpoint: number): ClosureCurrentState | null {
133
+ const obj = asObject(readAttr(node, endpoint, ATTR_OVERALL_CURRENT_STATE));
134
+ if (!obj) return null;
135
+ return {
136
+ position: pickNumber(obj, "position", "0"),
137
+ latch: readBoolField(obj, "latch", "1"),
138
+ speed: pickNumber(obj, "speed", "2"),
139
+ secureState: readBoolField(obj, "secureState", "3"),
140
+ };
141
+ }
142
+
143
+ export function readOverallTargetState(node: MatterNode, endpoint: number): ClosureState | null {
144
+ const obj = asObject(readAttr(node, endpoint, ATTR_OVERALL_TARGET_STATE));
145
+ if (!obj) return null;
146
+ return {
147
+ position: pickNumber(obj, "position", "0"),
148
+ latch: readBoolField(obj, "latch", "1"),
149
+ speed: pickNumber(obj, "speed", "2"),
150
+ };
151
+ }
152
+
153
+ export interface LatchControlModes {
154
+ remoteLatching: boolean;
155
+ remoteUnlatching: boolean;
156
+ }
157
+
158
+ /** Whether the latch mechanism accepts remote (un)latch requests, vs. manual-only per spec §5.4.6.7. */
159
+ export function readLatchControlModes(node: MatterNode, endpoint: number): LatchControlModes {
160
+ const v = readAttr(node, endpoint, ATTR_LATCH_CONTROL_MODES);
161
+ const bitmap = typeof v === "number" ? v : 0;
162
+ return {
163
+ remoteLatching: (bitmap & (1 << 0)) !== 0,
164
+ remoteUnlatching: (bitmap & (1 << 1)) !== 0,
165
+ };
166
+ }
167
+
168
+ export async function stop(client: MatterClient, nodeId: number | bigint, endpoint: number): Promise<void> {
169
+ await client.deviceCommand(nodeId, endpoint, CLOSURE_CONTROL_CLUSTER_ID, "Stop", {});
170
+ }
171
+
172
+ export async function calibrate(client: MatterClient, nodeId: number | bigint, endpoint: number): Promise<void> {
173
+ await client.deviceCommand(nodeId, endpoint, CLOSURE_CONTROL_CLUSTER_ID, "Calibrate", {});
174
+ }
175
+
176
+ export interface MoveToParams {
177
+ position?: number;
178
+ latch?: boolean;
179
+ speed?: number;
180
+ }
181
+
182
+ export async function moveTo(
183
+ client: MatterClient,
184
+ nodeId: number | bigint,
185
+ endpoint: number,
186
+ params: MoveToParams,
187
+ ): Promise<void> {
188
+ const payload: Record<string, unknown> = {};
189
+ if (params.position !== undefined) payload.position = params.position;
190
+ if (params.latch !== undefined) payload.latch = params.latch;
191
+ if (params.speed !== undefined) payload.speed = params.speed;
192
+ await client.deviceCommand(nodeId, endpoint, CLOSURE_CONTROL_CLUSTER_ID, "MoveTo", payload);
193
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025-2026 Open Home Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import type { ClusterFeatureDescription } from "../client/models/descriptions.js";
8
+
9
+ // Decode a cluster's FeatureMap bitmap into the subset of its known features that are active.
10
+ export function computeActiveClusterFeatures(
11
+ featureMapValue: unknown,
12
+ knownFeatures: ClusterFeatureDescription[],
13
+ ): ClusterFeatureDescription[] {
14
+ if (featureMapValue === undefined) return [];
15
+ const featureMap = Number(featureMapValue);
16
+ return knownFeatures.filter(feature => (featureMap & (1 << feature.bit)) !== 0).sort((a, b) => a.bit - b.bit);
17
+ }
@@ -189,13 +189,6 @@ export const DeviceTypes = {
189
189
  INTERCOM: 0x0140,
190
190
  };
191
191
 
192
- /** Device types whose mandatory clusters include WebRTCTransportProvider (0x553), i.e. support live streaming. */
193
- export const LIVE_VIEW_DEVICE_TYPE_IDS: readonly number[] = Object.freeze([
194
- DeviceTypes.CAMERA,
195
- DeviceTypes.VIDEO_DOORBELL,
196
- DeviceTypes.FLOODLIGHT_CAMERA,
197
- ]);
198
-
199
192
  /**
200
193
  * Maps device type IDs to MDI icon paths.
201
194
  */
@@ -15,3 +15,53 @@ export function getEndpointDeviceTypes(node: MatterNode, endpoint: number): Devi
15
15
  return device_types[id] ?? { id: id ?? -1, label: `Unknown Device Type (${id})`, clusters: [] };
16
16
  });
17
17
  }
18
+
19
+ export interface EndpointTreeNode {
20
+ endpointId: number;
21
+ depth: number;
22
+ }
23
+
24
+ /**
25
+ * Orders endpoints into parent-first tree order using each endpoint's Descriptor PartsList
26
+ * (attribute 29/3). PartsList on an ancestor also lists indirect descendants, so for each
27
+ * endpoint we keep only the closest parent (the one whose own PartsList doesn't contain
28
+ * another candidate parent that also lists the endpoint).
29
+ */
30
+ export function getEndpointTree(node: MatterNode, endpointIds: number[]): EndpointTreeNode[] {
31
+ const idSet = new Set(endpointIds);
32
+ const partsList = new Map<number, number[]>(
33
+ endpointIds.map(id => {
34
+ const raw = node.attributes[`${id}/29/3`];
35
+ const list = Array.isArray(raw) ? (raw as number[]) : [];
36
+ return [id, list.filter(childId => idSet.has(childId) && childId !== id)];
37
+ }),
38
+ );
39
+ const partsSet = new Map<number, Set<number>>([...partsList].map(([id, list]) => [id, new Set(list)]));
40
+
41
+ const children = new Map<number, number[]>();
42
+ const hasParent = new Set<number>();
43
+ for (const id of endpointIds) {
44
+ const descendants = partsList.get(id)!;
45
+ const directChildren = descendants
46
+ .filter(child => !descendants.some(other => other !== child && partsSet.get(other)!.has(child)))
47
+ .sort((a, b) => a - b);
48
+ children.set(id, directChildren);
49
+ for (const child of directChildren) hasParent.add(child);
50
+ }
51
+
52
+ const roots = endpointIds.filter(id => !hasParent.has(id)).sort((a, b) => a - b);
53
+ const ordered: EndpointTreeNode[] = [];
54
+ const visited = new Set<number>();
55
+ const visit = (id: number, depth: number) => {
56
+ if (visited.has(id)) return;
57
+ visited.add(id);
58
+ ordered.push({ endpointId: id, depth });
59
+ for (const child of children.get(id)!) visit(child, depth + 1);
60
+ };
61
+ for (const root of roots) visit(root, 0);
62
+ // PartsList cycles can leave every endpoint marked as someone's child (no roots) or
63
+ // strand nodes unreached; fall back to emitting anything still unvisited as a root
64
+ // so malformed device data never makes endpoints disappear from the list.
65
+ for (const id of [...endpointIds].sort((a, b) => a - b)) visit(id, 0);
66
+ return ordered;
67
+ }