@matter-server/dashboard 1.4.0 → 1.4.1-alpha.0-20260813-eaf19f2

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 (43) hide show
  1. package/dist/esm/pages/cluster-commands/clusters/commodity-tariff-commands.js +1 -1
  2. package/dist/esm/pages/cluster-commands/clusters/commodity-tariff-commands.js.map +1 -1
  3. package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.d.ts +24 -2
  4. package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.d.ts.map +1 -1
  5. package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.js +368 -6
  6. package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.js.map +1 -1
  7. package/dist/esm/util/commodity-tariff.d.ts +0 -2
  8. package/dist/esm/util/commodity-tariff.d.ts.map +1 -1
  9. package/dist/esm/util/commodity-tariff.js +0 -12
  10. package/dist/esm/util/commodity-tariff.js.map +1 -1
  11. package/dist/esm/util/thermostat-schedule.d.ts +10 -4
  12. package/dist/esm/util/thermostat-schedule.d.ts.map +1 -1
  13. package/dist/esm/util/thermostat-schedule.js +34 -10
  14. package/dist/esm/util/thermostat-schedule.js.map +1 -1
  15. package/dist/esm/util/thermostat-suggestions.d.ts +31 -0
  16. package/dist/esm/util/thermostat-suggestions.d.ts.map +1 -0
  17. package/dist/esm/util/thermostat-suggestions.js +74 -0
  18. package/dist/esm/util/thermostat-suggestions.js.map +6 -0
  19. package/dist/esm/util/time.d.ts +8 -0
  20. package/dist/esm/util/time.d.ts.map +1 -0
  21. package/dist/esm/util/time.js +20 -0
  22. package/dist/esm/util/time.js.map +6 -0
  23. package/dist/web/js/{attribute-write-dialog-Dj2vnLR_.js → attribute-write-dialog-D9sQZ3cC.js} +1 -1
  24. package/dist/web/js/{command-invoke-dialog-DJY2HePu.js → command-invoke-dialog-97gEPxxK.js} +1 -1
  25. package/dist/web/js/{commission-node-dialog-BAzJcdYg.js → commission-node-dialog-DGQNBWXZ.js} +5 -5
  26. package/dist/web/js/{commission-node-existing-DDtYs7R-.js → commission-node-existing-6v8QILKO.js} +1 -1
  27. package/dist/web/js/{commission-node-thread-Bf0XhUqn.js → commission-node-thread-yDsPWps7.js} +1 -1
  28. package/dist/web/js/{commission-node-wifi-DL4q7kzh.js → commission-node-wifi-CI7pARxR.js} +1 -1
  29. package/dist/web/js/{dialog-box-BquhCceT.js → dialog-box-3KtZbAq6.js} +1 -1
  30. package/dist/web/js/{fabric-label-dialog-iLm9DGea.js → fabric-label-dialog-DEX_6sSD.js} +1 -1
  31. package/dist/web/js/main.js +1 -1
  32. package/dist/web/js/{matter-dashboard-app-RcyNZLl_.js → matter-dashboard-app-CI4ZaWuC.js} +3805 -3340
  33. package/dist/web/js/{node-acl-add-dialog-CyWYXa6M.js → node-acl-add-dialog-sZ48IJcy.js} +1 -1
  34. package/dist/web/js/{node-binding-dialog-BjQ0KYzx.js → node-binding-dialog-Ds8EQCKU.js} +1 -1
  35. package/dist/web/js/{node-label-dialog-BNUn3Joo.js → node-label-dialog-DVACaUNu.js} +1 -1
  36. package/dist/web/js/{settings-dialog-DvAq6gKo.js → settings-dialog-36p8fc6y.js} +1 -1
  37. package/package.json +4 -4
  38. package/src/pages/cluster-commands/clusters/commodity-tariff-commands.ts +1 -1
  39. package/src/pages/cluster-commands/clusters/thermostat-commands.ts +418 -7
  40. package/src/util/commodity-tariff.ts +0 -18
  41. package/src/util/thermostat-schedule.ts +39 -11
  42. package/src/util/thermostat-suggestions.ts +93 -0
  43. package/src/util/time.ts +23 -0
