@matter-server/dashboard 1.2.8 → 1.3.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.
Files changed (62) hide show
  1. package/dist/esm/components/webrtc-stream-view.d.ts +13 -0
  2. package/dist/esm/components/webrtc-stream-view.d.ts.map +1 -1
  3. package/dist/esm/components/webrtc-stream-view.js +51 -11
  4. package/dist/esm/components/webrtc-stream-view.js.map +1 -1
  5. package/dist/esm/pages/camera-overlay.d.ts.map +1 -1
  6. package/dist/esm/pages/camera-overlay.js +3 -11
  7. package/dist/esm/pages/camera-overlay.js.map +1 -1
  8. package/dist/esm/pages/cluster-commands/clusters/closure-control-commands.d.ts +35 -0
  9. package/dist/esm/pages/cluster-commands/clusters/closure-control-commands.d.ts.map +1 -0
  10. package/dist/esm/pages/cluster-commands/clusters/closure-control-commands.js +352 -0
  11. package/dist/esm/pages/cluster-commands/clusters/closure-control-commands.js.map +6 -0
  12. package/dist/esm/pages/cluster-commands/index.d.ts +1 -0
  13. package/dist/esm/pages/cluster-commands/index.d.ts.map +1 -1
  14. package/dist/esm/pages/cluster-commands/index.js +1 -0
  15. package/dist/esm/pages/cluster-commands/index.js.map +1 -1
  16. package/dist/esm/pages/components/node-details.d.ts.map +1 -1
  17. package/dist/esm/pages/components/node-details.js +4 -5
  18. package/dist/esm/pages/components/node-details.js.map +1 -1
  19. package/dist/esm/pages/matter-node-view.d.ts.map +1 -1
  20. package/dist/esm/pages/matter-node-view.js +10 -6
  21. package/dist/esm/pages/matter-node-view.js.map +1 -1
  22. package/dist/esm/util/camera.d.ts +15 -0
  23. package/dist/esm/util/camera.d.ts.map +1 -0
  24. package/dist/esm/util/camera.js +42 -0
  25. package/dist/esm/util/camera.js.map +6 -0
  26. package/dist/esm/util/closure-control.d.ts +57 -0
  27. package/dist/esm/util/closure-control.d.ts.map +1 -0
  28. package/dist/esm/util/closure-control.js +148 -0
  29. package/dist/esm/util/closure-control.js.map +6 -0
  30. package/dist/esm/util/device-icons.d.ts +0 -2
  31. package/dist/esm/util/device-icons.d.ts.map +1 -1
  32. package/dist/esm/util/device-icons.js +0 -6
  33. package/dist/esm/util/device-icons.js.map +1 -1
  34. package/dist/esm/util/endpoints.d.ts +11 -0
  35. package/dist/esm/util/endpoints.d.ts.map +1 -1
  36. package/dist/esm/util/endpoints.js +33 -1
  37. package/dist/esm/util/endpoints.js.map +1 -1
  38. package/dist/web/js/{attribute-write-dialog-CB7oucjt.js → attribute-write-dialog-Bdg5QUXX.js} +1 -1
  39. package/dist/web/js/{command-invoke-dialog-C9rdQjTo.js → command-invoke-dialog-BXBss5sm.js} +1 -1
  40. package/dist/web/js/{commission-node-dialog-BwkiZy8i.js → commission-node-dialog-JvFwNpuW.js} +5 -5
  41. package/dist/web/js/{commission-node-existing-BWTlMlwi.js → commission-node-existing-DaHKu2E3.js} +1 -1
  42. package/dist/web/js/{commission-node-thread-WDo3_tCy.js → commission-node-thread-U9sFT51X.js} +1 -1
  43. package/dist/web/js/{commission-node-wifi-Drj7Z0rY.js → commission-node-wifi-BkNcTxuy.js} +1 -1
  44. package/dist/web/js/{dialog-box-Dq6fTPQH.js → dialog-box-Cn3JA0xi.js} +1 -1
  45. package/dist/web/js/{fabric-label-dialog-FE4tGieS.js → fabric-label-dialog-BLzecxP3.js} +1 -1
  46. package/dist/web/js/main.js +1 -1
  47. package/dist/web/js/{matter-dashboard-app-Ditf9BYC.js → matter-dashboard-app-KaEKzt4L.js} +1082 -566
  48. package/dist/web/js/{node-acl-add-dialog-BA3u0qYj.js → node-acl-add-dialog-B5G0k15F.js} +1 -1
  49. package/dist/web/js/{node-binding-dialog-BV_fMc0a.js → node-binding-dialog-fPE92bGT.js} +1 -1
  50. package/dist/web/js/{node-label-dialog-DG5CqG1e.js → node-label-dialog-B9pZzv7_.js} +1 -1
  51. package/dist/web/js/{settings-dialog-VafGbl7R.js → settings-dialog-CmhSbsTn.js} +1 -1
  52. package/package.json +4 -4
  53. package/src/components/webrtc-stream-view.ts +67 -12
  54. package/src/pages/camera-overlay.ts +3 -15
  55. package/src/pages/cluster-commands/clusters/closure-control-commands.ts +393 -0
  56. package/src/pages/cluster-commands/index.ts +1 -0
  57. package/src/pages/components/node-details.ts +4 -6
  58. package/src/pages/matter-node-view.ts +10 -6
  59. package/src/util/camera.ts +55 -0
  60. package/src/util/closure-control.ts +193 -0
  61. package/src/util/device-icons.ts +0 -7
  62. package/src/util/endpoints.ts +50 -0
