@matter-server/dashboard 1.4.0 → 1.4.1-alpha.0-20261008-d619c2e
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/README.md +13 -13
- package/dist/esm/client/models/descriptions.d.ts.map +1 -1
- package/dist/esm/client/models/descriptions.js +479 -28
- package/dist/esm/client/models/descriptions.js.map +1 -1
- package/dist/esm/components/avsum-ptz-strip.d.ts.map +1 -1
- package/dist/esm/components/avsum-ptz-strip.js +6 -6
- package/dist/esm/components/avsum-ptz-strip.js.map +1 -1
- package/dist/esm/components/semantic-tag-chips.d.ts +16 -0
- package/dist/esm/components/semantic-tag-chips.d.ts.map +1 -0
- package/dist/esm/components/semantic-tag-chips.js +22 -0
- package/dist/esm/components/semantic-tag-chips.js.map +6 -0
- package/dist/esm/pages/cluster-commands/clusters/access-control-commands.d.ts.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/access-control-commands.js +3 -2
- package/dist/esm/pages/cluster-commands/clusters/access-control-commands.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 +34 -34
- 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 -1
- package/dist/esm/pages/cluster-commands/clusters/basic-information-commands.js.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/closure-control-commands.d.ts.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/closure-control-commands.js +16 -4
- package/dist/esm/pages/cluster-commands/clusters/closure-control-commands.js.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/closure-dimension-commands.d.ts +41 -0
- package/dist/esm/pages/cluster-commands/clusters/closure-dimension-commands.d.ts.map +1 -0
- package/dist/esm/pages/cluster-commands/clusters/closure-dimension-commands.js +459 -0
- package/dist/esm/pages/cluster-commands/clusters/closure-dimension-commands.js.map +6 -0
- package/dist/esm/pages/cluster-commands/clusters/commodity-tariff-commands.js +1 -1
- package/dist/esm/pages/cluster-commands/clusters/commodity-tariff-commands.js.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/device-energy-management-commands.d.ts +34 -0
- package/dist/esm/pages/cluster-commands/clusters/device-energy-management-commands.d.ts.map +1 -0
- package/dist/esm/pages/cluster-commands/clusters/device-energy-management-commands.js +324 -0
- package/dist/esm/pages/cluster-commands/clusters/device-energy-management-commands.js.map +6 -0
- package/dist/esm/pages/cluster-commands/clusters/device-energy-management-mode-commands.d.ts +30 -0
- package/dist/esm/pages/cluster-commands/clusters/device-energy-management-mode-commands.d.ts.map +1 -0
- package/dist/esm/pages/cluster-commands/clusters/device-energy-management-mode-commands.js +167 -0
- package/dist/esm/pages/cluster-commands/clusters/device-energy-management-mode-commands.js.map +6 -0
- package/dist/esm/pages/cluster-commands/clusters/door-lock-commands.d.ts +56 -0
- package/dist/esm/pages/cluster-commands/clusters/door-lock-commands.d.ts.map +1 -0
- package/dist/esm/pages/cluster-commands/clusters/door-lock-commands.js +1919 -0
- package/dist/esm/pages/cluster-commands/clusters/door-lock-commands.js.map +6 -0
- package/dist/esm/pages/cluster-commands/clusters/energy-evse-commands.d.ts +58 -0
- package/dist/esm/pages/cluster-commands/clusters/energy-evse-commands.d.ts.map +1 -0
- package/dist/esm/pages/cluster-commands/clusters/energy-evse-commands.js +886 -0
- package/dist/esm/pages/cluster-commands/clusters/energy-evse-commands.js.map +6 -0
- package/dist/esm/pages/cluster-commands/clusters/icd-management-commands.d.ts.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/icd-management-commands.js +2 -1
- package/dist/esm/pages/cluster-commands/clusters/icd-management-commands.js.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/ikea-valve-calibration-commands.d.ts +25 -0
- package/dist/esm/pages/cluster-commands/clusters/ikea-valve-calibration-commands.d.ts.map +1 -0
- package/dist/esm/pages/cluster-commands/clusters/ikea-valve-calibration-commands.js +135 -0
- package/dist/esm/pages/cluster-commands/clusters/ikea-valve-calibration-commands.js.map +6 -0
- package/dist/esm/pages/cluster-commands/clusters/media-playback-commands.d.ts +30 -0
- package/dist/esm/pages/cluster-commands/clusters/media-playback-commands.d.ts.map +1 -0
- package/dist/esm/pages/cluster-commands/clusters/media-playback-commands.js +266 -0
- package/dist/esm/pages/cluster-commands/clusters/media-playback-commands.js.map +6 -0
- package/dist/esm/pages/cluster-commands/clusters/operational-state-commands.d.ts +27 -0
- package/dist/esm/pages/cluster-commands/clusters/operational-state-commands.d.ts.map +1 -0
- package/dist/esm/pages/cluster-commands/clusters/operational-state-commands.js +215 -0
- package/dist/esm/pages/cluster-commands/clusters/operational-state-commands.js.map +6 -0
- package/dist/esm/pages/cluster-commands/clusters/service-area-commands.d.ts +47 -0
- package/dist/esm/pages/cluster-commands/clusters/service-area-commands.d.ts.map +1 -0
- package/dist/esm/pages/cluster-commands/clusters/service-area-commands.js +344 -0
- package/dist/esm/pages/cluster-commands/clusters/service-area-commands.js.map +6 -0
- package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.d.ts +24 -2
- package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.d.ts.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.js +368 -6
- package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.js.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/water-heater-management-commands.d.ts +29 -0
- package/dist/esm/pages/cluster-commands/clusters/water-heater-management-commands.d.ts.map +1 -0
- package/dist/esm/pages/cluster-commands/clusters/water-heater-management-commands.js +262 -0
- package/dist/esm/pages/cluster-commands/clusters/water-heater-management-commands.js.map +6 -0
- package/dist/esm/pages/cluster-commands/index.d.ts +10 -0
- package/dist/esm/pages/cluster-commands/index.d.ts.map +1 -1
- package/dist/esm/pages/cluster-commands/index.js +10 -0
- package/dist/esm/pages/cluster-commands/index.js.map +1 -1
- package/dist/esm/pages/matter-cluster-view.d.ts.map +1 -1
- package/dist/esm/pages/matter-cluster-view.js +6 -24
- package/dist/esm/pages/matter-cluster-view.js.map +1 -1
- package/dist/esm/pages/matter-endpoint-view.d.ts.map +1 -1
- package/dist/esm/pages/matter-endpoint-view.js +20 -2
- package/dist/esm/pages/matter-endpoint-view.js.map +1 -1
- package/dist/esm/pages/matter-network-view.d.ts +16 -0
- package/dist/esm/pages/matter-network-view.d.ts.map +1 -1
- package/dist/esm/pages/matter-network-view.js +55 -6
- package/dist/esm/pages/matter-network-view.js.map +1 -1
- package/dist/esm/pages/matter-node-view.d.ts.map +1 -1
- package/dist/esm/pages/matter-node-view.js +33 -4
- package/dist/esm/pages/matter-node-view.js.map +1 -1
- package/dist/esm/pages/network/border-router-store.d.ts +19 -0
- package/dist/esm/pages/network/border-router-store.d.ts.map +1 -1
- package/dist/esm/pages/network/border-router-store.js +61 -3
- package/dist/esm/pages/network/border-router-store.js.map +1 -1
- package/dist/esm/pages/network/network-details.d.ts +0 -3
- package/dist/esm/pages/network/network-details.d.ts.map +1 -1
- package/dist/esm/pages/network/network-details.js +15 -22
- package/dist/esm/pages/network/network-details.js.map +1 -1
- package/dist/esm/pages/network/network-utils.d.ts +4 -6
- package/dist/esm/pages/network/network-utils.d.ts.map +1 -1
- package/dist/esm/pages/network/network-utils.js +19 -13
- package/dist/esm/pages/network/network-utils.js.map +1 -1
- package/dist/esm/pages/network/thread-graph.d.ts +0 -5
- package/dist/esm/pages/network/thread-graph.d.ts.map +1 -1
- package/dist/esm/pages/network/thread-graph.js +21 -38
- package/dist/esm/pages/network/thread-graph.js.map +1 -1
- package/dist/esm/util/closure-control.d.ts +1 -0
- package/dist/esm/util/closure-control.d.ts.map +1 -1
- package/dist/esm/util/closure-control.js +5 -0
- package/dist/esm/util/closure-control.js.map +1 -1
- package/dist/esm/util/closure-dimension.d.ts +83 -0
- package/dist/esm/util/closure-dimension.d.ts.map +1 -0
- package/dist/esm/util/closure-dimension.js +238 -0
- package/dist/esm/util/closure-dimension.js.map +6 -0
- package/dist/esm/util/commodity-tariff.d.ts +1 -2
- package/dist/esm/util/commodity-tariff.d.ts.map +1 -1
- package/dist/esm/util/commodity-tariff.js +9 -17
- package/dist/esm/util/commodity-tariff.js.map +1 -1
- package/dist/esm/util/device-energy-management-mode.d.ts +35 -0
- package/dist/esm/util/device-energy-management-mode.d.ts.map +1 -0
- package/dist/esm/util/device-energy-management-mode.js +80 -0
- package/dist/esm/util/device-energy-management-mode.js.map +6 -0
- package/dist/esm/util/device-energy-management.d.ts +90 -0
- package/dist/esm/util/device-energy-management.d.ts.map +1 -0
- package/dist/esm/util/device-energy-management.js +230 -0
- package/dist/esm/util/device-energy-management.js.map +6 -0
- package/dist/esm/util/device-icons.d.ts.map +1 -1
- package/dist/esm/util/device-icons.js +3 -3
- package/dist/esm/util/device-icons.js.map +1 -1
- package/dist/esm/util/door-lock.d.ts +249 -0
- package/dist/esm/util/door-lock.d.ts.map +1 -0
- package/dist/esm/util/door-lock.js +724 -0
- package/dist/esm/util/door-lock.js.map +6 -0
- package/dist/esm/util/endpoint-label.d.ts +13 -0
- package/dist/esm/util/endpoint-label.d.ts.map +1 -0
- package/dist/esm/util/endpoint-label.js +41 -0
- package/dist/esm/util/endpoint-label.js.map +6 -0
- package/dist/esm/util/energy-evse.d.ts +116 -0
- package/dist/esm/util/energy-evse.d.ts.map +1 -0
- package/dist/esm/util/energy-evse.js +308 -0
- package/dist/esm/util/energy-evse.js.map +6 -0
- package/dist/esm/util/enum-label.d.ts +24 -0
- package/dist/esm/util/enum-label.d.ts.map +1 -0
- package/dist/esm/util/enum-label.js +24 -0
- package/dist/esm/util/enum-label.js.map +6 -0
- package/dist/esm/util/error-text.d.ts +8 -0
- package/dist/esm/util/error-text.d.ts.map +1 -0
- package/dist/esm/util/error-text.js +12 -0
- package/dist/esm/util/error-text.js.map +6 -0
- package/dist/esm/util/ikea-valve-calibration.d.ts +21 -0
- package/dist/esm/util/ikea-valve-calibration.d.ts.map +1 -0
- package/dist/esm/util/ikea-valve-calibration.js +43 -0
- package/dist/esm/util/ikea-valve-calibration.js.map +6 -0
- package/dist/esm/util/media-playback.d.ts +47 -0
- package/dist/esm/util/media-playback.d.ts.map +1 -0
- package/dist/esm/util/media-playback.js +119 -0
- package/dist/esm/util/media-playback.js.map +6 -0
- package/dist/esm/util/operational-state.d.ts +102 -0
- package/dist/esm/util/operational-state.d.ts.map +1 -0
- package/dist/esm/util/operational-state.js +212 -0
- package/dist/esm/util/operational-state.js.map +6 -0
- package/dist/esm/util/semantic-tags.d.ts +3 -0
- package/dist/esm/util/semantic-tags.d.ts.map +1 -1
- package/dist/esm/util/semantic-tags.js +5 -1
- package/dist/esm/util/semantic-tags.js.map +1 -1
- package/dist/esm/util/service-area.d.ts +88 -0
- package/dist/esm/util/service-area.d.ts.map +1 -0
- package/dist/esm/util/service-area.js +185 -0
- package/dist/esm/util/service-area.js.map +6 -0
- package/dist/esm/util/shared-styles.d.ts +1 -0
- package/dist/esm/util/shared-styles.d.ts.map +1 -1
- package/dist/esm/util/shared-styles.js +37 -17
- package/dist/esm/util/shared-styles.js.map +1 -1
- package/dist/esm/util/thermostat-schedule.d.ts +10 -4
- package/dist/esm/util/thermostat-schedule.d.ts.map +1 -1
- package/dist/esm/util/thermostat-schedule.js +34 -10
- package/dist/esm/util/thermostat-schedule.js.map +1 -1
- package/dist/esm/util/thermostat-suggestions.d.ts +31 -0
- package/dist/esm/util/thermostat-suggestions.d.ts.map +1 -0
- package/dist/esm/util/thermostat-suggestions.js +74 -0
- package/dist/esm/util/thermostat-suggestions.js.map +6 -0
- package/dist/esm/util/time.d.ts +24 -0
- package/dist/esm/util/time.d.ts.map +1 -0
- package/dist/esm/util/time.js +42 -0
- package/dist/esm/util/time.js.map +6 -0
- package/dist/esm/util/water-heater-management.d.ts +56 -0
- package/dist/esm/util/water-heater-management.d.ts.map +1 -0
- package/dist/esm/util/water-heater-management.js +147 -0
- package/dist/esm/util/water-heater-management.js.map +6 -0
- package/dist/web/index.html +4 -0
- package/dist/web/js/{attribute-write-dialog-Dj2vnLR_.js → attribute-write-dialog-DrJZQaXy.js} +1 -1
- package/dist/web/js/{command-invoke-dialog-DJY2HePu.js → command-invoke-dialog-D_zf390T.js} +1 -1
- package/dist/web/js/{commission-node-dialog-BAzJcdYg.js → commission-node-dialog-DIBv_ihK.js} +5 -5
- package/dist/web/js/{commission-node-existing-DDtYs7R-.js → commission-node-existing-ApIugQzz.js} +1 -1
- package/dist/web/js/{commission-node-thread-Bf0XhUqn.js → commission-node-thread-DdEySLrf.js} +1 -1
- package/dist/web/js/{commission-node-wifi-DL4q7kzh.js → commission-node-wifi-BIhsmTCV.js} +1 -1
- package/dist/web/js/{dialog-box-BquhCceT.js → dialog-box-Df4y4onO.js} +1 -1
- package/dist/web/js/{fabric-label-dialog-iLm9DGea.js → fabric-label-dialog-BFs_iHTp.js} +1 -1
- package/dist/web/js/main.js +61 -28
- package/dist/web/js/{matter-dashboard-app-RcyNZLl_.js → matter-dashboard-app-DfcntGqC.js} +17911 -10233
- package/dist/web/js/{node-acl-add-dialog-CyWYXa6M.js → node-acl-add-dialog-DPG7FkNs.js} +1 -1
- package/dist/web/js/{node-binding-dialog-BjQ0KYzx.js → node-binding-dialog-CvQuClGz.js} +1 -1
- package/dist/web/js/{node-label-dialog-BNUn3Joo.js → node-label-dialog-DNEWL6Ku.js} +1 -1
- package/dist/web/js/{settings-dialog-DvAq6gKo.js → settings-dialog-BvAdX2Jo.js} +1 -1
- package/package.json +7 -7
- package/src/client/models/descriptions.ts +479 -28
- package/src/components/avsum-ptz-strip.ts +10 -9
- package/src/components/semantic-tag-chips.ts +30 -0
- package/src/pages/cluster-commands/AGENTS.md +1 -0
- package/src/pages/cluster-commands/clusters/access-control-commands.ts +3 -2
- package/src/pages/cluster-commands/clusters/avsum-commands.ts +44 -42
- package/src/pages/cluster-commands/clusters/basic-information-commands.ts +2 -1
- package/src/pages/cluster-commands/clusters/closure-control-commands.ts +16 -4
- package/src/pages/cluster-commands/clusters/closure-dimension-commands.ts +512 -0
- package/src/pages/cluster-commands/clusters/commodity-tariff-commands.ts +1 -1
- package/src/pages/cluster-commands/clusters/device-energy-management-commands.ts +426 -0
- package/src/pages/cluster-commands/clusters/device-energy-management-mode-commands.ts +172 -0
- package/src/pages/cluster-commands/clusters/door-lock-commands.ts +2120 -0
- package/src/pages/cluster-commands/clusters/energy-evse-commands.ts +1048 -0
- package/src/pages/cluster-commands/clusters/icd-management-commands.ts +2 -1
- package/src/pages/cluster-commands/clusters/ikea-valve-calibration-commands.ts +129 -0
- package/src/pages/cluster-commands/clusters/media-playback-commands.ts +313 -0
- package/src/pages/cluster-commands/clusters/operational-state-commands.ts +234 -0
- package/src/pages/cluster-commands/clusters/service-area-commands.ts +395 -0
- package/src/pages/cluster-commands/clusters/thermostat-commands.ts +418 -7
- package/src/pages/cluster-commands/clusters/water-heater-management-commands.ts +275 -0
- package/src/pages/cluster-commands/index.ts +10 -0
- package/src/pages/matter-cluster-view.ts +6 -28
- package/src/pages/matter-endpoint-view.ts +24 -2
- package/src/pages/matter-network-view.ts +67 -6
- package/src/pages/matter-node-view.ts +35 -4
- package/src/pages/network/border-router-store.ts +77 -2
- package/src/pages/network/network-details.ts +15 -26
- package/src/pages/network/network-utils.ts +15 -15
- package/src/pages/network/thread-graph.ts +32 -48
- package/src/util/closure-control.ts +5 -0
- package/src/util/closure-dimension.ts +307 -0
- package/src/util/commodity-tariff.ts +9 -23
- package/src/util/device-energy-management-mode.ts +132 -0
- package/src/util/device-energy-management.ts +378 -0
- package/src/util/device-icons.ts +4 -6
- package/src/util/door-lock.ts +1076 -0
- package/src/util/endpoint-label.ts +70 -0
- package/src/util/energy-evse.ts +472 -0
- package/src/util/enum-label.ts +39 -0
- package/src/util/error-text.ts +10 -0
- package/src/util/ikea-valve-calibration.ts +54 -0
- package/src/util/media-playback.ts +132 -0
- package/src/util/operational-state.ts +251 -0
- package/src/util/semantic-tags.ts +6 -0
- package/src/util/service-area.ts +313 -0
- package/src/util/shared-styles.ts +37 -17
- package/src/util/thermostat-schedule.ts +39 -11
- package/src/util/thermostat-suggestions.ts +93 -0
- package/src/util/time.ts +54 -0
- package/src/util/water-heater-management.ts +217 -0
|
@@ -0,0 +1,132 @@
|
|
|
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, tagField, toNumber } from "./attribute-shapes.js";
|
|
9
|
+
|
|
10
|
+
export const MEDIA_PLAYBACK_CLUSTER_ID = 1286; // 0x0506
|
|
11
|
+
|
|
12
|
+
const ATTR_CURRENT_STATE = 0;
|
|
13
|
+
const ATTR_DURATION = 2;
|
|
14
|
+
const ATTR_SAMPLED_POSITION = 3;
|
|
15
|
+
const ATTR_PLAYBACK_SPEED = 4;
|
|
16
|
+
const ATTR_ACCEPTED_COMMAND_LIST = 0xfff9;
|
|
17
|
+
|
|
18
|
+
export const PLAY_COMMAND_ID = 0;
|
|
19
|
+
export const PAUSE_COMMAND_ID = 1;
|
|
20
|
+
export const STOP_COMMAND_ID = 2;
|
|
21
|
+
export const START_OVER_COMMAND_ID = 3;
|
|
22
|
+
export const PREVIOUS_COMMAND_ID = 4;
|
|
23
|
+
export const NEXT_COMMAND_ID = 5;
|
|
24
|
+
export const REWIND_COMMAND_ID = 6;
|
|
25
|
+
export const FAST_FORWARD_COMMAND_ID = 7;
|
|
26
|
+
export const SKIP_FORWARD_COMMAND_ID = 8;
|
|
27
|
+
export const SKIP_BACKWARD_COMMAND_ID = 9;
|
|
28
|
+
|
|
29
|
+
/** PlaybackStateEnum. */
|
|
30
|
+
export enum PlaybackState {
|
|
31
|
+
Playing = 0,
|
|
32
|
+
Paused = 1,
|
|
33
|
+
NotPlaying = 2,
|
|
34
|
+
Buffering = 3,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function readAttr(node: MatterNode, endpoint: number, attrId: number): unknown {
|
|
38
|
+
return node.attributes[`${endpoint}/${MEDIA_PLAYBACK_CLUSTER_ID}/${attrId}`];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function readCurrentState(node: MatterNode, endpoint: number): PlaybackState | null {
|
|
42
|
+
const value = toNumber(readAttr(node, endpoint, ATTR_CURRENT_STATE));
|
|
43
|
+
return value === undefined ? null : value;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function formatPlaybackState(state: PlaybackState | null): string {
|
|
47
|
+
switch (state) {
|
|
48
|
+
case PlaybackState.Playing:
|
|
49
|
+
return "Playing";
|
|
50
|
+
case PlaybackState.Paused:
|
|
51
|
+
return "Paused";
|
|
52
|
+
case PlaybackState.NotPlaying:
|
|
53
|
+
return "Not playing";
|
|
54
|
+
case PlaybackState.Buffering:
|
|
55
|
+
return "Buffering";
|
|
56
|
+
default:
|
|
57
|
+
return "Unknown";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** SampledPosition.Position (field tag 1), in milliseconds. */
|
|
62
|
+
export function readPositionMs(node: MatterNode, endpoint: number): number | null {
|
|
63
|
+
return toNumber(tagField(readAttr(node, endpoint, ATTR_SAMPLED_POSITION), 1)) ?? null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Duration, in milliseconds, or null when the device reports no duration (e.g. a live stream). */
|
|
67
|
+
export function readDurationMs(node: MatterNode, endpoint: number): number | null {
|
|
68
|
+
return toNumber(readAttr(node, endpoint, ATTR_DURATION)) ?? null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* PlaybackSpeed is a float32, so a device reporting 0.1x decodes to 0.10000000149011612; round it to
|
|
73
|
+
* the two decimals the spec's 1/16 speed steps need. A stopped player reports 0, which is not a speed.
|
|
74
|
+
*/
|
|
75
|
+
export function readPlaybackSpeed(node: MatterNode, endpoint: number): number | null {
|
|
76
|
+
const speed = toNumber(readAttr(node, endpoint, ATTR_PLAYBACK_SPEED));
|
|
77
|
+
if (speed === undefined || speed === 0) return null;
|
|
78
|
+
return Math.round(speed * 100) / 100;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** m:ss for anything under an hour, h:mm:ss beyond that. */
|
|
82
|
+
export function formatDurationMs(ms: number): string {
|
|
83
|
+
const totalSeconds = Math.floor(ms / 1000);
|
|
84
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
85
|
+
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
86
|
+
const seconds = totalSeconds % 60;
|
|
87
|
+
const pad = (n: number) => String(n).padStart(2, "0");
|
|
88
|
+
return hours > 0 ? `${hours}:${pad(minutes)}:${pad(seconds)}` : `${minutes}:${pad(seconds)}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function supportsCommand(node: MatterNode, endpoint: number, commandId: number): boolean {
|
|
92
|
+
const accepted = readAttr(node, endpoint, ATTR_ACCEPTED_COMMAND_LIST);
|
|
93
|
+
return Array.isArray(accepted) && accepted.map(value => Number(value)).includes(commandId);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** PlaybackResponse.Status. */
|
|
97
|
+
const PLAYBACK_STATUS_NAMES: Record<number, string> = {
|
|
98
|
+
0: "Success",
|
|
99
|
+
1: "Invalid state for command",
|
|
100
|
+
2: "Not allowed",
|
|
101
|
+
3: "Not active",
|
|
102
|
+
4: "Speed out of range",
|
|
103
|
+
5: "Seek out of range",
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Every transport command answers with PlaybackResponse, and a non-Success status is a successful
|
|
108
|
+
* invoke at the interaction layer — the caller only learns the device refused from the payload.
|
|
109
|
+
* Command responses are name-keyed (convertMatterToWebSocketNameBased), unlike attributes.
|
|
110
|
+
*/
|
|
111
|
+
export async function invokeTransportCommand(
|
|
112
|
+
client: MatterClient,
|
|
113
|
+
nodeId: number | bigint,
|
|
114
|
+
endpoint: number,
|
|
115
|
+
command: string,
|
|
116
|
+
payload: Record<string, unknown> = {},
|
|
117
|
+
): Promise<void> {
|
|
118
|
+
const response = await client.deviceCommand(nodeId, endpoint, MEDIA_PLAYBACK_CLUSTER_ID, command, payload);
|
|
119
|
+
const status = pickNumber(asObject(response) ?? {}, "status");
|
|
120
|
+
if (status !== null && status !== 0) {
|
|
121
|
+
throw new Error(`${command} rejected: ${PLAYBACK_STATUS_NAMES[status] ?? `status ${status}`}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** The delta the skip form would send, or null when the field holds no submittable value. */
|
|
126
|
+
export function parseSkipMs(value: string): number | null {
|
|
127
|
+
const trimmed = value.trim();
|
|
128
|
+
if (trimmed === "") return null;
|
|
129
|
+
const ms = Number(trimmed);
|
|
130
|
+
if (!Number.isSafeInteger(ms) || ms < 1) return null;
|
|
131
|
+
return ms;
|
|
132
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025-2026 Open Home Foundation
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { asObject, pickNumber, tagField, toNumber, toText } from "./attribute-shapes.js";
|
|
8
|
+
import { OPERATIONAL_MANUFACTURER_RANGE, unnamedEnumLabel } from "./enum-label.js";
|
|
9
|
+
|
|
10
|
+
export const OPERATIONAL_STATE_CLUSTER_ID = 0x0060;
|
|
11
|
+
export const RVC_OPERATIONAL_STATE_CLUSTER_ID = 0x0061;
|
|
12
|
+
export const OVEN_CAVITY_OPERATIONAL_STATE_CLUSTER_ID = 0x0048;
|
|
13
|
+
|
|
14
|
+
export const OPERATIONAL_STATE_LIST_ATTR = 3;
|
|
15
|
+
export const OPERATIONAL_STATE_ATTR = 4;
|
|
16
|
+
export const OPERATIONAL_ERROR_ATTR = 5;
|
|
17
|
+
export const ACCEPTED_COMMAND_LIST_ATTR = 0xfff9;
|
|
18
|
+
|
|
19
|
+
const ERROR_STATE_ID_FIELD = 0;
|
|
20
|
+
const ERROR_STATE_LABEL_FIELD = 1;
|
|
21
|
+
const ERROR_STATE_DETAILS_FIELD = 2;
|
|
22
|
+
|
|
23
|
+
const OPERATIONAL_STATE_ID_FIELD = 0;
|
|
24
|
+
const OPERATIONAL_STATE_LABEL_FIELD = 1;
|
|
25
|
+
|
|
26
|
+
export enum OperationalState {
|
|
27
|
+
Stopped = 0,
|
|
28
|
+
Running = 1,
|
|
29
|
+
Paused = 2,
|
|
30
|
+
Error = 3,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export enum RvcOperationalState {
|
|
34
|
+
SeekingCharger = 64,
|
|
35
|
+
Charging = 65,
|
|
36
|
+
Docked = 66,
|
|
37
|
+
EmptyingDustBin = 67,
|
|
38
|
+
CleaningMop = 68,
|
|
39
|
+
FillingWaterTank = 69,
|
|
40
|
+
UpdatingMaps = 70,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export enum ErrorState {
|
|
44
|
+
NoError = 0,
|
|
45
|
+
UnableToStartOrResume = 1,
|
|
46
|
+
UnableToCompleteOperation = 2,
|
|
47
|
+
CommandInvalidInState = 3,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export enum RvcErrorState {
|
|
51
|
+
FailedToFindChargingDock = 64,
|
|
52
|
+
Stuck = 65,
|
|
53
|
+
DustBinMissing = 66,
|
|
54
|
+
DustBinFull = 67,
|
|
55
|
+
WaterTankEmpty = 68,
|
|
56
|
+
WaterTankMissing = 69,
|
|
57
|
+
WaterTankLidOpen = 70,
|
|
58
|
+
MopCleaningPadMissing = 71,
|
|
59
|
+
LowBattery = 72,
|
|
60
|
+
CannotReachTargetArea = 73,
|
|
61
|
+
DirtyWaterTankFull = 74,
|
|
62
|
+
DirtyWaterTankMissing = 75,
|
|
63
|
+
WheelsJammed = 76,
|
|
64
|
+
BrushJammed = 77,
|
|
65
|
+
NavigationSensorObscured = 78,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export enum OperationalCommand {
|
|
69
|
+
Pause = 0,
|
|
70
|
+
Stop = 1,
|
|
71
|
+
Start = 2,
|
|
72
|
+
Resume = 3,
|
|
73
|
+
GoHome = 128,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const BASE_STATE_NAMES: Record<number, string> = {
|
|
77
|
+
[OperationalState.Stopped]: "Stopped",
|
|
78
|
+
[OperationalState.Running]: "Running",
|
|
79
|
+
[OperationalState.Paused]: "Paused",
|
|
80
|
+
[OperationalState.Error]: "Error",
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const BASE_ERROR_NAMES: Record<number, string> = {
|
|
84
|
+
[ErrorState.NoError]: "No Error",
|
|
85
|
+
[ErrorState.UnableToStartOrResume]: "Unable to Start or Resume",
|
|
86
|
+
[ErrorState.UnableToCompleteOperation]: "Unable to Complete Operation",
|
|
87
|
+
[ErrorState.CommandInvalidInState]: "Command Invalid in Current State",
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export interface OperationalCommandInfo {
|
|
91
|
+
name: string;
|
|
92
|
+
label: string;
|
|
93
|
+
id: OperationalCommand;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const PAUSE: OperationalCommandInfo = { name: "Pause", label: "Pause", id: OperationalCommand.Pause };
|
|
97
|
+
const STOP: OperationalCommandInfo = { name: "Stop", label: "Stop", id: OperationalCommand.Stop };
|
|
98
|
+
const START: OperationalCommandInfo = { name: "Start", label: "Start", id: OperationalCommand.Start };
|
|
99
|
+
const RESUME: OperationalCommandInfo = { name: "Resume", label: "Resume", id: OperationalCommand.Resume };
|
|
100
|
+
const GO_HOME: OperationalCommandInfo = { name: "GoHome", label: "Go Home", id: OperationalCommand.GoHome };
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* A cluster derived from OperationalState: the base enums extended by its own states and errors,
|
|
104
|
+
* and the commands its derivation allows.
|
|
105
|
+
*/
|
|
106
|
+
export interface OperationalStateVariant {
|
|
107
|
+
clusterId: number;
|
|
108
|
+
title: string;
|
|
109
|
+
stateNames: Readonly<Record<number, string>>;
|
|
110
|
+
errorNames: Readonly<Record<number, string>>;
|
|
111
|
+
commands: readonly OperationalCommandInfo[];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export const OPERATIONAL_STATE_VARIANTS: Readonly<Partial<Record<number, OperationalStateVariant>>> = {
|
|
115
|
+
[OPERATIONAL_STATE_CLUSTER_ID]: {
|
|
116
|
+
clusterId: OPERATIONAL_STATE_CLUSTER_ID,
|
|
117
|
+
title: "Operational State",
|
|
118
|
+
stateNames: BASE_STATE_NAMES,
|
|
119
|
+
errorNames: BASE_ERROR_NAMES,
|
|
120
|
+
commands: [START, STOP, PAUSE, RESUME],
|
|
121
|
+
},
|
|
122
|
+
[RVC_OPERATIONAL_STATE_CLUSTER_ID]: {
|
|
123
|
+
clusterId: RVC_OPERATIONAL_STATE_CLUSTER_ID,
|
|
124
|
+
title: "RVC Operational State",
|
|
125
|
+
stateNames: {
|
|
126
|
+
...BASE_STATE_NAMES,
|
|
127
|
+
[RvcOperationalState.SeekingCharger]: "Seeking Charger",
|
|
128
|
+
[RvcOperationalState.Charging]: "Charging",
|
|
129
|
+
[RvcOperationalState.Docked]: "Docked",
|
|
130
|
+
[RvcOperationalState.EmptyingDustBin]: "Emptying Dust Bin",
|
|
131
|
+
[RvcOperationalState.CleaningMop]: "Cleaning Mop",
|
|
132
|
+
[RvcOperationalState.FillingWaterTank]: "Filling Water Tank",
|
|
133
|
+
[RvcOperationalState.UpdatingMaps]: "Updating Maps",
|
|
134
|
+
},
|
|
135
|
+
errorNames: {
|
|
136
|
+
...BASE_ERROR_NAMES,
|
|
137
|
+
[RvcErrorState.FailedToFindChargingDock]: "Failed to Find Charging Dock",
|
|
138
|
+
[RvcErrorState.Stuck]: "Stuck",
|
|
139
|
+
[RvcErrorState.DustBinMissing]: "Dust Bin Missing",
|
|
140
|
+
[RvcErrorState.DustBinFull]: "Dust Bin Full",
|
|
141
|
+
[RvcErrorState.WaterTankEmpty]: "Water Tank Empty",
|
|
142
|
+
[RvcErrorState.WaterTankMissing]: "Water Tank Missing",
|
|
143
|
+
[RvcErrorState.WaterTankLidOpen]: "Water Tank Lid Open",
|
|
144
|
+
[RvcErrorState.MopCleaningPadMissing]: "Mop Cleaning Pad Missing",
|
|
145
|
+
[RvcErrorState.LowBattery]: "Low Battery",
|
|
146
|
+
[RvcErrorState.CannotReachTargetArea]: "Cannot Reach Target Area",
|
|
147
|
+
[RvcErrorState.DirtyWaterTankFull]: "Dirty Water Tank Full",
|
|
148
|
+
[RvcErrorState.DirtyWaterTankMissing]: "Dirty Water Tank Missing",
|
|
149
|
+
[RvcErrorState.WheelsJammed]: "Wheels Jammed",
|
|
150
|
+
[RvcErrorState.BrushJammed]: "Brush Jammed",
|
|
151
|
+
[RvcErrorState.NavigationSensorObscured]: "Navigation Sensor Obscured",
|
|
152
|
+
},
|
|
153
|
+
commands: [PAUSE, RESUME, GO_HOME],
|
|
154
|
+
},
|
|
155
|
+
[OVEN_CAVITY_OPERATIONAL_STATE_CLUSTER_ID]: {
|
|
156
|
+
clusterId: OVEN_CAVITY_OPERATIONAL_STATE_CLUSTER_ID,
|
|
157
|
+
title: "Oven Cavity Operational State",
|
|
158
|
+
stateNames: BASE_STATE_NAMES,
|
|
159
|
+
errorNames: BASE_ERROR_NAMES,
|
|
160
|
+
commands: [START, STOP],
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Ids the variant does not name (manufacturer-specific 128-191, or a newer spec value) fall back to the
|
|
166
|
+
* label the device supplies with the id.
|
|
167
|
+
*/
|
|
168
|
+
export function operationalStateLabel(variant: OperationalStateVariant, id: number, deviceLabel?: string): string {
|
|
169
|
+
return variant.stateNames[id] ?? deviceLabel ?? unnamedEnumLabel(id, OPERATIONAL_MANUFACTURER_RANGE);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function errorStateLabel(variant: OperationalStateVariant, id: number, deviceLabel?: string): string {
|
|
173
|
+
return variant.errorNames[id] ?? deviceLabel ?? unnamedEnumLabel(id, OPERATIONAL_MANUFACTURER_RANGE);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Decoded ErrorStateStruct, used for both the attribute and command responses. */
|
|
177
|
+
export interface ErrorStateInfo {
|
|
178
|
+
errorStateId: number;
|
|
179
|
+
/** NoError (0) is a healthy status, not a fault, so callers must not style it as an error. */
|
|
180
|
+
isError: boolean;
|
|
181
|
+
label: string;
|
|
182
|
+
details?: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Label of a manufacturer-specific state from OperationalStateList, delivered field-tag keyed. */
|
|
186
|
+
function operationalStateLabelFromList(stateList: unknown, id: number): string | undefined {
|
|
187
|
+
if (!Array.isArray(stateList)) return undefined;
|
|
188
|
+
for (const entry of stateList) {
|
|
189
|
+
const obj = asObject(entry);
|
|
190
|
+
if (obj !== null && toNumber(tagField(obj, OPERATIONAL_STATE_ID_FIELD)) === id) {
|
|
191
|
+
return toText(tagField(obj, OPERATIONAL_STATE_LABEL_FIELD));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** The OperationalState attribute as a label, or null when it is absent or not a number. */
|
|
198
|
+
export function describeOperationalState(
|
|
199
|
+
variant: OperationalStateVariant,
|
|
200
|
+
value: unknown,
|
|
201
|
+
stateList?: unknown,
|
|
202
|
+
): string | null {
|
|
203
|
+
const id = toNumber(value);
|
|
204
|
+
if (id === undefined) return null;
|
|
205
|
+
return operationalStateLabel(variant, id, operationalStateLabelFromList(stateList, id));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** OperationalError attribute: an ErrorStateStruct, delivered field-tag keyed. */
|
|
209
|
+
export function decodeOperationalError(variant: OperationalStateVariant, value: unknown): ErrorStateInfo | null {
|
|
210
|
+
const obj = asObject(value);
|
|
211
|
+
if (obj === null) return null;
|
|
212
|
+
const id = toNumber(tagField(obj, ERROR_STATE_ID_FIELD));
|
|
213
|
+
if (id === undefined) return null;
|
|
214
|
+
return {
|
|
215
|
+
errorStateId: id,
|
|
216
|
+
isError: id !== ErrorState.NoError,
|
|
217
|
+
label: errorStateLabel(variant, id, toText(tagField(obj, ERROR_STATE_LABEL_FIELD))),
|
|
218
|
+
details: toText(tagField(obj, ERROR_STATE_DETAILS_FIELD)),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* OperationalCommandResponse carries a commandResponseState (ErrorStateStruct) whose errorStateId
|
|
224
|
+
* reports rejection even when the invoke itself succeeds, so a successful transport does not mean the
|
|
225
|
+
* device accepted the command. Unlike the attribute, the response reaches the client name keyed, with
|
|
226
|
+
* the wire spelling `errorStateID` (legacy `errorStateId` as fallback).
|
|
227
|
+
*/
|
|
228
|
+
export function decodeOperationalCommandResponse(variant: OperationalStateVariant, response: unknown): ErrorStateInfo {
|
|
229
|
+
const state = asObject(asObject(response)?.["commandResponseState"]);
|
|
230
|
+
const id = state === null ? null : pickNumber(state, "errorStateID", "errorStateId");
|
|
231
|
+
if (state === null || id === null) {
|
|
232
|
+
throw new Error("The device answer carries no command response state");
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
errorStateId: id,
|
|
236
|
+
isError: id !== ErrorState.NoError,
|
|
237
|
+
label: errorStateLabel(variant, id, toText(state["errorStateLabel"])),
|
|
238
|
+
details: toText(state["errorStateDetails"]),
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** The accepted command ids, or undefined while AcceptedCommandList has not been reported. */
|
|
243
|
+
export function decodeAcceptedCommands(value: unknown): ReadonlySet<number> | undefined {
|
|
244
|
+
if (!Array.isArray(value)) return undefined;
|
|
245
|
+
const ids = new Set<number>();
|
|
246
|
+
for (const entry of value) {
|
|
247
|
+
const id = toNumber(entry);
|
|
248
|
+
if (id !== undefined) ids.add(id);
|
|
249
|
+
}
|
|
250
|
+
return ids;
|
|
251
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import type { MatterNode } from "@matter-server/ws-client";
|
|
7
8
|
import { toBigIntAwareJson } from "@matter-server/ws-client";
|
|
8
9
|
import { semantic_tag_namespaces } from "../client/models/descriptions.js";
|
|
9
10
|
import { attributeArray } from "./access-control.js";
|
|
@@ -54,6 +55,11 @@ export function decodeSemanticTagList(value: unknown): SemanticTagListEntry[] |
|
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
/** Decoded semantic tags (Descriptor TagList) for one endpoint; empty when it reports none. */
|
|
59
|
+
export function getEndpointSemanticTags(node: MatterNode, endpoint: number): SemanticTagListEntry[] {
|
|
60
|
+
return decodeSemanticTagList(node.attributes[`${endpoint}/${DESCRIPTOR_CLUSTER_ID}/${TAG_LIST_ATTR}`]) ?? [];
|
|
61
|
+
}
|
|
62
|
+
|
|
57
63
|
const RAW_ENTRY_TEXT_MAX = 60;
|
|
58
64
|
|
|
59
65
|
export function describeSemanticTagListEntry(entry: SemanticTagListEntry): {
|