@@ -1,4 +1,4 @@
1
- import { i, c, a as clientContext, n, r, b as i$1, P as Privilege, x as nodeIdKey, y as aclCapacity, s as showAlertDialog, z as targetServerClusters, B as clusters, C as AuthMode, E as addAclEntry, F as PRIVILEGE_NAMES, d as b, G as mdiClose, H as getDeviceName, h as handleAsync, g as t } from './matter-dashboard-app-RcyNZLl_.js';
1
+ import { i, c, a as clientContext, n, r, b as i$1, P as Privilege, x as nodeIdKey, y as aclCapacity, s as showAlertDialog, z as targetServerClusters, B as clusters, C as AuthMode, E as addAclEntry, F as PRIVILEGE_NAMES, d as b, G as mdiClose, H as getDeviceName, h as handleAsync, g as t } from './matter-dashboard-app-CI4ZaWuC.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, x as nodeIdKey, B as clusters, s as showAlertDialog, I as targetAclCapacityForBinding, J as addBinding, K as bindableClusters, A, d as b, H as getDeviceName, L as getEndpointDeviceTypes, h as handleAsync, g as t } from './matter-dashboard-app-RcyNZLl_.js';
1
+ import { i, c, a as clientContext, n, r, b as i$1, x as nodeIdKey, B as clusters, s as showAlertDialog, I as targetAclCapacityForBinding, J as addBinding, K as bindableClusters, A, d as b, H as getDeviceName, L as getEndpointDeviceTypes, h as handleAsync, g as t } from './matter-dashboard-app-CI4ZaWuC.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-RcyNZLl_.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-CI4ZaWuC.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-RcyNZLl_.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-CI4ZaWuC.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.4.0",
3
+ "version": "1.4.1-alpha.0-20260813-eaf19f2",
4
4
  "description": "Dashboard for OHF Matter Server",
5
5
  "homepage": "https://github.com/matter-js/matterjs-server",