@@ -1,4 +1,4 @@
1
- import { i, c, a as clientContext, n, r, b as i$1, P as Privilege, v as nodeIdKey, x as aclCapacity, s as showAlertDialog, y as targetServerClusters, z as clusters, B as AuthMode, C as addAclEntry, E as PRIVILEGE_NAMES, d as b, F as mdiClose, G as getDeviceName, h as handleAsync, g as t } from './matter-dashboard-app-Ditf9BYC.js';
1
+ import { i, c, a as clientContext, n, r, b as i$1, P as Privilege, v as nodeIdKey, x as aclCapacity, s as showAlertDialog, y as targetServerClusters, z as clusters, B as AuthMode, C as addAclEntry, E as PRIVILEGE_NAMES, d as b, F as mdiClose, G as getDeviceName, h as handleAsync, g as t } from './matter-dashboard-app-KaEKzt4L.js';
2
2
  import { p as preventDefault } from './prevent_default-D-ohDGsN.js';
3
3
  import './main.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { i, c, a as clientContext, n, r, b as i$1, v as nodeIdKey, z as clusters, s as showAlertDialog, H as targetAclCapacityForBinding, I as addBinding, J as bindableClusters, A, d as b, G as getDeviceName, K as getEndpointDeviceTypes, h as handleAsync, g as t } from './matter-dashboard-app-Ditf9BYC.js';
1
+ import { i, c, a as clientContext, n, r, b as i$1, v as nodeIdKey, z as clusters, s as showAlertDialog, H as targetAclCapacityForBinding, I as addBinding, J as bindableClusters, A, d as b, G as getDeviceName, K as getEndpointDeviceTypes, h as handleAsync, g as t } from './matter-dashboard-app-KaEKzt4L.js';
2
2
  import { p as preventDefault } from './prevent_default-D-ohDGsN.js';
3
3
  import './main.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { r, n, g as t, b as i, M as MAX_NODE_LABEL_LENGTH, d as b, w as writeNodeLabel, s as showAlertDialog } from './matter-dashboard-app-Ditf9BYC.js';
1
+ import { r, n, g as t, b as i, M as MAX_NODE_LABEL_LENGTH, d as b, w as writeNodeLabel, s as showAlertDialog } from './matter-dashboard-app-KaEKzt4L.js';
2
2
  import { p as preventDefault } from './prevent_default-D-ohDGsN.js';
3
3
  import './main.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { i, c, a as clientContext, t as tickContext, r, e, b as i$1, f as fireAndForget, s as showAlertDialog, d as b, A, h as handleAsync, g as t, n, D as DevModeService, m as mdiWifi, j as mdiPlus, k as mdiPencil, l as mdiDelete, o as mdiEyeOff, p as mdiEye, q as mdiAccessPoint } from './matter-dashboard-app-Ditf9BYC.js';
1
+ import { i, c, a as clientContext, t as tickContext, r, e, b as i$1, f as fireAndForget, s as showAlertDialog, d as b, A, h as handleAsync, g as t, n, D as DevModeService, m as mdiWifi, j as mdiPlus, k as mdiPencil, l as mdiDelete, o as mdiEyeOff, p as mdiEye, q as mdiAccessPoint } from './matter-dashboard-app-KaEKzt4L.js';
2
2
  import { p as preventDefault } from './prevent_default-D-ohDGsN.js';
3
3
  import './main.js';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matter-server/dashboard",
3
- "version": "1.2.8",
3
+ "version": "1.3.0",
4
4
  "description": "Dashboard for OHF Matter Server",
5
5
  "homepage": "https://github.com/matter-js/matterjs-server",
