@matter-server/dashboard 1.5.6-alpha.0-20261114-ddb31cd → 1.6.0
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/components/chip-list.d.ts +15 -0
- package/dist/esm/components/chip-list.d.ts.map +1 -0
- package/dist/esm/components/chip-list.js +20 -0
- package/dist/esm/components/chip-list.js.map +6 -0
- package/dist/esm/components/dialogs/fabric-label-dialog/fabric-label-dialog.d.ts.map +1 -1
- package/dist/esm/components/dialogs/fabric-label-dialog/fabric-label-dialog.js +11 -5
- package/dist/esm/components/dialogs/fabric-label-dialog/fabric-label-dialog.js.map +1 -1
- package/dist/esm/components/dialogs/node-label-dialog/node-label-dialog.d.ts.map +1 -1
- package/dist/esm/components/dialogs/node-label-dialog/node-label-dialog.js +2 -3
- package/dist/esm/components/dialogs/node-label-dialog/node-label-dialog.js.map +1 -1
- package/dist/esm/components/semantic-tag-chips.d.ts +1 -2
- package/dist/esm/components/semantic-tag-chips.d.ts.map +1 -1
- package/dist/esm/components/semantic-tag-chips.js +2 -10
- package/dist/esm/components/semantic-tag-chips.js.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/avsum-commands.d.ts.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/avsum-commands.js +4 -3
- package/dist/esm/pages/cluster-commands/clusters/avsum-commands.js.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/basic-information-commands.d.ts.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/basic-information-commands.js +2 -3
- package/dist/esm/pages/cluster-commands/clusters/basic-information-commands.js.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/zone-management-commands.d.ts.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/zone-management-commands.js +0 -1
- package/dist/esm/pages/cluster-commands/clusters/zone-management-commands.js.map +1 -1
- package/dist/esm/pages/matter-cluster-view.d.ts +1 -0
- package/dist/esm/pages/matter-cluster-view.d.ts.map +1 -1
- package/dist/esm/pages/matter-cluster-view.js +27 -1
- package/dist/esm/pages/matter-cluster-view.js.map +1 -1
- package/dist/esm/util/avsum.d.ts +7 -0
- package/dist/esm/util/avsum.d.ts.map +1 -1
- package/dist/esm/util/avsum.js +5 -0
- package/dist/esm/util/avsum.js.map +1 -1
- package/dist/esm/util/chip-text.d.ts +14 -0
- package/dist/esm/util/chip-text.d.ts.map +1 -0
- package/dist/esm/util/chip-text.js +16 -0
- package/dist/esm/util/chip-text.js.map +6 -0
- package/dist/esm/util/endpoint-label.d.ts.map +1 -1
- package/dist/esm/util/endpoint-label.js +8 -9
- package/dist/esm/util/endpoint-label.js.map +1 -1
- package/dist/esm/util/label-length.d.ts +11 -0
- package/dist/esm/util/label-length.d.ts.map +1 -0
- package/dist/esm/util/label-length.js +14 -0
- package/dist/esm/util/label-length.js.map +6 -0
- package/dist/esm/util/label-list.d.ts +33 -0
- package/dist/esm/util/label-list.d.ts.map +1 -0
- package/dist/esm/util/label-list.js +47 -0
- package/dist/esm/util/label-list.js.map +6 -0
- package/dist/esm/util/node-label.d.ts +3 -2
- package/dist/esm/util/node-label.d.ts.map +1 -1
- package/dist/esm/util/node-label.js +7 -3
- package/dist/esm/util/node-label.js.map +1 -1
- package/dist/esm/util/semantic-tags.d.ts +2 -5
- package/dist/esm/util/semantic-tags.d.ts.map +1 -1
- package/dist/esm/util/semantic-tags.js +2 -5
- package/dist/esm/util/semantic-tags.js.map +1 -1
- package/dist/web/js/{attribute-write-dialog-ShbilQzq.js → attribute-write-dialog-C5H1hYCh.js} +1 -1
- package/dist/web/js/{command-invoke-dialog-D6uUqzX3.js → command-invoke-dialog-DlbPP_Wu.js} +1 -1
- package/dist/web/js/{commission-node-dialog-CJ6aw9lk.js → commission-node-dialog-WFZcwSgL.js} +5 -5
- package/dist/web/js/{commission-node-existing-DE8IZQ5s.js → commission-node-existing-B-8_PJXh.js} +1 -1
- package/dist/web/js/{commission-node-thread-BuurVjpm.js → commission-node-thread-BMAaHRE7.js} +1 -1
- package/dist/web/js/{commission-node-wifi-DE-FUW4S.js → commission-node-wifi-KDjCP9BF.js} +1 -1
- package/dist/web/js/{dialog-box-DT5swFpZ.js → dialog-box-BL3Mqpl4.js} +1 -1
- package/dist/web/js/{fabric-label-dialog-dzunWV5m.js → fabric-label-dialog-CdYSfT08.js} +14 -6
- package/dist/web/js/main.js +3 -2
- package/dist/web/js/{matter-dashboard-app-B-zK5IW3.js → matter-dashboard-app-SgzIBXor.js} +137 -45
- package/dist/web/js/{node-acl-add-dialog-CcTsEhnc.js → node-acl-add-dialog-CMQZ5D8d.js} +1 -1
- package/dist/web/js/{node-binding-dialog-BbIqj67g.js → node-binding-dialog-CLh7bcJz.js} +1 -1
- package/dist/web/js/{node-label-dialog-CjXZbpK7.js → node-label-dialog-T264l0uQ.js} +2 -3
- package/dist/web/js/{settings-dialog-DUKiCCKZ.js → settings-dialog-DdsjlFA9.js} +1 -1
- package/package.json +4 -4
- package/src/components/chip-list.ts +26 -0
- package/src/components/dialogs/fabric-label-dialog/fabric-label-dialog.ts +11 -5
- package/src/components/dialogs/node-label-dialog/node-label-dialog.ts +2 -3
- package/src/components/semantic-tag-chips.ts +4 -12
- package/src/pages/cluster-commands/clusters/avsum-commands.ts +4 -3
- package/src/pages/cluster-commands/clusters/basic-information-commands.ts +2 -3
- package/src/pages/cluster-commands/clusters/zone-management-commands.ts +0 -1
- package/src/pages/matter-cluster-view.ts +35 -1
- package/src/util/avsum.ts +11 -0
- package/src/util/chip-text.ts +23 -0
- package/src/util/endpoint-label.ts +12 -19
- package/src/util/label-length.ts +15 -0
- package/src/util/label-list.ts +64 -0
- package/src/util/node-label.ts +8 -3
- package/src/util/semantic-tags.ts +3 -12
|
@@ -18,6 +18,7 @@ import { customElement, property, state } from "lit/decorators.js";
|
|
|
18
18
|
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
19
19
|
import { clientContext, tickContext } from "../client/client-context.js";
|
|
20
20
|
import { clusters } from "../client/models/descriptions.js";
|
|
21
|
+
import { renderChipList } from "../components/chip-list.js";
|
|
21
22
|
import { showAlertDialog } from "../components/dialog-box/show-dialog-box.js";
|
|
22
23
|
import { showAttributeWriteDialog } from "../components/dialogs/dev/show-attribute-write-dialog.js";
|
|
23
24
|
import { showCommandInvokeDialog } from "../components/dialogs/dev/show-command-invoke-dialog.js";
|
|
@@ -30,6 +31,13 @@ import { computeActiveClusterFeatures } from "../util/cluster-features.js";
|
|
|
30
31
|
import { DevModeService } from "../util/dev-mode-service.js";
|
|
31
32
|
import { getEndpointLabel } from "../util/endpoint-label.js";
|
|
32
33
|
import { formatHex, formatNodeAddress, getEffectiveFabricIndex } from "../util/format_hex.js";
|
|
34
|
+
import {
|
|
35
|
+
decodeLabelList,
|
|
36
|
+
describeLabelListEntry,
|
|
37
|
+
FIXED_LABEL_CLUSTER_ID,
|
|
38
|
+
LABEL_LIST_ATTR,
|
|
39
|
+
USER_LABEL_CLUSTER_ID,
|
|
40
|
+
} from "../util/label-list.js";
|
|
33
41
|
import { decodeSemanticTagList, DESCRIPTOR_CLUSTER_ID, TAG_LIST_ATTR } from "../util/semantic-tags.js";
|
|
34
42
|
import { infoPanelStyles, notFoundStyles } from "../util/shared-styles.js";
|
|
35
43
|
import {
|
|
@@ -418,7 +426,11 @@ class MatterClusterView extends LitElement {
|
|
|
418
426
|
|
|
419
427
|
private _renderClusterInfoPanel(): TemplateResult | typeof nothing {
|
|
420
428
|
const sections = new Array<TemplateResult>();
|
|
421
|
-
for (const section of [
|
|
429
|
+
for (const section of [
|
|
430
|
+
this._renderFeaturesSection(),
|
|
431
|
+
this._renderTagListSection(),
|
|
432
|
+
this._renderLabelListSection(),
|
|
433
|
+
]) {
|
|
422
434
|
if (section !== undefined) sections.push(section);
|
|
423
435
|
}
|
|
424
436
|
if (sections.length === 0) return nothing;
|
|
@@ -479,6 +491,28 @@ class MatterClusterView extends LitElement {
|
|
|
479
491
|
`;
|
|
480
492
|
}
|
|
481
493
|
|
|
494
|
+
private _renderLabelListSection(): TemplateResult | undefined {
|
|
495
|
+
if (this.cluster !== USER_LABEL_CLUSTER_ID && this.cluster !== FIXED_LABEL_CLUSTER_ID) return undefined;
|
|
496
|
+
if (!this.node) return undefined;
|
|
497
|
+
|
|
498
|
+
const value = this.node.attributes[`${this.endpoint}/${this.cluster}/${LABEL_LIST_ATTR}`];
|
|
499
|
+
const labelList = decodeLabelList(value);
|
|
500
|
+
if (labelList === undefined) return undefined;
|
|
501
|
+
|
|
502
|
+
const title = this.cluster === USER_LABEL_CLUSTER_ID ? "User Labels (LabelList)" : "Fixed Labels (LabelList)";
|
|
503
|
+
|
|
504
|
+
return html`
|
|
505
|
+
<div class="info-section">
|
|
506
|
+
<div class="info-section-header">${title}</div>
|
|
507
|
+
${
|
|
508
|
+
labelList.length === 0
|
|
509
|
+
? html`<p class="empty">No labels</p>`
|
|
510
|
+
: renderChipList(labelList.map(describeLabelListEntry))
|
|
511
|
+
}
|
|
512
|
+
</div>
|
|
513
|
+
`;
|
|
514
|
+
}
|
|
515
|
+
|
|
482
516
|
private async _showAttributeValue(value: any) {
|
|
483
517
|
showAlertDialog({
|
|
484
518
|
title: "Attribute value",
|
package/src/util/avsum.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import type { MatterClient, MatterNode } from "@matter-server/ws-client";
|
|
8
8
|
import { asObject, pickNumber, pickString } from "./attribute-shapes.js";
|
|
9
|
+
import { labelLengthError } from "./label-length.js";
|
|
9
10
|
|
|
10
11
|
/** Camera AV Settings User Level Management cluster (Matter spec). */
|
|
11
12
|
export const AVSUM_CLUSTER_ID = 1362; // 0x0552
|
|
@@ -199,6 +200,14 @@ export async function moveToPreset(
|
|
|
199
200
|
await client.deviceCommand(nodeId, endpoint, AVSUM_CLUSTER_ID, "MPTZMoveToPreset", { presetID: presetId });
|
|
200
201
|
}
|
|
201
202
|
|
|
203
|
+
export const PRESET_NAME_MAX_BYTES = 32;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Saves the current position as a preset. Throws without sending the command when the name is longer than
|
|
207
|
+
* {@link PRESET_NAME_MAX_BYTES} bytes.
|
|
208
|
+
*
|
|
209
|
+
* @see MatterSpecification.v161.Cluster § 11.3.7.4
|
|
210
|
+
*/
|
|
202
211
|
export async function savePreset(
|
|
203
212
|
client: MatterClient,
|
|
204
213
|
nodeId: number | bigint,
|
|
@@ -206,6 +215,8 @@ export async function savePreset(
|
|
|
206
215
|
name: string,
|
|
207
216
|
presetId?: number,
|
|
208
217
|
): Promise<void> {
|
|
218
|
+
const lengthError = labelLengthError(name, PRESET_NAME_MAX_BYTES);
|
|
219
|
+
if (lengthError !== undefined) throw new Error(lengthError);
|
|
209
220
|
const payload: Record<string, unknown> = { name };
|
|
210
221
|
if (presetId !== undefined) payload.presetID = presetId;
|
|
211
222
|
await client.deviceCommand(nodeId, endpoint, AVSUM_CLUSTER_ID, "MPTZSavePreset", payload);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Open Home Foundation
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { toBigIntAwareJson } from "@matter-server/ws-client";
|
|
8
|
+
|
|
9
|
+
/** One chip of a decoded list attribute; an `erroneous` chip renders with the error style. */
|
|
10
|
+
export interface ChipText {
|
|
11
|
+
text: string;
|
|
12
|
+
title: string;
|
|
13
|
+
erroneous: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const RAW_ENTRY_TEXT_MAX = 60;
|
|
17
|
+
|
|
18
|
+
/** Error chip for a list entry that did not decode as a valid `structName`; the tooltip keeps the full JSON. */
|
|
19
|
+
export function describeRawEntry(raw: unknown, structName: string): ChipText {
|
|
20
|
+
const json = raw === undefined ? "undefined" : toBigIntAwareJson(raw);
|
|
21
|
+
const text = json.length > RAW_ENTRY_TEXT_MAX ? `${json.slice(0, RAW_ENTRY_TEXT_MAX - 1)}…` : json;
|
|
22
|
+
return { text, title: `Invalid ${structName}: ${json}`, erroneous: true };
|
|
23
|
+
}
|
|
@@ -7,36 +7,33 @@
|
|
|
7
7
|
import type { MatterNode } from "@matter-server/ws-client";
|
|
8
8
|
import { attributeArray } from "./access-control.js";
|
|
9
9
|
import { tagField, toText } from "./attribute-shapes.js";
|
|
10
|
+
import {
|
|
11
|
+
FIXED_LABEL_CLUSTER_ID,
|
|
12
|
+
LABEL_LIST_ATTR,
|
|
13
|
+
LABEL_STRUCT_VALUE_TAG,
|
|
14
|
+
USER_LABEL_CLUSTER_ID,
|
|
15
|
+
} from "./label-list.js";
|
|
10
16
|
|
|
11
17
|
// BridgedDeviceBasicInformation cluster (0x39 / 57): carries its own NodeLabel per bridged
|
|
12
18
|
// endpoint, distinct from the whole-node BasicInformation NodeLabel on endpoint 0.
|
|
13
19
|
const BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_ID = 57;
|
|
14
20
|
const BRIDGED_NODE_LABEL_ATTRIBUTE_ID = 5;
|
|
15
21
|
|
|
16
|
-
// FixedLabel (0x40 / 64) and UserLabel (0x41 / 65) both expose a LabelList of LabelStruct
|
|
17
|
-
// entries; either can be present on any endpoint as Matter's generic per-endpoint labeling
|
|
18
|
-
// mechanism (FixedLabel is factory-set, UserLabel is user/controller-writable).
|
|
19
|
-
const FIXED_LABEL_CLUSTER_ID = 64;
|
|
20
|
-
const USER_LABEL_CLUSTER_ID = 65;
|
|
21
|
-
const LABEL_LIST_ATTRIBUTE_ID = 0;
|
|
22
|
-
|
|
23
22
|
/** The label shares a single-line header with the endpoint number and the cluster name. */
|
|
24
23
|
const MAX_LABEL_ENTRIES = 3;
|
|
25
24
|
const MAX_LABEL_LENGTH = 60;
|
|
26
25
|
|
|
27
|
-
/**
|
|
28
|
-
* A device padding a fixed-width label field with NULs reports the padding as text;
|
|
29
|
-
* `MatterNode.nodeLabel` rejects the same shape rather than rendering it.
|
|
30
|
-
*/
|
|
26
|
+
/** A device padding a fixed-width label field with NULs reports the padding as text. */
|
|
31
27
|
function labelText(value: unknown): string | undefined {
|
|
32
28
|
const text = toText(value);
|
|
33
29
|
return text === undefined || text.includes("\u0000") ? undefined : text;
|
|
34
30
|
}
|
|
35
31
|
|
|
36
|
-
//
|
|
32
|
+
// Best effort: only the Value of each LabelStruct identifies the endpoint (Label is the category,
|
|
33
|
+
// e.g. "room"), so a malformed Label does not hide a usable Value.
|
|
37
34
|
function decodeLabelListValues(raw: unknown): string[] {
|
|
38
35
|
return attributeArray(raw)
|
|
39
|
-
.map(entry => labelText(tagField(entry,
|
|
36
|
+
.map(entry => labelText(tagField(entry, LABEL_STRUCT_VALUE_TAG)))
|
|
40
37
|
.filter((value): value is string => value !== undefined);
|
|
41
38
|
}
|
|
42
39
|
|
|
@@ -60,11 +57,7 @@ export function getEndpointLabel(node: MatterNode, endpoint: number): string | u
|
|
|
60
57
|
if (bridgedNodeLabel !== undefined) return joinLabels([bridgedNodeLabel]);
|
|
61
58
|
|
|
62
59
|
return (
|
|
63
|
-
joinLabels(
|
|
64
|
-
|
|
65
|
-
) ??
|
|
66
|
-
joinLabels(
|
|
67
|
-
decodeLabelListValues(node.attributes[`${endpoint}/${FIXED_LABEL_CLUSTER_ID}/${LABEL_LIST_ATTRIBUTE_ID}`]),
|
|
68
|
-
)
|
|
60
|
+
joinLabels(decodeLabelListValues(node.attributes[`${endpoint}/${USER_LABEL_CLUSTER_ID}/${LABEL_LIST_ATTR}`])) ??
|
|
61
|
+
joinLabels(decodeLabelListValues(node.attributes[`${endpoint}/${FIXED_LABEL_CLUSTER_ID}/${LABEL_LIST_ATTR}`]))
|
|
69
62
|
);
|
|
70
63
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Open Home Foundation
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Why this label is too long, or undefined when it fits. Matter string limits count UTF-8 bytes, so a label inside
|
|
9
|
+
* the character count can still be too long.
|
|
10
|
+
*/
|
|
11
|
+
export function labelLengthError(label: string, maxBytes: number): string | undefined {
|
|
12
|
+
const bytes = new TextEncoder().encode(label).length;
|
|
13
|
+
if (bytes <= maxBytes) return undefined;
|
|
14
|
+
return `The label is ${bytes} bytes long, the maximum is ${maxBytes}; accented and non-Latin characters take more than one byte.`;
|
|
15
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Open Home Foundation
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { attributeArray } from "./access-control.js";
|
|
8
|
+
import { tagField } from "./attribute-shapes.js";
|
|
9
|
+
import { describeRawEntry, type ChipText } from "./chip-text.js";
|
|
10
|
+
|
|
11
|
+
// FixedLabel (0x40 / 64) and UserLabel (0x41 / 65) both expose a LabelList of LabelStruct
|
|
12
|
+
// entries; either can be present on any endpoint as Matter's generic per-endpoint labeling
|
|
13
|
+
// mechanism (FixedLabel is factory-set, UserLabel is user/controller-writable).
|
|
14
|
+
export const FIXED_LABEL_CLUSTER_ID = 64;
|
|
15
|
+
export const USER_LABEL_CLUSTER_ID = 65;
|
|
16
|
+
export const LABEL_LIST_ATTR = 0;
|
|
17
|
+
export const LABEL_STRUCT_LABEL_TAG = 0;
|
|
18
|
+
export const LABEL_STRUCT_VALUE_TAG = 1;
|
|
19
|
+
|
|
20
|
+
export interface LabelListItem {
|
|
21
|
+
label: string;
|
|
22
|
+
value: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type LabelListEntry = { kind: "label"; item: LabelListItem } | { kind: "raw"; raw: unknown };
|
|
26
|
+
|
|
27
|
+
function labelField(raw: unknown): string | undefined {
|
|
28
|
+
return typeof raw === "string" && !raw.includes("\u0000") ? raw : undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Both fields are mandatory, so an entry missing one is flagged instead of taking the spec's empty fallback.
|
|
32
|
+
function decodeLabelListItem(entry: unknown): LabelListItem | undefined {
|
|
33
|
+
const label = labelField(tagField(entry, LABEL_STRUCT_LABEL_TAG));
|
|
34
|
+
const value = labelField(tagField(entry, LABEL_STRUCT_VALUE_TAG));
|
|
35
|
+
return label === undefined || value === undefined ? undefined : { label, value };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Decodes a FixedLabel/UserLabel LabelList for display. An entry that is not a LabelStruct with two
|
|
40
|
+
* strings, or that carries NUL characters, stays a `raw` entry so the reported data remains visible.
|
|
41
|
+
*
|
|
42
|
+
* @returns undefined when the attribute was not read or was removed (`null`); an empty array when the
|
|
43
|
+
* device reports no labels
|
|
44
|
+
* @see MatterSpecification.v161.Core § 9.7.4.1
|
|
45
|
+
*/
|
|
46
|
+
export function decodeLabelList(value: unknown): LabelListEntry[] | undefined {
|
|
47
|
+
if (value === undefined || value === null) return undefined;
|
|
48
|
+
if (typeof value !== "object") return [{ kind: "raw", raw: value }];
|
|
49
|
+
|
|
50
|
+
return attributeArray(value).map((entry): LabelListEntry => {
|
|
51
|
+
const item = decodeLabelListItem(entry);
|
|
52
|
+
return item === undefined ? { kind: "raw", raw: entry } : { kind: "label", item };
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function describeLabelListEntry(entry: LabelListEntry): ChipText {
|
|
57
|
+
if (entry.kind === "raw") return describeRawEntry(entry.raw, "LabelStruct");
|
|
58
|
+
|
|
59
|
+
const label = entry.item.label.trim();
|
|
60
|
+
const value = entry.item.value.trim();
|
|
61
|
+
const text = label !== "" && value !== "" ? `${label}: ${value}` : label || value || "(empty label)";
|
|
62
|
+
const title = `Label ${JSON.stringify(entry.item.label)} = ${JSON.stringify(entry.item.value)}`;
|
|
63
|
+
return { text, title, erroneous: false };
|
|
64
|
+
}
|
package/src/util/node-label.ts
CHANGED
|
@@ -5,22 +5,27 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { MatterClient, MatterNode } from "@matter-server/ws-client";
|
|
8
|
+
import { labelLengthError } from "./label-length.js";
|
|
8
9
|
import { requireAttributeWriteSuccess } from "./matter-status.js";
|
|
9
10
|
|
|
10
11
|
// BasicInformation cluster (0x28 / 40), always on endpoint 0 per Matter specification.
|
|
11
12
|
export const NODE_LABEL_CLUSTER_ID = 0x28;
|
|
12
13
|
export const NODE_LABEL_ATTRIBUTE_ID = 5;
|
|
13
|
-
export const
|
|
14
|
+
export const NODE_LABEL_MAX_BYTES = 32;
|
|
14
15
|
|
|
15
16
|
export const NODE_LABEL_ATTRIBUTE_PATH = `0/${NODE_LABEL_CLUSTER_ID}/${NODE_LABEL_ATTRIBUTE_ID}`;
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Write the BasicInformation NodeLabel attribute for a node.
|
|
19
|
-
* Trims surrounding whitespace so the stored value matches what MatterNode.nodeLabel reads back.
|
|
20
|
+
* Trims surrounding whitespace so the stored value matches what MatterNode.nodeLabel reads back. Throws without
|
|
21
|
+
* writing when the label is longer than {@link NODE_LABEL_MAX_BYTES} bytes.
|
|
20
22
|
*/
|
|
21
23
|
export async function writeNodeLabel(client: MatterClient, node: MatterNode, label: string): Promise<void> {
|
|
24
|
+
const trimmed = label.trim();
|
|
25
|
+
const lengthError = labelLengthError(trimmed, NODE_LABEL_MAX_BYTES);
|
|
26
|
+
if (lengthError !== undefined) throw new Error(lengthError);
|
|
22
27
|
requireAttributeWriteSuccess(
|
|
23
|
-
await client.writeAttribute(node.node_id, NODE_LABEL_ATTRIBUTE_PATH,
|
|
28
|
+
await client.writeAttribute(node.node_id, NODE_LABEL_ATTRIBUTE_PATH, trimmed),
|
|
24
29
|
"Writing the node label failed",
|
|
25
30
|
);
|
|
26
31
|
}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { MatterNode } from "@matter-server/ws-client";
|
|
8
|
-
import { toBigIntAwareJson } from "@matter-server/ws-client";
|
|
9
8
|
import { semantic_tag_namespaces } from "../client/models/descriptions.js";
|
|
10
9
|
import { attributeArray } from "./access-control.js";
|
|
10
|
+
import { describeRawEntry, type ChipText } from "./chip-text.js";
|
|
11
11
|
import { formatHex } from "./format_hex.js";
|
|
12
12
|
|
|
13
13
|
// Descriptor cluster and its TagList attribute (semantic tags for the endpoint)
|
|
@@ -60,18 +60,9 @@ export function getEndpointSemanticTags(node: MatterNode, endpoint: number): Sem
|
|
|
60
60
|
return decodeSemanticTagList(node.attributes[`${endpoint}/${DESCRIPTOR_CLUSTER_ID}/${TAG_LIST_ATTR}`]) ?? [];
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
export function describeSemanticTagListEntry(entry: SemanticTagListEntry): {
|
|
66
|
-
text: string;
|
|
67
|
-
title: string;
|
|
68
|
-
erroneous: boolean;
|
|
69
|
-
} {
|
|
63
|
+
export function describeSemanticTagListEntry(entry: SemanticTagListEntry): ChipText {
|
|
70
64
|
if (entry.kind === "tag") return { ...describeSemanticTag(entry.semtag), erroneous: false };
|
|
71
|
-
|
|
72
|
-
const raw = entry.raw === undefined ? "undefined" : toBigIntAwareJson(entry.raw);
|
|
73
|
-
const text = raw.length > RAW_ENTRY_TEXT_MAX ? `${raw.slice(0, RAW_ENTRY_TEXT_MAX - 1)}…` : raw;
|
|
74
|
-
return { text, title: `Not a SemanticTagStruct: ${raw}`, erroneous: true };
|
|
65
|
+
return describeRawEntry(entry.raw, "SemanticTagStruct");
|
|
75
66
|
}
|
|
76
67
|
|
|
77
68
|
// Renders a single semantic tag as "Namespace → Tag", falling back to raw ids when the
|