6
6
  "bugs": {
@@ -34,13 +34,13 @@
34
34
  "dependencies": {
35
35
  "@lit/context": "^1.1.6",
36
36
  "@material/web": "^2.5.0",
37
- "@matter-server/custom-clusters": "1.4.0",
38
- "@matter-server/ws-client": "1.4.0",
37
+ "@matter-server/custom-clusters": "1.4.1-alpha.0-20260813-eaf19f2",
38
+ "@matter-server/ws-client": "1.4.1-alpha.0-20260813-eaf19f2",
39
39
  "@mdi/js": "^7.4.47",
40
40
  "lit": "^3.3.3",
41
41
  "qrcode-generator": "^2.0.4",
42
42
  "tslib": "^2.8.1",
43
- "vis-network": "^10.1.0"
43
+ "vis-network": "^10.1.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@babel/preset-env": "^8.0.2",
@@ -9,12 +9,12 @@ import { customElement } from "lit/decorators.js";
9
9
  import {
10
10
  COMMODITY_TARIFF_CLUSTER_ID,
11
11
  commodityTariffInfo,
12
- formatEpochTime,
13
12
  formatMinutesOfDay,
14
13
  type ScheduleRow,
15
14
  type TariffComponentInfo,
16
15
  type TariffRange,
17
16
  } from "../../../util/commodity-tariff.js";
17
+ import { formatEpochTime } from "../../../util/time.js";
18
18
  import { BaseClusterCommands } from "../base-cluster-commands.js";
19
19
  import { registerClusterCommands } from "../registry.js";
20
20
 
@@ -4,10 +4,25 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import { mdiCheck, mdiClockOutline, mdiFire, mdiSnowflake } from "@mdi/js";
8
- import { css, type CSSResultGroup, html, nothing } from "lit";
7
+ import "@material/web/button/outlined-button";
8
+ import "@material/web/iconbutton/outlined-icon-button";
9
+ import type { MatterNode } from "@matter-server/ws-client";
10
+ import {
11
+ mdiCheck,
12
+ mdiClockOutline,
13
+ mdiFire,
14
+ mdiLightbulbOnOutline,
15
+ mdiPaletteSwatchOutline,
16
+ mdiPlus,
17
+ mdiSnowflake,
18
+ mdiTrashCanOutline,
19
+ } from "@mdi/js";
20
+ import { css, type CSSResultGroup, html, nothing, type TemplateResult } from "lit";
9
21
  import { customElement, state } from "lit/decorators.js";
22
+ import { live } from "lit/directives/live.js";
10
23
  import "../../../components/ha-svg-icon.js";
24
+ import { showAlertDialog } from "../../../components/dialog-box/show-dialog-box.js";
25
+ import { handleAsync } from "../../../util/async-handler.js";
11
26
  import {
12
27
  buildDaySegments,
13
28
  compareTransitionsForDisplay,
@@ -17,9 +32,11 @@ import {
17
32
  formatDayOfWeek,
18
33
  formatHandleShort,
19
34
  formatMinutes,
35
+ formatPresetLabel,
20
36
  formatSegmentTooltip,
21
37
  formatSetpoint,
22
- isMSCHActive,
38
+ isFeatureActive,
39
+ readActivePresetHandle,
23
40
  readActiveScheduleHandle,
24
41
  readPresets,
25
42
  pickSetpointForMode,
@@ -29,18 +46,45 @@ import {
29
46
  type ScheduleColorMode,
30
47
  setpointColorMixPercent,
31
48
  THERMOSTAT_CLUSTER_ID,
49
+ type ThermostatPreset,
32
50
  } from "../../../util/thermostat-schedule.js";
51
+ import {
52
+ clampExpirationMinutes,
53
+ MAX_EXPIRATION_MINUTES,
54
+ MIN_EXPIRATION_MINUTES,
55
+ readCurrentThermostatSuggestion,
56
+ readMaxThermostatSuggestions,
57
+ readThermostatSuggestionNotFollowingReasons,
58
+ readThermostatSuggestions,
59
+ resolveSuggestionLabel,
60
+ type ThermostatSuggestion,
61
+ } from "../../../util/thermostat-suggestions.js";
62
+ import { formatEpochTime } from "../../../util/time.js";
33
63
  import { BaseClusterCommands } from "../base-cluster-commands.js";
34
64
  import { registerClusterCommands } from "../registry.js";
35
65
 
36
66
  const HOUR_TICKS = [0, 4, 8, 12, 16, 20, 24];
37
67
 
68
+ const DEFAULT_EXPIRATION_MINUTES = 60;
69
+
38
70
  @customElement("thermostat-cluster-commands")
39
71
  class ThermostatClusterCommands extends BaseClusterCommands {
40
72
  @state() private _selectedHandle: string | null = null;
41
73
  @state() private _colorMode: ScheduleColorMode = "heat";
42
74
  private _scheduleContext?: string;
43
75
 
76
+ @state() private _addPresetHandle: string | null = null;
77
+ @state() private _addExpirationMinutes = DEFAULT_EXPIRATION_MINUTES;
78
+ @state() private _addExpirationInput = String(DEFAULT_EXPIRATION_MINUTES);
79
+
80
+ /**
81
+ * In-flight invokes, identified by operation id rather than a boolean: the panel is reused across
82
+ * navigations, so a settling promise must only clear the flag it set itself.
83
+ */
84
+ @state() private _addOperation: number | null = null;
85
+ @state() private _removeOperations: Record<number, number> = {};
86
+ private _operationCounter = 0;
87
+
44
88
  override willUpdate(changedProperties: Map<string, unknown>) {
45
89
  super.willUpdate(changedProperties);
46
90
  if (!this.node) return;
@@ -48,18 +92,29 @@ class ThermostatClusterCommands extends BaseClusterCommands {
48
92
  if (this._scheduleContext !== undefined && this._scheduleContext !== context) {
49
93
  this._selectedHandle = null;
50
94
  this._colorMode = "heat";
95
+ this._addPresetHandle = null;
96
+ this._addExpirationMinutes = DEFAULT_EXPIRATION_MINUTES;
97
+ this._addExpirationInput = String(DEFAULT_EXPIRATION_MINUTES);
98
+ this._addOperation = null;
99
+ this._removeOperations = {};
51
100
  }
52
101
  this._scheduleContext = context;
53
102
  }
54
103
 
55
104
  override render() {
56
- if (!this.node || this.cluster !== THERMOSTAT_CLUSTER_ID || !isMSCHActive(this.node, this.endpoint)) {
57
- return nothing;
58
- }
105
+ if (!this.node || this.cluster !== THERMOSTAT_CLUSTER_ID) return nothing;
59
106
 
107
+ return html`
108
+ ${isFeatureActive(this.node, this.endpoint, "MSCH") ? this._renderSchedulePanel() : nothing}
109
+ ${isFeatureActive(this.node, this.endpoint, "PRES") ? this._renderPresetsPanel() : nothing}
110
+ ${isFeatureActive(this.node, this.endpoint, "TSUGGEST") ? this._renderSuggestionsPanel() : nothing}
111
+ `;
112
+ }
113
+
114
+ private _renderSchedulePanel(): TemplateResult {
60
115
  const schedules = readSchedules(this.node, this.endpoint);
61
116
  const activeHandle = readActiveScheduleHandle(this.node, this.endpoint);
62
- const presets = readPresets(this.node, this.endpoint);
117
+ const presets = readPresets(this.node, this.endpoint) ?? [];
63
118
 
64
119
  const pickedSchedule =
65
120
  (this._selectedHandle !== null ? schedules?.find(s => s.handle === this._selectedHandle) : undefined) ??
@@ -260,6 +315,274 @@ class ThermostatClusterCommands extends BaseClusterCommands {
260
315
  `;
261
316
  }
262
317
 
318
+ private _renderPresetsPanel(): TemplateResult {
319
+ const presets = readPresets(this.node, this.endpoint);
320
+ const activeHandle = readActivePresetHandle(this.node, this.endpoint);
321
+
322
+ return html`
323
+ <details class="command-panel" open>
324
+ <summary>
325
+ <ha-svg-icon .path=${mdiPaletteSwatchOutline}></ha-svg-icon>
326
+ Presets
327
+ <span class="feature-map-badge">FeatureMap: PRES</span>
328
+ </summary>
329
+ <div class="command-content">
330
+ ${
331
+ presets === undefined
332
+ ? html`<p class="empty">Presets attribute not available.</p>`
333
+ : presets.length === 0
334
+ ? html`<p class="empty">No presets configured.</p>`
335
+ : html`
336
+ <ul class="preset-list">
337
+ ${presets.map(p => this._renderPresetRow(p, p.handle === activeHandle))}
338
+ </ul>
339
+ `
340
+ }
341
+ </div>
342
+ </details>
343
+ `;
344
+ }
345
+
346
+ private _renderPresetRow(preset: ThermostatPreset, isActive: boolean): TemplateResult {
347
+ return html`
348
+ <li class="preset-row">
349
+ <span class="preset-label">${formatPresetLabel(preset)}</span>
350
+ <span class="preset-setpoints">
351
+ ${this._setpointCell(mdiFire, preset.heatingSetpoint, preset.heatingSetpoint)}
352
+ ${this._setpointCell(mdiSnowflake, preset.coolingSetpoint, preset.coolingSetpoint)}
353
+ </span>
354
+ ${preset.builtIn ? html`<span class="chip-handle">Built-in</span>` : nothing}
355
+ ${
356
+ isActive
357
+ ? html`<span class="active-badge">
358
+ <ha-svg-icon .path=${mdiCheck}></ha-svg-icon>
359
+ Active
360
+ </span>`
361
+ : nothing
362
+ }
363
+ </li>
364
+ `;
365
+ }
366
+
367
+ private _renderSuggestionsPanel(): TemplateResult {
368
+ const maxSuggestions = readMaxThermostatSuggestions(this.node, this.endpoint);
369
+ const suggestions = readThermostatSuggestions(this.node, this.endpoint);
370
+ const current = readCurrentThermostatSuggestion(this.node, this.endpoint);
371
+ const notFollowingReasons = readThermostatSuggestionNotFollowingReasons(this.node, this.endpoint);
372
+ const presets = readPresets(this.node, this.endpoint) ?? [];
373
+ const atCapacity = maxSuggestions !== null && suggestions !== undefined && suggestions.length >= maxSuggestions;
374
+
375
+ return html`
376
+ <details class="command-panel" open>
377
+ <summary>
378
+ <ha-svg-icon .path=${mdiLightbulbOnOutline}></ha-svg-icon>
379
+ Thermostat Suggestions
380
+ <span class="feature-map-badge">FeatureMap: TSUGGEST</span>
381
+ </summary>
382
+ <div class="command-content">
383
+ ${
384
+ current
385
+ ? html`
386
+ <div class="current-suggestion">
387
+ <span class="suggestion-current-label">Current suggestion</span>
388
+ <span class="preset-label">${resolveSuggestionLabel(current, presets)}</span>
389
+ <span class="suggestion-window">
390
+ ${formatEpochTime(current.effectiveTime)} –
391
+ ${formatEpochTime(current.expirationTime)}
392
+ </span>
393
+ ${
394
+ notFollowingReasons.length > 0
395
+ ? html`<span class="suggestion-not-following">
396
+ Not followed: ${notFollowingReasons.map(r => r.label).join(", ")}
397
+ </span>`
398
+ : nothing
399
+ }
400
+ </div>
401
+ `
402
+ : html`<p class="empty">No current suggestion.</p>`
403
+ }
404
+ ${
405
+ suggestions === undefined
406
+ ? html`<p class="empty">ThermostatSuggestions attribute not available.</p>`
407
+ : html`
408
+ <div class="transitions-header">
409
+ QUEUE
410
+ ${maxSuggestions !== null ? html`· ${suggestions.length}/${maxSuggestions}` : nothing}
411
+ </div>
412
+ ${
413
+ suggestions.length === 0
414
+ ? html`<p class="empty">No suggestions queued.</p>`
415
+ : html`
416
+ <ul class="preset-list">
417
+ ${suggestions.map(s =>
418
+ this._renderSuggestionRow(
419
+ s,
420
+ s.uniqueId === current?.uniqueId,
421
+ presets,
422
+ ),
423
+ )}
424
+ </ul>
425
+ `
426
+ }
427
+ `
428
+ }
429
+ ${this._renderAddSuggestionForm(presets, atCapacity)}
430
+ </div>
431
+ </details>
432
+ `;
433
+ }
434
+
435
+ private _renderSuggestionRow(
436
+ suggestion: ThermostatSuggestion,
437
+ isCurrent: boolean,
438
+ presets: ThermostatPreset[],
439
+ ): TemplateResult {
440
+ const busy = this._removeOperations[suggestion.uniqueId] !== undefined;
441
+ return html`
442
+ <li class="preset-row">
443
+ <span class="chip-handle">#${suggestion.uniqueId}</span>
444
+ <span class="preset-label">${resolveSuggestionLabel(suggestion, presets)}</span>
445
+ <span class="suggestion-window">
446
+ ${formatEpochTime(suggestion.effectiveTime)} – ${formatEpochTime(suggestion.expirationTime)}
447
+ </span>
448
+ ${
449
+ isCurrent
450
+ ? html`<span class="active-badge">
451
+ <ha-svg-icon .path=${mdiCheck}></ha-svg-icon>
452
+ Current
453
+ </span>`
454
+ : nothing
455
+ }
456
+ <md-outlined-icon-button
457
+ title="Remove suggestion"
458
+ aria-label="Remove suggestion"
459
+ ?disabled=${busy}
460
+ @click=${handleAsync(() => this._handleRemoveSuggestion(suggestion.uniqueId))}
461
+ >
462
+ <ha-svg-icon .path=${mdiTrashCanOutline}></ha-svg-icon>
463
+ </md-outlined-icon-button>
464
+ </li>
465
+ `;
466
+ }
467
+
468
+ private _renderAddSuggestionForm(presets: ThermostatPreset[], atCapacity: boolean): TemplateResult {
469
+ // The device rewrites Presets at will, so a handle picked earlier may no longer exist.
470
+ const selectedHandle =
471
+ (presets.some(p => p.handle === this._addPresetHandle) ? this._addPresetHandle : presets[0]?.handle) ??
472
+ null;
473
+ return html`
474
+ <div class="transitions-header">ADD SUGGESTION</div>
475
+ ${
476
+ presets.length === 0
477
+ ? html`<p class="empty">No presets available to suggest.</p>`
478
+ : html`
479
+ <div class="command-row">
480
+ <label for="addSuggestionPreset">Preset:</label>
481
+ <select
482
+ id="addSuggestionPreset"
483
+ @change=${(e: Event) => {
484
+ this._addPresetHandle = (e.target as HTMLSelectElement).value;
485
+ }}
486
+ >
487
+ ${presets.map(
488
+ p => html`
489
+ <option value=${p.handle} .selected=${p.handle === selectedHandle}>
490
+ ${formatPresetLabel(p)}
491
+ </option>
492
+ `,
493
+ )}
494
+ </select>
495
+ <label for="addSuggestionExpiration">Expires in (min):</label>
496
+ <input
497
+ id="addSuggestionExpiration"
498
+ type="number"
499
+ min=${MIN_EXPIRATION_MINUTES}
500
+ max=${MAX_EXPIRATION_MINUTES}
501
+ .value=${live(this._addExpirationInput)}
502
+ @input=${(e: Event) => {
503
+ this._addExpirationInput = (e.target as HTMLInputElement).value;
504
+ }}
505
+ @change=${(e: Event) => {
506
+ const raw = (e.target as HTMLInputElement).value.trim();
507
+ this._addExpirationMinutes = clampExpirationMinutes(
508
+ raw === "" ? NaN : Number(raw),
509
+ this._addExpirationMinutes,
510
+ );
511
+ this._addExpirationInput = String(this._addExpirationMinutes);
512
+ }}
513
+ />
514
+ <md-outlined-button
515
+ ?disabled=${this._addOperation !== null || atCapacity || selectedHandle === null}
516
+ @click=${handleAsync(() => this._handleAddSuggestion(selectedHandle))}
517
+ >
518
+ <ha-svg-icon slot="icon" .path=${mdiPlus}></ha-svg-icon>
519
+ Add
520
+ </md-outlined-button>
521
+ </div>
522
+ `
523
+ }
524
+ `;
525
+ }
526
+
527
+ private async _handleAddSuggestion(presetHandle: string | null) {
528
+ const node = this.node;
529
+ const endpoint = this.endpoint;
530
+ if (!node || presetHandle === null || this._addOperation !== null) return;
531
+ const expirationInMinutes = clampExpirationMinutes(this._addExpirationMinutes, DEFAULT_EXPIRATION_MINUTES);
532
+ const operation = ++this._operationCounter;
533
+ this._addOperation = operation;
534
+ try {
535
+ await this.client.deviceCommand(node.node_id, endpoint, THERMOSTAT_CLUSTER_ID, "AddThermostatSuggestion", {
536
+ presetHandle,
537
+ effectiveTime: null,
538
+ expirationInMinutes,
539
+ });
540
+ } catch (err) {
541
+ this._reportInvokeFailure("Add suggestion failed", err, node, endpoint);
542
+ } finally {
543
+ if (this._addOperation === operation) this._addOperation = null;
544
+ }
545
+ }
546
+
547
+ private async _handleRemoveSuggestion(uniqueId: number) {
548
+ const node = this.node;
549
+ const endpoint = this.endpoint;
550
+ if (!node || this._removeOperations[uniqueId] !== undefined) return;
551
+ const operation = ++this._operationCounter;
552
+ this._removeOperations = { ...this._removeOperations, [uniqueId]: operation };
553
+ try {
554
+ await this.client.deviceCommand(
555
+ node.node_id,
556
+ endpoint,
557
+ THERMOSTAT_CLUSTER_ID,
558
+ "RemoveThermostatSuggestion",
559
+ {
560
+ uniqueId,
561
+ },
562
+ );
563
+ } catch (err) {
564
+ this._reportInvokeFailure("Remove suggestion failed", err, node, endpoint);
565
+ } finally {
566
+ if (this._removeOperations[uniqueId] === operation) {
567
+ const pending = { ...this._removeOperations };
568
+ delete pending[uniqueId];
569
+ this._removeOperations = pending;
570
+ }
571
+ }
572
+ }
573
+
574
+ /** Only alerts while the panel still shows the node the invoke was sent to; the dialog names no device. */
575
+ private _reportInvokeFailure(title: string, err: unknown, node: MatterNode, endpoint: number) {
576
+ if (!this.isSameContext(node, endpoint)) {
577
+ console.error(`${title} (panel moved on)`, err);
578
+ return;
579
+ }
580
+ showAlertDialog({
581
+ title,
582
+ text: err instanceof Error ? err.message : String(err),
583
+ }).catch(alertErr => console.error(`Failed to show the "${title}" dialog`, alertErr));
584
+ }
585
+
263
586
  /** A value the device did not report for this transition comes from its preset, so it is marked as derived. */
264
587
  private _setpointCell(icon: string, resolved: number | null, reported: number | null) {
265
588
  if (resolved === null) return nothing;
@@ -289,6 +612,12 @@ class ThermostatClusterCommands extends BaseClusterCommands {
289
612
  static override styles: CSSResultGroup = [
290
613
  BaseClusterCommands.styles,
291
614
  css`
615
+ :host {
616
+ display: flex;
617
+ flex-direction: column;
618
+ gap: 12px;
619
+ }
620
+
292
621
  .feature-map-badge {
293
622
  margin-left: auto;
294
623
  font-size: 0.75rem;
@@ -521,6 +850,86 @@ class ThermostatClusterCommands extends BaseClusterCommands {
521
850
  color: var(--md-sys-color-on-surface-variant);
522
851
  }
523
852
 
853
+ .preset-list {
854
+ list-style: none;
855
+ margin: 0;
856
+ padding: 0;
857
+ display: flex;
858
+ flex-direction: column;
859
+ gap: 4px;
860
+ }
861
+
862
+ .preset-row {
863
+ display: flex;
864
+ align-items: center;
865
+ gap: 12px;
866
+ padding: 8px 12px;
867
+ border-radius: 8px;
868
+ background: var(--md-sys-color-surface-container-highest);
869
+ }
870
+
871
+ .preset-label {
872
+ flex: 1;
873
+ font-weight: 500;
874
+ }
875
+
876
+ .preset-setpoints {
877
+ display: inline-flex;
878
+ align-items: center;
879
+ gap: 4px;
880
+ }
881
+
882
+ .preset-setpoints ha-svg-icon {
883
+ --mdc-icon-size: 16px;
884
+ }
885
+
886
+ .preset-row md-outlined-icon-button {
887
+ --md-outlined-icon-button-container-height: 32px;
888
+ --md-outlined-icon-button-container-width: 32px;
889
+ --md-outlined-icon-button-icon-size: 16px;
890
+ flex-shrink: 0;
891
+ }
892
+
893
+ .command-row select {
894
+ padding: 8px;
895
+ border: 1px solid var(--md-sys-color-outline);
896
+ border-radius: 4px;
897
+ background: var(--md-sys-color-surface);
898
+ color: var(--md-sys-color-on-surface);
899
+ font: inherit;
900
+ }
901
+
902
+ .current-suggestion {
903
+ display: flex;
904
+ flex-wrap: wrap;
905
+ align-items: baseline;
906
+ gap: 8px 12px;
907
+ padding: 8px 12px;
908
+ margin-bottom: 12px;
909
+ border-radius: 8px;
910
+ background: var(--md-sys-color-secondary-container);
911
+ color: var(--md-sys-color-on-secondary-container);
912
+ }
913
+
914
+ .suggestion-current-label {
915
+ text-transform: uppercase;
916
+ font-size: 0.75rem;
917
+ letter-spacing: 0.04em;
918
+ opacity: 0.8;
919
+ }
920
+
921
+ .suggestion-window {
922
+ font-family: var(--monospace-font);
923
+ font-size: 0.8rem;
924
+ opacity: 0.8;
925
+ }
926
+
927
+ .suggestion-not-following {
928
+ flex-basis: 100%;
929
+ font-size: 0.8rem;
930
+ color: var(--danger-color);
931
+ }
932
+
524
933
  .empty {
525
934
  color: var(--md-sys-color-on-surface-variant);
526
935
  margin: 0;
@@ -529,6 +938,8 @@ class ThermostatClusterCommands extends BaseClusterCommands {
529
938
  ];
530
939
  }
531
940
 
941
+ // Without renderWhenOffline the parent unmounts this panel when the node drops, which is what lets the
942
+ // suggestion invoke controls omit an `available` check. Adding it means adding those checks back.
532
943
  registerClusterCommands(THERMOSTAT_CLUSTER_ID, "thermostat-cluster-commands");
533
944
 
534
945
  declare global {
@@ -57,9 +57,6 @@ const TARIFF_UNIT_NAMES: Record<number, string> = { 0: "kWh", 1: "kVAh" };
57
57
  /** ISO 4217 numeric currency codes; falls back to the raw code when not listed here. */
58
58
  const CURRENCY_SYMBOLS: Record<number, string> = { 978: "€", 840: "$", 826: "£", 756: "CHF" };
59
59
 
60
- /** Matter epoch-s values count seconds since 2000-01-01T00:00:00Z, not the Unix epoch. */
61
- const MATTER_EPOCH_OFFSET_SECONDS = 946_684_800;
62
-
63
60
  export interface CurrencyInfo {
64
61
  code: number;
65
62
  decimalPoints: number;
@@ -370,21 +367,6 @@ export function formatMinutesOfDay(minutes: number): string {
370
367
  return `${String(hours).padStart(2, "0")}:${String(mins).padStart(2, "0")}`;
371
368
  }
372
369
 
373
- /** Formats a Matter epoch-s instant as a local time, prefixed with the date when it isn't today. */
374
- export function formatEpochTime(matterEpochSeconds: number, relativeTo: Date = new Date()): string {
375
- const date = new Date((matterEpochSeconds + MATTER_EPOCH_OFFSET_SECONDS) * 1000);
376
- const time = date.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });
377
- if (date.toDateString() === relativeTo.toDateString()) return time;
378
- const tomorrow = new Date(relativeTo);
379
- tomorrow.setDate(tomorrow.getDate() + 1);
380
- if (date.toDateString() === tomorrow.toDateString()) return `tomorrow ${time}`;
381
- const dateOptions: Intl.DateTimeFormatOptions =
382
- date.getFullYear() === relativeTo.getFullYear()
383
- ? { month: "2-digit", day: "2-digit" }
384
- : { year: "numeric", month: "2-digit", day: "2-digit" };
385
- return `${date.toLocaleDateString(undefined, dateOptions)} ${time}`;
386
- }
387
-
388
370
  export function commodityTariffInfo(attributes: Record<string, unknown>, endpoint: number): CommodityTariffInfo {
389
371
  const featureMap = attr(attributes, endpoint, ATTR_FEATURE_MAP);
390
372
  const tariffInfo = decodeTariffInfo(attr(attributes, endpoint, ATTR_TARIFF_INFO));