6
6
  "bugs": {
@@ -34,8 +34,8 @@
34
34
  "dependencies": {
35
35
  "@lit/context": "^1.1.6",
36
36
  "@material/web": "^2.4.1",
37
- "@matter-server/custom-clusters": "1.2.8",
38
- "@matter-server/ws-client": "1.2.8",
37
+ "@matter-server/custom-clusters": "1.3.0",
38
+ "@matter-server/ws-client": "1.3.0",
39
39
  "@mdi/js": "^7.4.47",
40
40
  "lit": "^3.3.3",
41
41
  "qrcode-generator": "^2.0.4",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@babel/preset-env": "^8.0.2",
47
- "@matter/main": "0.17.7-alpha.0-20260720-00d9d6fbf",
47
+ "@matter/main": "0.17.7-alpha.0-20260722-ee3cc63a3",
48
48
  "@rollup/plugin-babel": "^7.1.0",
49
49
  "@rollup/plugin-commonjs": "^29.0.3",
50
50
  "@rollup/plugin-json": "^6.1.0",
@@ -201,6 +201,11 @@ export class WebRtcStreamView extends LitElement {
201
201
 
202
202
  private _snapshotStreamId: number | null = null;
203
203
  private _snapshotResolution: { width: number; height: number } | null = null;
204
+ private _snapshotImageCodec: number | null = null;
205
+ private _snapshotMaxFrameRate: number | null = null;
206
+ private _snapshotWatermarkEnabled: boolean | undefined = undefined;
207
+ private _snapshotOsdEnabled: boolean | undefined = undefined;
208
+ private _snapshotChain: Promise<unknown> = Promise.resolve();
204
209
  /** True when we allocated this stream ourselves and must Deallocate it on stop. False when reusing an existing allocation. */
205
210
  private _videoStreamOwned = false;
206
211
  private _audioStreamOwned = false;
@@ -416,7 +421,7 @@ export class WebRtcStreamView extends LitElement {
416
421
  console.info(
417
422
  "[webrtc-stream-view] VideoStreamAllocate ResourceExhausted; freeing snapshot stream and retrying",
418
423
  );
419
- await this.deallocateSnapshot();
424
+ await this._runSerialized(() => this.deallocateSnapshot());
420
425
  videoAlloc = await this.client.deviceCommand(
421
426
  this.nodeId,
422
427
  this.endpointId,
@@ -584,7 +589,7 @@ export class WebRtcStreamView extends LitElement {
584
589
  this._videoStreamOwned = false;
585
590
  this._audioStreamOwned = false;
586
591
 
587
- await this.deallocateSnapshot();
592
+ await this._runSerialized(() => this.deallocateSnapshot());
588
593
 
589
594
  const video = this._video;
590
595
  if (video && video.srcObject) {
@@ -614,7 +619,26 @@ export class WebRtcStreamView extends LitElement {
614
619
  this._stopping = false;
615
620
  }
616
621
 
622
+ /**
623
+ * Runs a snapshot-stream lifecycle op (capture, or a deallocate triggered by the video path /
624
+ * teardown) after any in-flight one settles. Keeps re-negotiation and cross-path deallocation
625
+ * from tearing down a stream a concurrent capture is using, and first-time captures from each
626
+ * allocating (leak).
627
+ */
628
+ private _runSerialized<T>(op: () => Promise<T>): Promise<T> {
629
+ const run = this._snapshotChain.then(op, op);
630
+ this._snapshotChain = run.then(
631
+ () => undefined,
632
+ () => undefined,
633
+ );
634
+ return run;
635
+ }
636
+
617
637
  async takeSnapshot(): Promise<{ dataUri: string; resolution: { width: number; height: number } }> {
638
+ return this._runSerialized(() => this._takeSnapshot());
639
+ }
640
+
641
+ private async _takeSnapshot(): Promise<{ dataUri: string; resolution: { width: number; height: number } }> {
618
642
  if (!this.client) throw new Error("Matter client not available");
619
643
  const streamId = await this._ensureSnapshotStream();
620
644
  const requestedResolution = this._snapshotResolution ?? SNAPSHOT_DEFAULTS.resolution;
@@ -682,6 +706,10 @@ export class WebRtcStreamView extends LitElement {
682
706
  const wasOwned = this._snapshotStreamOwned;
683
707
  this._snapshotStreamId = null;
684
708
  this._snapshotResolution = null;
709
+ this._snapshotImageCodec = null;
710
+ this._snapshotMaxFrameRate = null;
711
+ this._snapshotWatermarkEnabled = undefined;
712
+ this._snapshotOsdEnabled = undefined;
685
713
  this._snapshotStreamOwned = false;
686
714
  if (!wasOwned) return; // Reused an existing allocation — leave it for its owner.
687
715
  try {
@@ -791,7 +819,7 @@ export class WebRtcStreamView extends LitElement {
791
819
  resolution: { width: number; height: number };
792
820
  watermarkEnabled?: boolean;
793
821
  osdEnabled?: boolean;
794
- }): { id: number; resolution: { width: number; height: number } } | null {
822
+ }): number | null {
795
823
  const node = this.client?.nodes[String(this.nodeId)];
796
824
  const list = node?.attributes[`${this.endpointId}/${CAMERA_AV_STREAM_MANAGEMENT_CLUSTER_ID}/17`];
797
825
  if (!Array.isArray(list)) return null;
@@ -818,14 +846,12 @@ export class WebRtcStreamView extends LitElement {
818
846
  if (v !== want.osdEnabled) continue;
819
847
  }
820
848
  const id = pickNumber(obj, "snapshotStreamId", "0");
821
- const resolution = { width: eMaxW, height: eMaxH };
822
- if (id !== null) return { id, resolution };
849
+ if (id !== null) return id;
823
850
  }
824
851
  return null;
825
852
  }
826
853
 
827
854
  private async _ensureSnapshotStream(): Promise<number> {
828
- if (this._snapshotStreamId !== null) return this._snapshotStreamId;
829
855
  if (!this.client) throw new Error("Matter client not available");
830
856
 
831
857
  const node = this.client.nodes[String(this.nodeId)];
@@ -847,21 +873,46 @@ export class WebRtcStreamView extends LitElement {
847
873
  const targetResolution = clampToCapability(this.snapshotResolution ?? cap.resolution, cap.resolution);
848
874
 
849
875
  const avsmFeatures = this._readAvsmFeatures();
876
+ const wantWatermark = avsmFeatures.wmark ? this.watermarkEnabled : undefined;
877
+ const wantOsd = avsmFeatures.osd ? this.osdEnabled : undefined;
878
+
879
+ // A cached stream only still covers the current call if its resolution, codec, frame rate,
880
+ // and watermark/OSD flags all still match: the caller may have changed `snapshotResolution`
881
+ // or toggled watermark/OSD, or the encoder may have freed up (which reselects the capability,
882
+ // changing maxFrameRate), since it was ensured. Otherwise release it before searching for
883
+ // (or allocating) one that actually covers the new target.
884
+ if (this._snapshotStreamId !== null) {
885
+ if (
886
+ this._snapshotResolution?.width === targetResolution.width &&
887
+ this._snapshotResolution?.height === targetResolution.height &&
888
+ this._snapshotImageCodec === cap.imageCodec &&
889
+ this._snapshotMaxFrameRate === cap.maxFrameRate &&
890
+ this._snapshotWatermarkEnabled === wantWatermark &&
891
+ this._snapshotOsdEnabled === wantOsd
892
+ ) {
893
+ return this._snapshotStreamId;
894
+ }
895
+ await this.deallocateSnapshot();
896
+ }
850
897
 
851
898
  // AllocatedSnapshotStreams (attr 0x0011) — reuse existing stream when its capability
852
899
  // range covers our target resolution (spec §11.2.1.2.1 / §11.2.8.8.8).
853
900
  const reused = this._findMatchingSnapshotStream({
854
901
  imageCodec: cap.imageCodec,
855
902
  resolution: targetResolution,
856
- watermarkEnabled: avsmFeatures.wmark ? this.watermarkEnabled : undefined,
857
- osdEnabled: avsmFeatures.osd ? this.osdEnabled : undefined,
903
+ watermarkEnabled: wantWatermark,
904
+ osdEnabled: wantOsd,
858
905
  });
859
906
  if (reused !== null) {
860
- console.info("[webrtc-stream-view] reusing existing snapshot stream", reused.id);
861
- this._snapshotStreamId = reused.id;
862
- this._snapshotResolution = reused.resolution;
907
+ console.info("[webrtc-stream-view] reusing existing snapshot stream", reused);
908
+ this._snapshotStreamId = reused;
909
+ this._snapshotResolution = targetResolution;
910
+ this._snapshotImageCodec = cap.imageCodec;
911
+ this._snapshotMaxFrameRate = cap.maxFrameRate;
912
+ this._snapshotWatermarkEnabled = wantWatermark;
913
+ this._snapshotOsdEnabled = wantOsd;
863
914
  this._snapshotStreamOwned = false;
864
- return reused.id;
915
+ return reused;
865
916
  }
866
917
 
867
918
  const snapshotAllocPayload: Record<string, unknown> = {
@@ -886,6 +937,10 @@ export class WebRtcStreamView extends LitElement {
886
937
  }
887
938
  this._snapshotStreamId = snapshotStreamId;
888
939
  this._snapshotResolution = targetResolution;
940
+ this._snapshotImageCodec = cap.imageCodec;
941
+ this._snapshotMaxFrameRate = cap.maxFrameRate;
942
+ this._snapshotWatermarkEnabled = wantWatermark;
943
+ this._snapshotOsdEnabled = wantOsd;
889
944
  this._snapshotStreamOwned = true;
890
945
  return this._snapshotStreamId;
891
946
  }
@@ -28,8 +28,7 @@ import "../components/webrtc-stream-view.js";
28
28
  import type { WebRtcStreamView } from "../components/webrtc-stream-view.js";
29
29
  import { asObject, pickNumber } from "../util/attribute-shapes.js";
30
30
  import { hasAvsumOnEndpoint } from "../util/avsum.js";
31
- import { LIVE_VIEW_DEVICE_TYPE_IDS } from "../util/device-icons.js";
32
- import { getEndpointDeviceTypes } from "../util/endpoints.js";
31
+ import { supportsLiveView, supportsSnapshot } from "../util/camera.js";
33
32
 
34
33
  type StreamState = "idle" | "connecting" | "streaming" | "error";
35
34
 
@@ -77,23 +76,12 @@ export class CameraOverlay extends LitElement {
77
76
 
78
77
  private get _liveViewSupported(): boolean {
79
78
  const node = this.client?.nodes[String(this.nodeId)];
80
- if (!node) return false;
81
- const deviceTypeIds = getEndpointDeviceTypes(node, this.endpointId).map(d => d.id);
82
- return LIVE_VIEW_DEVICE_TYPE_IDS.some(id => deviceTypeIds.includes(id));
79
+ return node ? supportsLiveView(node, this.endpointId) : false;
83
80
  }
84
81
 
85
82
  private get _snapshotSupported(): boolean {
86
83
  const node = this.client?.nodes[String(this.nodeId)];
87
- // CaptureSnapshot (cmd 12) must appear in AcceptedCommandList (attr 0xfff9 = 65529).
88
- const accepted = node?.attributes[`${this.endpointId}/1361/65529`];
89
- if (!Array.isArray(accepted) || !accepted.includes(12)) return false;
90
- // FeatureMap (attr 0xfffc = 65532) bit 2 (SNP) advertises snapshot support — some cameras
91
- // set the bit but leave SnapshotCapabilities empty, so the feature bit is the authoritative
92
- // signal and SnapshotCapabilities a hint we fall back from.
93
- const featureMap = node?.attributes[`${this.endpointId}/1361/65532`];
94
- if (typeof featureMap === "number" && (featureMap & 0x04) !== 0) return true;
95
- const caps = node?.attributes[`${this.endpointId}/1361/10`];
96
- return Array.isArray(caps) && caps.length > 0;
84
+ return node ? supportsSnapshot(node, this.endpointId) : false;
97
85
  }
98
86
 
99
87
  private _streamViewRef = createRef<WebRtcStreamView>();
@@ -0,0 +1,393 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025-2026 Open Home Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import "@material/web/button/filled-button";
8
+ import "@material/web/button/outlined-button";
9
+ import "@material/web/select/outlined-select";
10
+ import "@material/web/select/select-option";
11
+ import { mdiAlertCircle, mdiCogRefresh, mdiStop } from "@mdi/js";
12
+ import { css, html, nothing } from "lit";
13
+ import { customElement, state } from "lit/decorators.js";
14
+ import "../../../components/ha-svg-icon.js";
15
+ import { handleAsync } from "../../../util/async-handler.js";
16
+ import {
17
+ CLOSURE_CONTROL_CLUSTER_ID,
18
+ CLOSURE_ERROR_LABELS,
19
+ CURRENT_POSITION_LABELS,
20
+ type ClosureCurrentState,
21
+ type ClosureFeatures,
22
+ type ClosureState,
23
+ MAIN_STATE_LABELS,
24
+ SPEED_LABELS,
25
+ TARGET_POSITION_LABELS,
26
+ calibrate,
27
+ moveTo,
28
+ readCountdownTime,
29
+ readCurrentErrorList,
30
+ readFeatures,
31
+ readLatchControlModes,
32
+ readMainState,
33
+ readOverallCurrentState,
34
+ readOverallTargetState,
35
+ stop,
36
+ } from "../../../util/closure-control.js";
37
+ import { BaseClusterCommands } from "../base-cluster-commands.js";
38
+ import { registerClusterCommands } from "../registry.js";
39
+
40
+ const MAIN_STATE_ERROR = 3;
41
+
42
+ @customElement("closure-control-cluster-commands")
43
+ class ClosureControlClusterCommands extends BaseClusterCommands {
44
+ @state() private _moveToPosition = "";
45
+ // "" = unchanged, "true" = latch, "false" = unlatch — kept as a select (not a plain switch) so an
46
+ // untouched control never implies an explicit latch/unlatch command in the MoveTo payload.
47
+ @state() private _moveToLatch = "";
48
+ @state() private _moveToSpeed = "";
49
+ private _unsubscribeNodes?: () => void;
50
+ private _moveToContext?: string;
51
+
52
+ override willUpdate(changedProperties: Map<string, unknown>) {
53
+ super.willUpdate(changedProperties);
54
+ if (!this.node) return;
55
+ const context = `${String(this.node.node_id)}/${this.endpoint}/${this.cluster}`;
56
+ if (this._moveToContext !== undefined && this._moveToContext !== context) {
57
+ this._moveToPosition = "";
58
+ this._moveToLatch = "";
59
+ this._moveToSpeed = "";
60
+ }
61
+ this._moveToContext = context;
62
+ }
63
+
64
+ override updated(changedProperties: Map<string, unknown>) {
65
+ super.updated(changedProperties);
66
+ if (changedProperties.has("client") && this.client && !this._unsubscribeNodes) {
67
+ this._unsubscribeNodes = this.client.addEventListener("nodes_changed", () => {
68
+ this.requestUpdate();
69
+ });
70
+ }
71
+ }
72
+
73
+ override disconnectedCallback() {
74
+ super.disconnectedCallback();
75
+ this._unsubscribeNodes?.();
76
+ this._unsubscribeNodes = undefined;
77
+ }
78
+
79
+ override render() {
80
+ if (!this.node || this.cluster !== CLOSURE_CONTROL_CLUSTER_ID) return nothing;
81
+ const features = readFeatures(this.node, this.endpoint);
82
+ const mainState = readMainState(this.node, this.endpoint);
83
+ const errors = readCurrentErrorList(this.node, this.endpoint);
84
+ const countdownTime = readCountdownTime(this.node, this.endpoint);
85
+ const current = readOverallCurrentState(this.node, this.endpoint);
86
+ const target = readOverallTargetState(this.node, this.endpoint);
87
+ const latchControlModes = readLatchControlModes(this.node, this.endpoint);
88
+
89
+ return html`
90
+ <details class="command-panel" open>
91
+ <summary>Closure Control</summary>
92
+ <div class="command-content">
93
+ <div class="top-row">
94
+ <span class="state-badge ${mainState === MAIN_STATE_ERROR ? "error" : ""}">
95
+ ${mainState !== null
96
+ ? (MAIN_STATE_LABELS[mainState] ?? `Unknown (${mainState})`)
97
+ : "Unknown"}
98
+ </span>
99
+ ${countdownTime !== null
100
+ ? html`<span class="muted">~${countdownTime}s remaining</span>`
101
+ : nothing}
102
+ </div>
103
+
104
+ ${errors.length > 0
105
+ ? html`
106
+ <div class="errors">
107
+ ${errors.map(
108
+ e => html`
109
+ <span class="error-chip">
110
+ <ha-svg-icon .path=${mdiAlertCircle}></ha-svg-icon>
111
+ ${CLOSURE_ERROR_LABELS[e] ?? `Error ${e}`}
112
+ </span>
113
+ `,
114
+ )}
115
+ </div>
116
+ `
117
+ : nothing}
118
+
119
+ <div class="states-grid">
120
+ <div class="state-block">
121
+ <div class="state-block-header">Current</div>
122
+ ${this._renderState(current, features)}
123
+ </div>
124
+ <div class="state-block">
125
+ <div class="state-block-header">Target</div>
126
+ ${this._renderState(target, features)}
127
+ </div>
128
+ </div>
129
+
130
+ <div class="actions">
131
+ ${!features.instantaneous
132
+ ? html`<md-outlined-button @click=${handleAsync(() => this._handleStop())}>
133
+ <ha-svg-icon slot="icon" .path=${mdiStop}></ha-svg-icon>
134
+ Stop
135
+ </md-outlined-button>`
136
+ : nothing}
137
+ ${features.calibration
138
+ ? html`<md-outlined-button @click=${handleAsync(() => this._handleCalibrate())}>
139
+ <ha-svg-icon slot="icon" .path=${mdiCogRefresh}></ha-svg-icon>
140
+ Calibrate
141
+ </md-outlined-button>`
142
+ : nothing}
143
+ </div>
144
+
145
+ <div class="move-to">
146
+ <div class="move-to-header">Move to</div>
147
+ <div class="move-to-controls">
148
+ ${features.positioning
149
+ ? html`
150
+ <md-outlined-select
151
+ label="Position"
152
+ .value=${this._moveToPosition}
153
+ @change=${(e: Event) => {
154
+ this._moveToPosition = (e.target as HTMLSelectElement).value;
155
+ }}
156
+ >
157
+ <md-select-option value="">
158
+ <div slot="headline">(unchanged)</div>
159
+ </md-select-option>
160
+ ${Object.entries(TARGET_POSITION_LABELS)
161
+ .filter(
162
+ ([id]) =>
163
+ (id !== "2" || features.pedestrian) &&
164
+ (id !== "3" || features.ventilation),
165
+ )
166
+ .map(
167
+ ([id, label]) => html`
168
+ <md-select-option value=${id}>
169
+ <div slot="headline">${label}</div>
170
+ </md-select-option>
171
+ `,
172
+ )}
173
+ </md-outlined-select>
174
+ `
175
+ : nothing}
176
+ ${features.motionLatching &&
177
+ (latchControlModes.remoteLatching || latchControlModes.remoteUnlatching)
178
+ ? html`
179
+ <md-outlined-select
180
+ label="Latch"
181
+ .value=${this._moveToLatch}
182
+ @change=${(e: Event) => {
183
+ this._moveToLatch = (e.target as HTMLSelectElement).value;
184
+ }}
185
+ >
186
+ <md-select-option value="">
187
+ <div slot="headline">(unchanged)</div>
188
+ </md-select-option>
189
+ ${latchControlModes.remoteLatching
190
+ ? html`<md-select-option value="true">
191
+ <div slot="headline">Latch</div>
192
+ </md-select-option>`
193
+ : nothing}
194
+ ${latchControlModes.remoteUnlatching
195
+ ? html`<md-select-option value="false">
196
+ <div slot="headline">Unlatch</div>
197
+ </md-select-option>`
198
+ : nothing}
199
+ </md-outlined-select>
200
+ `
201
+ : nothing}
202
+ ${features.speed
203
+ ? html`
204
+ <md-outlined-select
205
+ label="Speed"
206
+ .value=${this._moveToSpeed}
207
+ @change=${(e: Event) => {
208
+ this._moveToSpeed = (e.target as HTMLSelectElement).value;
209
+ }}
210
+ >
211
+ <md-select-option value="">
212
+ <div slot="headline">(unchanged)</div>
213
+ </md-select-option>
214
+ ${Object.entries(SPEED_LABELS).map(
215
+ ([id, label]) => html`
216
+ <md-select-option value=${id}>
217
+ <div slot="headline">${label}</div>
218
+ </md-select-option>
219
+ `,
220
+ )}
221
+ </md-outlined-select>
222
+ `
223
+ : nothing}
224
+ <md-filled-button
225
+ ?disabled=${this._moveToPosition === "" &&
226
+ this._moveToLatch === "" &&
227
+ this._moveToSpeed === ""}
228
+ @click=${handleAsync(() => this._handleMoveTo())}
229
+ >
230
+ Move
231
+ </md-filled-button>
232
+ </div>
233
+ </div>
234
+ </div>
235
+ </details>
236
+ `;
237
+ }
238
+
239
+ private _renderState(state: ClosureState | ClosureCurrentState | null, features: ClosureFeatures) {
240
+ if (!state) return html`<div class="muted empty">Unknown</div>`;
241
+ const positionLabels = "secureState" in state ? CURRENT_POSITION_LABELS : TARGET_POSITION_LABELS;
242
+ return html`
243
+ <div class="state-fields">
244
+ ${features.positioning
245
+ ? html`<div class="state-field">
246
+ <span class="muted">Position:</span>
247
+ <span>
248
+ ${state.position !== null
249
+ ? (positionLabels[state.position] ?? `#${state.position}`)
250
+ : "Unknown"}
251
+ </span>
252
+ </div>`
253
+ : nothing}
254
+ ${features.motionLatching
255
+ ? html`<div class="state-field">
256
+ <span class="muted">Latch:</span>
257
+ <span>${state.latch === null ? "Unknown" : state.latch ? "Latched" : "Unlatched"}</span>
258
+ </div>`
259
+ : nothing}
260
+ ${features.speed
261
+ ? html`<div class="state-field">
262
+ <span class="muted">Speed:</span>
263
+ <span
264
+ >${state.speed !== null
265
+ ? (SPEED_LABELS[state.speed] ?? `#${state.speed}`)
266
+ : "Unknown"}</span
267
+ >
268
+ </div>`
269
+ : nothing}
270
+ ${"secureState" in state
271
+ ? html`<div class="state-field">
272
+ <span class="muted">Secure:</span>
273
+ <span>
274
+ ${state.secureState === null ? "Unknown" : state.secureState ? "Secure" : "Not secure"}
275
+ </span>
276
+ </div>`
277
+ : nothing}
278
+ </div>
279
+ `;
280
+ }
281
+
282
+ private async _handleStop() {
283
+ await stop(this.client, this.node.node_id, this.endpoint);
284
+ }
285
+
286
+ private async _handleCalibrate() {
287
+ await calibrate(this.client, this.node.node_id, this.endpoint);
288
+ }
289
+
290
+ private async _handleMoveTo() {
291
+ await moveTo(this.client, this.node.node_id, this.endpoint, {
292
+ position: this._moveToPosition !== "" ? Number(this._moveToPosition) : undefined,
293
+ latch: this._moveToLatch !== "" ? this._moveToLatch === "true" : undefined,
294
+ speed: this._moveToSpeed !== "" ? Number(this._moveToSpeed) : undefined,
295
+ });
296
+ }
297
+
298
+ static override styles = [
299
+ ...(Array.isArray(BaseClusterCommands.styles) ? BaseClusterCommands.styles : [BaseClusterCommands.styles]),
300
+ css`
301
+ .top-row {
302
+ display: flex;
303
+ align-items: center;
304
+ gap: 16px;
305
+ flex-wrap: wrap;
306
+ padding-bottom: 12px;
307
+ }
308
+ .state-badge {
309
+ font-weight: 500;
310
+ padding: 4px 10px;
311
+ border-radius: 8px;
312
+ background: var(--md-sys-color-secondary-container);
313
+ color: var(--md-sys-color-on-secondary-container);
314
+ }
315
+ .state-badge.error {
316
+ background: var(--md-sys-color-error-container);
317
+ color: var(--md-sys-color-on-error-container);
318
+ }
319
+ .muted {
320
+ color: var(--md-sys-color-on-surface-variant);
321
+ }
322
+ .errors {
323
+ display: flex;
324
+ flex-wrap: wrap;
325
+ gap: 8px;
326
+ padding-bottom: 12px;
327
+ }
328
+ .error-chip {
329
+ display: inline-flex;
330
+ align-items: center;
331
+ gap: 4px;
332
+ padding: 4px 10px;
333
+ border-radius: 8px;
334
+ background: var(--md-sys-color-error-container);
335
+ color: var(--md-sys-color-on-error-container);
336
+ font-size: 0.85rem;
337
+ }
338
+ .error-chip ha-svg-icon {
339
+ --mdc-icon-size: 16px;
340
+ }
341
+ .states-grid {
342
+ display: grid;
343
+ grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
344
+ gap: 16px;
345
+ border-top: 1px solid var(--md-sys-color-outline-variant);
346
+ border-bottom: 1px solid var(--md-sys-color-outline-variant);
347
+ padding: 12px 0;
348
+ margin-bottom: 12px;
349
+ }
350
+ .state-block-header {
351
+ font-weight: 500;
352
+ margin-bottom: 6px;
353
+ }
354
+ .state-fields {
355
+ display: flex;
356
+ flex-direction: column;
357
+ gap: 4px;
358
+ }
359
+ .state-field {
360
+ display: flex;
361
+ gap: 6px;
362
+ }
363
+ .actions {
364
+ display: flex;
365
+ gap: 8px;
366
+ flex-wrap: wrap;
367
+ padding-bottom: 12px;
368
+ }
369
+ .move-to {
370
+ border-top: 1px solid var(--md-sys-color-outline-variant);
371
+ padding-top: 12px;
372
+ }
373
+ .move-to-header {
374
+ font-weight: 500;
375
+ margin-bottom: 8px;
376
+ }
377
+ .move-to-controls {
378
+ display: flex;
379
+ align-items: center;
380
+ gap: 12px;
381
+ flex-wrap: wrap;
382
+ }
383
+ `,
384
+ ];
385
+ }
386
+
387
+ registerClusterCommands(CLOSURE_CONTROL_CLUSTER_ID, "closure-control-cluster-commands");
388
+
389
+ declare global {
390
+ interface HTMLElementTagNameMap {
391
+ "closure-control-cluster-commands": ClosureControlClusterCommands;
392
+ }
393
+ }
@@ -21,6 +21,7 @@ import "./clusters/avsum-commands.js";
21
21
  import "./clusters/basic-information-commands.js";
22
22
  import "./clusters/binding-commands.js";
23
23
  import "./clusters/chime-commands.js";
24
+ import "./clusters/closure-control-commands.js";
24
25
  import "./clusters/icd-management-commands.js";
25
26
  import "./clusters/level-control-commands.js";
26
27
  import "./clusters/on-off-commands.js";