@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.
Files changed (255) hide show
  1. package/README.md +13 -13
  2. package/dist/esm/client/models/descriptions.d.ts.map +1 -1
  3. package/dist/esm/client/models/descriptions.js +479 -28
  4. package/dist/esm/client/models/descriptions.js.map +1 -1
  5. package/dist/esm/components/avsum-ptz-strip.d.ts.map +1 -1
  6. package/dist/esm/components/avsum-ptz-strip.js +6 -6
  7. package/dist/esm/components/avsum-ptz-strip.js.map +1 -1
  8. package/dist/esm/components/semantic-tag-chips.d.ts +16 -0
  9. package/dist/esm/components/semantic-tag-chips.d.ts.map +1 -0
  10. package/dist/esm/components/semantic-tag-chips.js +22 -0
  11. package/dist/esm/components/semantic-tag-chips.js.map +6 -0
  12. package/dist/esm/pages/cluster-commands/clusters/access-control-commands.d.ts.map +1 -1
  13. package/dist/esm/pages/cluster-commands/clusters/access-control-commands.js +3 -2
  14. package/dist/esm/pages/cluster-commands/clusters/access-control-commands.js.map +1 -1
  15. package/dist/esm/pages/cluster-commands/clusters/avsum-commands.d.ts.map +1 -1
  16. package/dist/esm/pages/cluster-commands/clusters/avsum-commands.js +34 -34
  17. package/dist/esm/pages/cluster-commands/clusters/avsum-commands.js.map +1 -1
  18. package/dist/esm/pages/cluster-commands/clusters/basic-information-commands.d.ts.map +1 -1
  19. package/dist/esm/pages/cluster-commands/clusters/basic-information-commands.js +2 -1
  20. package/dist/esm/pages/cluster-commands/clusters/basic-information-commands.js.map +1 -1
  21. package/dist/esm/pages/cluster-commands/clusters/closure-control-commands.d.ts.map +1 -1
  22. package/dist/esm/pages/cluster-commands/clusters/closure-control-commands.js +16 -4
  23. package/dist/esm/pages/cluster-commands/clusters/closure-control-commands.js.map +1 -1
  24. package/dist/esm/pages/cluster-commands/clusters/closure-dimension-commands.d.ts +41 -0
  25. package/dist/esm/pages/cluster-commands/clusters/closure-dimension-commands.d.ts.map +1 -0
  26. package/dist/esm/pages/cluster-commands/clusters/closure-dimension-commands.js +459 -0
  27. package/dist/esm/pages/cluster-commands/clusters/closure-dimension-commands.js.map +6 -0
  28. package/dist/esm/pages/cluster-commands/clusters/commodity-tariff-commands.js +1 -1
  29. package/dist/esm/pages/cluster-commands/clusters/commodity-tariff-commands.js.map +1 -1
  30. package/dist/esm/pages/cluster-commands/clusters/device-energy-management-commands.d.ts +34 -0
  31. package/dist/esm/pages/cluster-commands/clusters/device-energy-management-commands.d.ts.map +1 -0
  32. package/dist/esm/pages/cluster-commands/clusters/device-energy-management-commands.js +324 -0
  33. package/dist/esm/pages/cluster-commands/clusters/device-energy-management-commands.js.map +6 -0
  34. package/dist/esm/pages/cluster-commands/clusters/device-energy-management-mode-commands.d.ts +30 -0
  35. package/dist/esm/pages/cluster-commands/clusters/device-energy-management-mode-commands.d.ts.map +1 -0
  36. package/dist/esm/pages/cluster-commands/clusters/device-energy-management-mode-commands.js +167 -0
  37. package/dist/esm/pages/cluster-commands/clusters/device-energy-management-mode-commands.js.map +6 -0
  38. package/dist/esm/pages/cluster-commands/clusters/door-lock-commands.d.ts +56 -0
  39. package/dist/esm/pages/cluster-commands/clusters/door-lock-commands.d.ts.map +1 -0
  40. package/dist/esm/pages/cluster-commands/clusters/door-lock-commands.js +1919 -0
  41. package/dist/esm/pages/cluster-commands/clusters/door-lock-commands.js.map +6 -0
  42. package/dist/esm/pages/cluster-commands/clusters/energy-evse-commands.d.ts +58 -0
  43. package/dist/esm/pages/cluster-commands/clusters/energy-evse-commands.d.ts.map +1 -0
  44. package/dist/esm/pages/cluster-commands/clusters/energy-evse-commands.js +886 -0
  45. package/dist/esm/pages/cluster-commands/clusters/energy-evse-commands.js.map +6 -0
  46. package/dist/esm/pages/cluster-commands/clusters/icd-management-commands.d.ts.map +1 -1
  47. package/dist/esm/pages/cluster-commands/clusters/icd-management-commands.js +2 -1
  48. package/dist/esm/pages/cluster-commands/clusters/icd-management-commands.js.map +1 -1
  49. package/dist/esm/pages/cluster-commands/clusters/ikea-valve-calibration-commands.d.ts +25 -0
  50. package/dist/esm/pages/cluster-commands/clusters/ikea-valve-calibration-commands.d.ts.map +1 -0
  51. package/dist/esm/pages/cluster-commands/clusters/ikea-valve-calibration-commands.js +135 -0
  52. package/dist/esm/pages/cluster-commands/clusters/ikea-valve-calibration-commands.js.map +6 -0
  53. package/dist/esm/pages/cluster-commands/clusters/media-playback-commands.d.ts +30 -0
  54. package/dist/esm/pages/cluster-commands/clusters/media-playback-commands.d.ts.map +1 -0
  55. package/dist/esm/pages/cluster-commands/clusters/media-playback-commands.js +266 -0
  56. package/dist/esm/pages/cluster-commands/clusters/media-playback-commands.js.map +6 -0
  57. package/dist/esm/pages/cluster-commands/clusters/operational-state-commands.d.ts +27 -0
  58. package/dist/esm/pages/cluster-commands/clusters/operational-state-commands.d.ts.map +1 -0
  59. package/dist/esm/pages/cluster-commands/clusters/operational-state-commands.js +215 -0
  60. package/dist/esm/pages/cluster-commands/clusters/operational-state-commands.js.map +6 -0
  61. package/dist/esm/pages/cluster-commands/clusters/service-area-commands.d.ts +47 -0
  62. package/dist/esm/pages/cluster-commands/clusters/service-area-commands.d.ts.map +1 -0
  63. package/dist/esm/pages/cluster-commands/clusters/service-area-commands.js +344 -0
  64. package/dist/esm/pages/cluster-commands/clusters/service-area-commands.js.map +6 -0
  65. package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.d.ts +24 -2
  66. package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.d.ts.map +1 -1
  67. package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.js +368 -6
  68. package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.js.map +1 -1
  69. package/dist/esm/pages/cluster-commands/clusters/water-heater-management-commands.d.ts +29 -0
  70. package/dist/esm/pages/cluster-commands/clusters/water-heater-management-commands.d.ts.map +1 -0
  71. package/dist/esm/pages/cluster-commands/clusters/water-heater-management-commands.js +262 -0
  72. package/dist/esm/pages/cluster-commands/clusters/water-heater-management-commands.js.map +6 -0
  73. package/dist/esm/pages/cluster-commands/index.d.ts +10 -0
  74. package/dist/esm/pages/cluster-commands/index.d.ts.map +1 -1
  75. package/dist/esm/pages/cluster-commands/index.js +10 -0
  76. package/dist/esm/pages/cluster-commands/index.js.map +1 -1
  77. package/dist/esm/pages/matter-cluster-view.d.ts.map +1 -1
  78. package/dist/esm/pages/matter-cluster-view.js +6 -24
  79. package/dist/esm/pages/matter-cluster-view.js.map +1 -1
  80. package/dist/esm/pages/matter-endpoint-view.d.ts.map +1 -1
  81. package/dist/esm/pages/matter-endpoint-view.js +20 -2
  82. package/dist/esm/pages/matter-endpoint-view.js.map +1 -1
  83. package/dist/esm/pages/matter-network-view.d.ts +16 -0
  84. package/dist/esm/pages/matter-network-view.d.ts.map +1 -1
  85. package/dist/esm/pages/matter-network-view.js +55 -6
  86. package/dist/esm/pages/matter-network-view.js.map +1 -1
  87. package/dist/esm/pages/matter-node-view.d.ts.map +1 -1
  88. package/dist/esm/pages/matter-node-view.js +33 -4
  89. package/dist/esm/pages/matter-node-view.js.map +1 -1
  90. package/dist/esm/pages/network/border-router-store.d.ts +19 -0
  91. package/dist/esm/pages/network/border-router-store.d.ts.map +1 -1
  92. package/dist/esm/pages/network/border-router-store.js +61 -3
  93. package/dist/esm/pages/network/border-router-store.js.map +1 -1
  94. package/dist/esm/pages/network/network-details.d.ts +0 -3
  95. package/dist/esm/pages/network/network-details.d.ts.map +1 -1
  96. package/dist/esm/pages/network/network-details.js +15 -22
  97. package/dist/esm/pages/network/network-details.js.map +1 -1
  98. package/dist/esm/pages/network/network-utils.d.ts +4 -6
  99. package/dist/esm/pages/network/network-utils.d.ts.map +1 -1
  100. package/dist/esm/pages/network/network-utils.js +19 -13
  101. package/dist/esm/pages/network/network-utils.js.map +1 -1
  102. package/dist/esm/pages/network/thread-graph.d.ts +0 -5
  103. package/dist/esm/pages/network/thread-graph.d.ts.map +1 -1
  104. package/dist/esm/pages/network/thread-graph.js +21 -38
  105. package/dist/esm/pages/network/thread-graph.js.map +1 -1
  106. package/dist/esm/util/closure-control.d.ts +1 -0
  107. package/dist/esm/util/closure-control.d.ts.map +1 -1
  108. package/dist/esm/util/closure-control.js +5 -0
  109. package/dist/esm/util/closure-control.js.map +1 -1
  110. package/dist/esm/util/closure-dimension.d.ts +83 -0
  111. package/dist/esm/util/closure-dimension.d.ts.map +1 -0
  112. package/dist/esm/util/closure-dimension.js +238 -0
  113. package/dist/esm/util/closure-dimension.js.map +6 -0
  114. package/dist/esm/util/commodity-tariff.d.ts +1 -2
  115. package/dist/esm/util/commodity-tariff.d.ts.map +1 -1
  116. package/dist/esm/util/commodity-tariff.js +9 -17
  117. package/dist/esm/util/commodity-tariff.js.map +1 -1
  118. package/dist/esm/util/device-energy-management-mode.d.ts +35 -0
  119. package/dist/esm/util/device-energy-management-mode.d.ts.map +1 -0
  120. package/dist/esm/util/device-energy-management-mode.js +80 -0
  121. package/dist/esm/util/device-energy-management-mode.js.map +6 -0
  122. package/dist/esm/util/device-energy-management.d.ts +90 -0
  123. package/dist/esm/util/device-energy-management.d.ts.map +1 -0
  124. package/dist/esm/util/device-energy-management.js +230 -0
  125. package/dist/esm/util/device-energy-management.js.map +6 -0
  126. package/dist/esm/util/device-icons.d.ts.map +1 -1
  127. package/dist/esm/util/device-icons.js +3 -3
  128. package/dist/esm/util/device-icons.js.map +1 -1
  129. package/dist/esm/util/door-lock.d.ts +249 -0
  130. package/dist/esm/util/door-lock.d.ts.map +1 -0
  131. package/dist/esm/util/door-lock.js +724 -0
  132. package/dist/esm/util/door-lock.js.map +6 -0
  133. package/dist/esm/util/endpoint-label.d.ts +13 -0
  134. package/dist/esm/util/endpoint-label.d.ts.map +1 -0
  135. package/dist/esm/util/endpoint-label.js +41 -0
  136. package/dist/esm/util/endpoint-label.js.map +6 -0
  137. package/dist/esm/util/energy-evse.d.ts +116 -0
  138. package/dist/esm/util/energy-evse.d.ts.map +1 -0
  139. package/dist/esm/util/energy-evse.js +308 -0
  140. package/dist/esm/util/energy-evse.js.map +6 -0
  141. package/dist/esm/util/enum-label.d.ts +24 -0
  142. package/dist/esm/util/enum-label.d.ts.map +1 -0
  143. package/dist/esm/util/enum-label.js +24 -0
  144. package/dist/esm/util/enum-label.js.map +6 -0
  145. package/dist/esm/util/error-text.d.ts +8 -0
  146. package/dist/esm/util/error-text.d.ts.map +1 -0
  147. package/dist/esm/util/error-text.js +12 -0
  148. package/dist/esm/util/error-text.js.map +6 -0
  149. package/dist/esm/util/ikea-valve-calibration.d.ts +21 -0
  150. package/dist/esm/util/ikea-valve-calibration.d.ts.map +1 -0
  151. package/dist/esm/util/ikea-valve-calibration.js +43 -0
  152. package/dist/esm/util/ikea-valve-calibration.js.map +6 -0
  153. package/dist/esm/util/media-playback.d.ts +47 -0
  154. package/dist/esm/util/media-playback.d.ts.map +1 -0
  155. package/dist/esm/util/media-playback.js +119 -0
  156. package/dist/esm/util/media-playback.js.map +6 -0
  157. package/dist/esm/util/operational-state.d.ts +102 -0
  158. package/dist/esm/util/operational-state.d.ts.map +1 -0
  159. package/dist/esm/util/operational-state.js +212 -0
  160. package/dist/esm/util/operational-state.js.map +6 -0
  161. package/dist/esm/util/semantic-tags.d.ts +3 -0
  162. package/dist/esm/util/semantic-tags.d.ts.map +1 -1
  163. package/dist/esm/util/semantic-tags.js +5 -1
  164. package/dist/esm/util/semantic-tags.js.map +1 -1
  165. package/dist/esm/util/service-area.d.ts +88 -0
  166. package/dist/esm/util/service-area.d.ts.map +1 -0
  167. package/dist/esm/util/service-area.js +185 -0
  168. package/dist/esm/util/service-area.js.map +6 -0
  169. package/dist/esm/util/shared-styles.d.ts +1 -0
  170. package/dist/esm/util/shared-styles.d.ts.map +1 -1
  171. package/dist/esm/util/shared-styles.js +37 -17
  172. package/dist/esm/util/shared-styles.js.map +1 -1
  173. package/dist/esm/util/thermostat-schedule.d.ts +10 -4
  174. package/dist/esm/util/thermostat-schedule.d.ts.map +1 -1
  175. package/dist/esm/util/thermostat-schedule.js +34 -10
  176. package/dist/esm/util/thermostat-schedule.js.map +1 -1
  177. package/dist/esm/util/thermostat-suggestions.d.ts +31 -0
  178. package/dist/esm/util/thermostat-suggestions.d.ts.map +1 -0
  179. package/dist/esm/util/thermostat-suggestions.js +74 -0
  180. package/dist/esm/util/thermostat-suggestions.js.map +6 -0
  181. package/dist/esm/util/time.d.ts +24 -0
  182. package/dist/esm/util/time.d.ts.map +1 -0
  183. package/dist/esm/util/time.js +42 -0
  184. package/dist/esm/util/time.js.map +6 -0
  185. package/dist/esm/util/water-heater-management.d.ts +56 -0
  186. package/dist/esm/util/water-heater-management.d.ts.map +1 -0
  187. package/dist/esm/util/water-heater-management.js +147 -0
  188. package/dist/esm/util/water-heater-management.js.map +6 -0
  189. package/dist/web/index.html +4 -0
  190. package/dist/web/js/{attribute-write-dialog-Dj2vnLR_.js → attribute-write-dialog-DrJZQaXy.js} +1 -1
  191. package/dist/web/js/{command-invoke-dialog-DJY2HePu.js → command-invoke-dialog-D_zf390T.js} +1 -1
  192. package/dist/web/js/{commission-node-dialog-BAzJcdYg.js → commission-node-dialog-DIBv_ihK.js} +5 -5
  193. package/dist/web/js/{commission-node-existing-DDtYs7R-.js → commission-node-existing-ApIugQzz.js} +1 -1
  194. package/dist/web/js/{commission-node-thread-Bf0XhUqn.js → commission-node-thread-DdEySLrf.js} +1 -1
  195. package/dist/web/js/{commission-node-wifi-DL4q7kzh.js → commission-node-wifi-BIhsmTCV.js} +1 -1
  196. package/dist/web/js/{dialog-box-BquhCceT.js → dialog-box-Df4y4onO.js} +1 -1
  197. package/dist/web/js/{fabric-label-dialog-iLm9DGea.js → fabric-label-dialog-BFs_iHTp.js} +1 -1
  198. package/dist/web/js/main.js +61 -28
  199. package/dist/web/js/{matter-dashboard-app-RcyNZLl_.js → matter-dashboard-app-DfcntGqC.js} +17911 -10233
  200. package/dist/web/js/{node-acl-add-dialog-CyWYXa6M.js → node-acl-add-dialog-DPG7FkNs.js} +1 -1
  201. package/dist/web/js/{node-binding-dialog-BjQ0KYzx.js → node-binding-dialog-CvQuClGz.js} +1 -1
  202. package/dist/web/js/{node-label-dialog-BNUn3Joo.js → node-label-dialog-DNEWL6Ku.js} +1 -1
  203. package/dist/web/js/{settings-dialog-DvAq6gKo.js → settings-dialog-BvAdX2Jo.js} +1 -1
  204. package/package.json +7 -7
  205. package/src/client/models/descriptions.ts +479 -28
  206. package/src/components/avsum-ptz-strip.ts +10 -9
  207. package/src/components/semantic-tag-chips.ts +30 -0
  208. package/src/pages/cluster-commands/AGENTS.md +1 -0
  209. package/src/pages/cluster-commands/clusters/access-control-commands.ts +3 -2
  210. package/src/pages/cluster-commands/clusters/avsum-commands.ts +44 -42
  211. package/src/pages/cluster-commands/clusters/basic-information-commands.ts +2 -1
  212. package/src/pages/cluster-commands/clusters/closure-control-commands.ts +16 -4
  213. package/src/pages/cluster-commands/clusters/closure-dimension-commands.ts +512 -0
  214. package/src/pages/cluster-commands/clusters/commodity-tariff-commands.ts +1 -1
  215. package/src/pages/cluster-commands/clusters/device-energy-management-commands.ts +426 -0
  216. package/src/pages/cluster-commands/clusters/device-energy-management-mode-commands.ts +172 -0
  217. package/src/pages/cluster-commands/clusters/door-lock-commands.ts +2120 -0
  218. package/src/pages/cluster-commands/clusters/energy-evse-commands.ts +1048 -0
  219. package/src/pages/cluster-commands/clusters/icd-management-commands.ts +2 -1
  220. package/src/pages/cluster-commands/clusters/ikea-valve-calibration-commands.ts +129 -0
  221. package/src/pages/cluster-commands/clusters/media-playback-commands.ts +313 -0
  222. package/src/pages/cluster-commands/clusters/operational-state-commands.ts +234 -0
  223. package/src/pages/cluster-commands/clusters/service-area-commands.ts +395 -0
  224. package/src/pages/cluster-commands/clusters/thermostat-commands.ts +418 -7
  225. package/src/pages/cluster-commands/clusters/water-heater-management-commands.ts +275 -0
  226. package/src/pages/cluster-commands/index.ts +10 -0
  227. package/src/pages/matter-cluster-view.ts +6 -28
  228. package/src/pages/matter-endpoint-view.ts +24 -2
  229. package/src/pages/matter-network-view.ts +67 -6
  230. package/src/pages/matter-node-view.ts +35 -4
  231. package/src/pages/network/border-router-store.ts +77 -2
  232. package/src/pages/network/network-details.ts +15 -26
  233. package/src/pages/network/network-utils.ts +15 -15
  234. package/src/pages/network/thread-graph.ts +32 -48
  235. package/src/util/closure-control.ts +5 -0
  236. package/src/util/closure-dimension.ts +307 -0
  237. package/src/util/commodity-tariff.ts +9 -23
  238. package/src/util/device-energy-management-mode.ts +132 -0
  239. package/src/util/device-energy-management.ts +378 -0
  240. package/src/util/device-icons.ts +4 -6
  241. package/src/util/door-lock.ts +1076 -0
  242. package/src/util/endpoint-label.ts +70 -0
  243. package/src/util/energy-evse.ts +472 -0
  244. package/src/util/enum-label.ts +39 -0
  245. package/src/util/error-text.ts +10 -0
  246. package/src/util/ikea-valve-calibration.ts +54 -0
  247. package/src/util/media-playback.ts +132 -0
  248. package/src/util/operational-state.ts +251 -0
  249. package/src/util/semantic-tags.ts +6 -0
  250. package/src/util/service-area.ts +313 -0
  251. package/src/util/shared-styles.ts +37 -17
  252. package/src/util/thermostat-schedule.ts +39 -11
  253. package/src/util/thermostat-suggestions.ts +93 -0
  254. package/src/util/time.ts +54 -0
  255. package/src/util/water-heater-management.ts +217 -0
@@ -0,0 +1,395 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025-2026 Open Home Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import "@material/web/button/outlined-button";
8
+ import { MdCheckbox } from "@material/web/checkbox/checkbox.js";
9
+ import { css, html, nothing, type CSSResultGroup } from "lit";
10
+ import { customElement, state } from "lit/decorators.js";
11
+ import { handleAsync } from "../../../util/async-handler.js";
12
+ import { formatDuration } from "../../../util/duration.js";
13
+ import { errorText } from "../../../util/error-text.js";
14
+ import {
15
+ SERVICE_AREA_CLUSTER_ID,
16
+ areaLabel,
17
+ decodeSelectAreasResult,
18
+ decodeSkipAreaResult,
19
+ describeOperationalStatus,
20
+ isSkippable,
21
+ OperationalStatus,
22
+ remainingSeconds,
23
+ remainingTimeLabel,
24
+ serviceAreaInfo,
25
+ type AreaInfo,
26
+ type CommandResult,
27
+ type MapInfo,
28
+ type ProgressInfo,
29
+ type ServiceAreaInfo,
30
+ } from "../../../util/service-area.js";
31
+ import { formatEpochTime } from "../../../util/time.js";
32
+ import { BaseClusterCommands } from "../base-cluster-commands.js";
33
+ import { registerClusterCommands } from "../registry.js";
34
+
35
+ const CLUSTER_ID = SERVICE_AREA_CLUSTER_ID;
36
+
37
+ const COUNTDOWN_INTERVAL_MS = 1000;
38
+
39
+ @customElement("service-area-cluster-commands")
40
+ class ServiceAreaClusterCommands extends BaseClusterCommands {
41
+ @state() private _selectedAreaIds = new Set<number>();
42
+ @state() private _busy = false;
43
+ @state() private _result?: { command: "SelectAreas" | "SkipArea"; result: CommandResult };
44
+ @state() private _error?: string;
45
+ private _formContext?: string;
46
+ /** An invoke started before a reset must not write its outcome into the panel that replaced it. */
47
+ private _invokeGeneration = 0;
48
+ /** Until the user picks areas, the checkboxes follow the device's own SelectedAreas. */
49
+ private _selectionEdited = false;
50
+ private _info?: ServiceAreaInfo;
51
+ private _countdownTimer?: ReturnType<typeof setInterval>;
52
+
53
+ override connectedCallback() {
54
+ super.connectedCallback();
55
+ // A reconnected element gets no property change, so nothing else would restart the countdown.
56
+ if (this._info !== undefined) this._syncCountdown(this._info);
57
+ }
58
+
59
+ override disconnectedCallback() {
60
+ super.disconnectedCallback();
61
+ this._stopCountdown();
62
+ }
63
+
64
+ override willUpdate(changedProperties: Map<string, unknown>) {
65
+ super.willUpdate(changedProperties);
66
+ if (!this.node) {
67
+ this._stopCountdown();
68
+ return;
69
+ }
70
+ const context = `${String(this.node.node_id)}/${this.endpoint}/${this.cluster}`;
71
+ if (this._formContext !== undefined && this._formContext !== context) {
72
+ this._selectedAreaIds = new Set();
73
+ this._selectionEdited = false;
74
+ this._result = undefined;
75
+ this._error = undefined;
76
+ this._busy = false;
77
+ this._invokeGeneration++;
78
+ }
79
+ this._formContext = context;
80
+
81
+ if (this.cluster !== CLUSTER_ID) {
82
+ this._info = undefined;
83
+ this._stopCountdown();
84
+ return;
85
+ }
86
+
87
+ const info = serviceAreaInfo(this.node.attributes, this.endpoint);
88
+ this._info = info;
89
+ this._syncSelection(info);
90
+ this._syncCountdown(info);
91
+ }
92
+
93
+ /**
94
+ * SelectAreas replaces the device's whole selection, so a panel that starts empty would cancel
95
+ * whatever is running the moment the user submits. An edited selection still drops areas the
96
+ * device no longer supports, which it would only reject as UnsupportedArea.
97
+ */
98
+ private _syncSelection(info: ServiceAreaInfo) {
99
+ const supported = new Set(info.supportedAreas.map(area => area.areaId));
100
+ const next = new Set(
101
+ (this._selectionEdited ? [...this._selectedAreaIds] : info.selectedAreas).filter(areaId =>
102
+ supported.has(areaId),
103
+ ),
104
+ );
105
+ if (next.size !== this._selectedAreaIds.size || [...next].some(id => !this._selectedAreaIds.has(id))) {
106
+ this._selectedAreaIds = next;
107
+ }
108
+ }
109
+
110
+ private _syncCountdown(info: ServiceAreaInfo) {
111
+ const needed = typeof info.estimatedEndTime === "number" && remainingSeconds(info.estimatedEndTime) > 0;
112
+ if (needed && this._countdownTimer === undefined) {
113
+ this._countdownTimer = setInterval(() => this.requestUpdate(), COUNTDOWN_INTERVAL_MS);
114
+ } else if (!needed) {
115
+ this._stopCountdown();
116
+ }
117
+ }
118
+
119
+ private _stopCountdown() {
120
+ if (this._countdownTimer !== undefined) {
121
+ clearInterval(this._countdownTimer);
122
+ this._countdownTimer = undefined;
123
+ }
124
+ }
125
+
126
+ private _toggleArea(areaId: number, checked: boolean) {
127
+ const next = new Set(this._selectedAreaIds);
128
+ if (checked) next.add(areaId);
129
+ else next.delete(areaId);
130
+ this._selectionEdited = true;
131
+ this._selectedAreaIds = next;
132
+ }
133
+
134
+ private async _selectAreas() {
135
+ const node = this.node;
136
+ const endpoint = this.endpoint;
137
+ const generation = ++this._invokeGeneration;
138
+ const isCurrent = () => this._invokeGeneration === generation && this.isSameContext(node, endpoint);
139
+ this._busy = true;
140
+ this._error = undefined;
141
+ this._result = undefined;
142
+ try {
143
+ const response = await this.client.deviceCommand(node.node_id, endpoint, CLUSTER_ID, "SelectAreas", {
144
+ newAreas: [...this._selectedAreaIds],
145
+ });
146
+ if (!isCurrent()) return;
147
+ const result = decodeSelectAreasResult(response);
148
+ this._result = { command: "SelectAreas", result };
149
+ // The device now owns the selection again, so let SelectedAreas drive the checkboxes.
150
+ if (result.success) this._selectionEdited = false;
151
+ } catch (err) {
152
+ if (isCurrent()) this._error = errorText(err);
153
+ } finally {
154
+ if (isCurrent()) this._busy = false;
155
+ }
156
+ }
157
+
158
+ private async _skipArea(areaId: number) {
159
+ const node = this.node;
160
+ const endpoint = this.endpoint;
161
+ const generation = ++this._invokeGeneration;
162
+ const isCurrent = () => this._invokeGeneration === generation && this.isSameContext(node, endpoint);
163
+ this._busy = true;
164
+ this._error = undefined;
165
+ this._result = undefined;
166
+ try {
167
+ const response = await this.client.deviceCommand(node.node_id, endpoint, CLUSTER_ID, "SkipArea", {
168
+ skippedArea: areaId,
169
+ });
170
+ if (!isCurrent()) return;
171
+ this._result = { command: "SkipArea", result: decodeSkipAreaResult(response) };
172
+ } catch (err) {
173
+ if (isCurrent()) this._error = errorText(err);
174
+ } finally {
175
+ if (isCurrent()) this._busy = false;
176
+ }
177
+ }
178
+
179
+ private _renderArea(area: AreaInfo, info: ServiceAreaInfo) {
180
+ const isCurrent = info.currentArea === area.areaId;
181
+ const progress = info.progress.find(entry => entry.areaId === area.areaId);
182
+
183
+ return html`
184
+ <li class="area-row ${isCurrent ? "area-row-current" : ""}">
185
+ <label>
186
+ <md-checkbox
187
+ .checked=${this._selectedAreaIds.has(area.areaId)}
188
+ ?disabled=${this._busy || !this.node.available || !info.commands.selectAreas}
189
+ @change=${(e: Event) => {
190
+ if (e.target instanceof MdCheckbox) this._toggleArea(area.areaId, e.target.checked);
191
+ }}
192
+ ></md-checkbox>
193
+ <span
194
+ >${areaLabel(area)}${
195
+ // The map header already conveys the floor once maps group the list; a
196
+ // per-row number is only informative in the flat, ungrouped fallback.
197
+ area.floorNumber !== undefined && !info.features.maps
198
+ ? html` <span>floor ${area.floorNumber}</span>`
199
+ : nothing
200
+ }${isCurrent ? html` <strong>(current)</strong>` : nothing}</span
201
+ >
202
+ </label>
203
+ ${progress ? this._renderProgressBadge(progress) : nothing}
204
+ ${
205
+ isSkippable(info, area.areaId)
206
+ ? html`<md-outlined-button
207
+ ?disabled=${this._busy || !this.node.available}
208
+ @click=${handleAsync(() => this._skipArea(area.areaId))}
209
+ >Skip</md-outlined-button
210
+ >`
211
+ : nothing
212
+ }
213
+ </li>
214
+ `;
215
+ }
216
+
217
+ private _renderProgressBadge(progress: ProgressInfo) {
218
+ const status = describeOperationalStatus(progress.status);
219
+ const times = new Array<string>();
220
+ if (progress.totalOperationalTime !== undefined) {
221
+ times.push(`ran ${formatDuration(progress.totalOperationalTime)}`);
222
+ }
223
+ if (progress.estimatedTime !== undefined) times.push(`~${formatDuration(progress.estimatedTime)} estimated`);
224
+
225
+ return html`<span class="progress-badge progress-${status.key}"
226
+ >${status.label}${times.length > 0 ? html` <span class="area-detail">${times.join(", ")}</span>` : nothing}</span
227
+ >`;
228
+ }
229
+
230
+ private _renderMapGroup(map: MapInfo | undefined, areas: AreaInfo[], info: ServiceAreaInfo) {
231
+ return html`
232
+ ${map ? html`<h4 class="map-name">${map.name}</h4>` : nothing}
233
+ <ul class="area-list">
234
+ ${areas.map(area => this._renderArea(area, info))}
235
+ </ul>
236
+ `;
237
+ }
238
+
239
+ override render() {
240
+ const info = this._info;
241
+ if (!this.node || info === undefined) return nothing;
242
+
243
+ const knownMapIds = new Set(info.supportedMaps.map(map => map.mapId));
244
+ const groups: { map: MapInfo | undefined; areas: AreaInfo[] }[] = info.features.maps
245
+ ? [
246
+ ...info.supportedMaps.map(map => ({
247
+ map,
248
+ areas: info.supportedAreas.filter(a => a.mapId === map.mapId),
249
+ })),
250
+ {
251
+ map: undefined,
252
+ areas: info.supportedAreas.filter(a => a.mapId === undefined || !knownMapIds.has(a.mapId)),
253
+ },
254
+ ].filter(group => group.areas.length > 0)
255
+ : [{ map: undefined, areas: info.supportedAreas }];
256
+
257
+ const running = info.progress.some(entry => entry.status === OperationalStatus.Operating);
258
+
259
+ return html`
260
+ <details class="command-panel">
261
+ <summary>Service Area</summary>
262
+ <div class="command-content">
263
+ ${
264
+ typeof info.estimatedEndTime === "number"
265
+ ? html`<div class="command-row">
266
+ <span
267
+ >Estimated end:
268
+ <strong>${formatEpochTime(info.estimatedEndTime)}</strong>
269
+ <span class="area-detail">${remainingTimeLabel(info.estimatedEndTime)}</span>
270
+ </span>
271
+ </div>`
272
+ : nothing
273
+ }
274
+ ${
275
+ info.supportedAreas.length === 0
276
+ ? html`<div class="command-row">No supported areas reported.</div>`
277
+ : groups.map(group => this._renderMapGroup(group.map, group.areas, info))
278
+ }
279
+ <div class="command-row">
280
+ <md-outlined-button
281
+ ?disabled=${
282
+ this._busy ||
283
+ !this.node.available ||
284
+ !info.commands.selectAreas ||
285
+ (running && !info.features.selectWhileRunning)
286
+ }
287
+ @click=${handleAsync(() => this._selectAreas())}
288
+ >Select Areas (${this._selectedAreaIds.size})</md-outlined-button
289
+ >
290
+ ${
291
+ running && !info.features.selectWhileRunning
292
+ ? html`<span class="area-detail"
293
+ >The device rejects a new selection while it is running.</span
294
+ >`
295
+ : nothing
296
+ }
297
+ </div>
298
+ ${
299
+ this._result
300
+ ? html`<div
301
+ class="result ${this._result.result.success ? "" : "result-error"}"
302
+ role=${this._result.result.success ? "status" : "alert"}
303
+ >
304
+ ${this._result.command} → ${this._result.result.statusName}
305
+ (${this._result.result.status})${
306
+ this._result.result.statusText
307
+ ? html`: ${this._result.result.statusText}`
308
+ : nothing
309
+ }
310
+ </div>`
311
+ : nothing
312
+ }
313
+ ${this._error ? html`<div class="result result-error" role="alert">${this._error}</div>` : nothing}
314
+ </div>
315
+ </details>
316
+ `;
317
+ }
318
+
319
+ static override styles: CSSResultGroup = [
320
+ BaseClusterCommands.styles,
321
+ css`
322
+ .map-name {
323
+ margin: 12px 0 4px 0;
324
+ font-size: 13px;
325
+ font-weight: 500;
326
+ color: var(--md-sys-color-on-surface-variant);
327
+ }
328
+ .area-list {
329
+ list-style: none;
330
+ margin: 0 0 12px 0;
331
+ padding: 0;
332
+ display: flex;
333
+ flex-direction: column;
334
+ gap: 4px;
335
+ }
336
+ .area-row {
337
+ display: flex;
338
+ align-items: center;
339
+ gap: 12px;
340
+ padding: 4px 0;
341
+ font-size: 14px;
342
+ }
343
+ .area-row label {
344
+ display: flex;
345
+ align-items: center;
346
+ gap: 8px;
347
+ cursor: pointer;
348
+ }
349
+ .area-row-current {
350
+ background-color: var(--md-sys-color-surface-container-high);
351
+ border-radius: 8px;
352
+ }
353
+ .area-detail {
354
+ font-size: 12px;
355
+ color: var(--md-sys-color-on-surface-variant);
356
+ }
357
+ .progress-badge {
358
+ font-size: 12px;
359
+ padding: 2px 8px;
360
+ border-radius: 8px;
361
+ background-color: var(--md-sys-color-surface-container-highest);
362
+ color: var(--md-sys-color-on-surface-variant);
363
+ }
364
+ .progress-operating {
365
+ background-color: var(--md-sys-color-tertiary-container);
366
+ color: var(--md-sys-color-on-tertiary-container);
367
+ }
368
+ .progress-completed {
369
+ background-color: var(--md-sys-color-secondary-container);
370
+ color: var(--md-sys-color-on-secondary-container);
371
+ }
372
+ .result {
373
+ margin-top: 8px;
374
+ padding: 8px 10px;
375
+ border-radius: 6px;
376
+ background: color-mix(in srgb, var(--success-color) 18%, transparent);
377
+ color: var(--success-color);
378
+ border: 1px solid color-mix(in srgb, var(--success-color) 40%, transparent);
379
+ }
380
+ .result-error {
381
+ background: var(--md-sys-color-error-container);
382
+ color: var(--md-sys-color-on-error-container);
383
+ border: none;
384
+ }
385
+ `,
386
+ ];
387
+ }
388
+
389
+ registerClusterCommands(CLUSTER_ID, "service-area-cluster-commands");
390
+
391
+ declare global {
392
+ interface HTMLElementTagNameMap {
393
+ "service-area-cluster-commands": ServiceAreaClusterCommands;
394
+ }
395
+ }