@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
@@ -12,9 +12,10 @@ import { computeActiveClusterFeatures } from "./cluster-features.js";
12
12
  /** Thermostat cluster (Matter spec §4.3). */
13
13
  export const THERMOSTAT_CLUSTER_ID = 513; // 0x0201
14
14
 
15
+ const ATTR_ACTIVE_PRESET_HANDLE = 0x4e;
16
+ const ATTR_ACTIVE_SCHEDULE_HANDLE = 0x4f;
15
17
  const ATTR_PRESETS = 0x50;
16
18
  const ATTR_SCHEDULES = 0x51;
17
- const ATTR_ACTIVE_SCHEDULE_HANDLE = 0x4f;
18
19
  const ATTR_FEATURE_MAP = 0xfffc;
19
20
 
20
21
  /** Days in display order (Mon..Sun) mapped to their ScheduleDayOfWeekBitmap bit (Sunday=0 .. Saturday=6). */
@@ -53,9 +54,11 @@ export interface ThermostatSchedule {
53
54
 
54
55
  export interface ThermostatPreset {
55
56
  handle: string;
57
+ scenario: number | null;
56
58
  name: string | null;
57
59
  coolingSetpoint: number | null;
58
60
  heatingSetpoint: number | null;
61
+ builtIn: boolean | null;
59
62
  }
60
63
 
61
64
  export interface DaySegment {
@@ -67,7 +70,7 @@ export interface DaySegment {
67
70
  systemMode: number | null;
68
71
  }
69
72
 
70
- function readAttr(node: MatterNode, endpoint: number, attrId: number): unknown {
73
+ export function readThermostatAttribute(node: MatterNode, endpoint: number, attrId: number): unknown {
71
74
  return node.attributes[`${endpoint}/${THERMOSTAT_CLUSTER_ID}/${attrId}`];
72
75
  }
73
76
 
@@ -126,36 +129,61 @@ function decodePreset(raw: unknown): ThermostatPreset | null {
126
129
  if (handle === null) return null;
127
130
  return {
128
131
  handle,
132
+ scenario: pickNumber(obj, "1"),
129
133
  name: pickString(obj, "2"),
130
134
  coolingSetpoint: pickNumber(obj, "3"),
131
135
  heatingSetpoint: pickNumber(obj, "4"),
136
+ builtIn: pickBoolean(obj, "5"),
132
137
  };
133
138
  }
134
139
 
135
- /** Whether the Thermostat cluster's FeatureMap includes MatterScheduleConfiguration (MSCH). */
136
- export function isMSCHActive(node: MatterNode, endpoint: number): boolean {
140
+ /** PresetScenarioEnum labels (Matter spec §4.3.10.17). */
141
+ const PRESET_SCENARIO_LABELS: Record<number, string> = {
142
+ 1: "Occupied",
143
+ 2: "Unoccupied",
144
+ 3: "Sleep",
145
+ 4: "Wake",
146
+ 5: "Vacation",
147
+ 6: "Going to Sleep",
148
+ 254: "User Defined",
149
+ };
150
+
151
+ /** A preset's display name: its own Name when set, else its PresetScenario label. */
152
+ export function formatPresetLabel(preset: ThermostatPreset): string {
153
+ if (preset.name) return preset.name;
154
+ if (preset.scenario !== null) return PRESET_SCENARIO_LABELS[preset.scenario] ?? `Scenario ${preset.scenario}`;
155
+ return formatHandleShort(preset.handle);
156
+ }
157
+
158
+ /** Whether the Thermostat cluster's FeatureMap includes the feature with the given code (e.g. "MSCH", "PRES"). */
159
+ export function isFeatureActive(node: MatterNode, endpoint: number, code: string): boolean {
137
160
  const knownFeatures = Object.values(clusters[THERMOSTAT_CLUSTER_ID]?.features ?? {});
138
161
  const featureMapValue = node.attributes[`${endpoint}/${THERMOSTAT_CLUSTER_ID}/${ATTR_FEATURE_MAP}`];
139
162
  if (featureMapValue === undefined) return false;
140
- return computeActiveClusterFeatures(featureMapValue, knownFeatures).some(feature => feature.code === "MSCH");
163
+ return computeActiveClusterFeatures(featureMapValue, knownFeatures).some(feature => feature.code === code);
141
164
  }
142
165
 
143
166
  export function readActiveScheduleHandle(node: MatterNode, endpoint: number): string | null {
144
- const v = readAttr(node, endpoint, ATTR_ACTIVE_SCHEDULE_HANDLE);
167
+ const v = readThermostatAttribute(node, endpoint, ATTR_ACTIVE_SCHEDULE_HANDLE);
168
+ return typeof v === "string" ? v : null;
169
+ }
170
+
171
+ export function readActivePresetHandle(node: MatterNode, endpoint: number): string | null {
172
+ const v = readThermostatAttribute(node, endpoint, ATTR_ACTIVE_PRESET_HANDLE);
145
173
  return typeof v === "string" ? v : null;
146
174
  }
147
175
 
148
176
  /** Decoded Schedules, or undefined when the attribute is not in the node's attribute cache. */
149
177
  export function readSchedules(node: MatterNode, endpoint: number): ThermostatSchedule[] | undefined {
150
- const raw = readAttr(node, endpoint, ATTR_SCHEDULES);
178
+ const raw = readThermostatAttribute(node, endpoint, ATTR_SCHEDULES);
151
179
  if (!Array.isArray(raw)) return undefined;
152
180
  return raw.map(decodeSchedule).filter((s): s is ThermostatSchedule => s !== null);
153
181
  }
154
182
 
155
- /** Best-effort: only meaningful when the Presets (PRES) feature is supported, but harmless to read regardless. */
156
- export function readPresets(node: MatterNode, endpoint: number): ThermostatPreset[] {
157
- const raw = readAttr(node, endpoint, ATTR_PRESETS);
158
- if (!Array.isArray(raw)) return [];
183
+ /** Decoded Presets, or undefined when the attribute is not in the node's attribute cache. */
184
+ export function readPresets(node: MatterNode, endpoint: number): ThermostatPreset[] | undefined {
185
+ const raw = readThermostatAttribute(node, endpoint, ATTR_PRESETS);
186
+ if (!Array.isArray(raw)) return undefined;
159
187
  return raw.map(decodePreset).filter((p): p is ThermostatPreset => p !== null);
160
188
  }
161
189
 
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025-2026 Open Home Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import type { MatterNode } from "@matter-server/ws-client";
8
+ import { asObject, pickNumber, pickString } from "./attribute-shapes.js";
9
+ import { computeActiveClusterFeatures } from "./cluster-features.js";
10
+ import {
11
+ formatHandleShort,
12
+ formatPresetLabel,
13
+ readThermostatAttribute,
14
+ type ThermostatPreset,
15
+ } from "./thermostat-schedule.js";
16
+
17
+ const ATTR_MAX_SUGGESTIONS = 0x53;
18
+ const ATTR_SUGGESTIONS = 0x54;
19
+ const ATTR_CURRENT_SUGGESTION = 0x55;
20
+ const ATTR_NOT_FOLLOWING_REASON = 0x56;
21
+
22
+ /** AddThermostatSuggestion's ExpirationInMinutes constraint (Matter spec §4.3.12.4.3). */
23
+ export const MIN_EXPIRATION_MINUTES = 30;
24
+ export const MAX_EXPIRATION_MINUTES = 1440;
25
+
26
+ /** Coerces user input to the ExpirationInMinutes constraint, falling back to `previous` for non-numeric input. */
27
+ export function clampExpirationMinutes(value: number, previous: number): number {
28
+ if (!Number.isFinite(value)) return previous;
29
+ return Math.min(MAX_EXPIRATION_MINUTES, Math.max(MIN_EXPIRATION_MINUTES, Math.round(value)));
30
+ }
31
+
32
+ export interface ThermostatSuggestion {
33
+ uniqueId: number;
34
+ presetHandle: string;
35
+ effectiveTime: number;
36
+ expirationTime: number;
37
+ }
38
+
39
+ /** ThermostatSuggestionNotFollowingReasonBitmap (Matter spec §4.3.10.9). */
40
+ const NOT_FOLLOWING_REASON_BITS = [
41
+ { bit: 0, code: "DemandResponseEvent", label: "Demand Response Event" },
42
+ { bit: 1, code: "OngoingHold", label: "Ongoing Hold" },
43
+ { bit: 2, code: "Schedule", label: "Schedule" },
44
+ { bit: 3, code: "Occupancy", label: "Occupancy" },
45
+ { bit: 4, code: "VacationMode", label: "Vacation Mode" },
46
+ { bit: 5, code: "TimeOfUseCostSavings", label: "Time-of-Use Cost Savings" },
47
+ { bit: 6, code: "PreCoolingOrPreHeating", label: "Pre-cooling / Pre-heating" },
48
+ { bit: 7, code: "ConflictingSuggestions", label: "Conflicting Suggestions" },
49
+ ];
50
+
51
+ // Struct attributes reach the dashboard field-tag keyed, matching ThermostatSuggestionStruct's field order.
52
+ function decodeSuggestion(raw: unknown): ThermostatSuggestion | null {
53
+ const obj = asObject(raw);
54
+ if (!obj) return null;
55
+ const uniqueId = pickNumber(obj, "0");
56
+ const presetHandle = pickString(obj, "1");
57
+ const effectiveTime = pickNumber(obj, "2");
58
+ const expirationTime = pickNumber(obj, "3");
59
+ if (uniqueId === null || presetHandle === null || effectiveTime === null || expirationTime === null) return null;
60
+ return { uniqueId, presetHandle, effectiveTime, expirationTime };
61
+ }
62
+
63
+ export function readMaxThermostatSuggestions(node: MatterNode, endpoint: number): number | null {
64
+ const v = readThermostatAttribute(node, endpoint, ATTR_MAX_SUGGESTIONS);
65
+ return typeof v === "number" ? v : null;
66
+ }
67
+
68
+ /** Decoded ThermostatSuggestions queue, or undefined when the attribute is not in the node's attribute cache. */
69
+ export function readThermostatSuggestions(node: MatterNode, endpoint: number): ThermostatSuggestion[] | undefined {
70
+ const raw = readThermostatAttribute(node, endpoint, ATTR_SUGGESTIONS);
71
+ if (!Array.isArray(raw)) return undefined;
72
+ return raw.map(decodeSuggestion).filter((s): s is ThermostatSuggestion => s !== null);
73
+ }
74
+
75
+ export function readCurrentThermostatSuggestion(node: MatterNode, endpoint: number): ThermostatSuggestion | null {
76
+ return decodeSuggestion(readThermostatAttribute(node, endpoint, ATTR_CURRENT_SUGGESTION));
77
+ }
78
+
79
+ /** Reasons the device isn't following CurrentThermostatSuggestion, decoded from the reason bitmap. */
80
+ export function readThermostatSuggestionNotFollowingReasons(
81
+ node: MatterNode,
82
+ endpoint: number,
83
+ ): { bit: number; code: string; label: string }[] {
84
+ const raw = readThermostatAttribute(node, endpoint, ATTR_NOT_FOLLOWING_REASON);
85
+ if (typeof raw !== "number") return [];
86
+ return computeActiveClusterFeatures(raw, NOT_FOLLOWING_REASON_BITS);
87
+ }
88
+
89
+ /** A suggestion's display label: its referenced preset's name/scenario, else its handle. */
90
+ export function resolveSuggestionLabel(suggestion: ThermostatSuggestion, presets: ThermostatPreset[]): string {
91
+ const preset = presets.find(p => p.handle === suggestion.presetHandle);
92
+ return preset ? formatPresetLabel(preset) : formatHandleShort(suggestion.presetHandle);
93
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025-2026 Open Home Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /** Matter epoch-s values count seconds since 2000-01-01T00:00:00Z, not the Unix epoch. */
8
+ const MATTER_EPOCH_OFFSET_SECONDS = 946_684_800;
9
+
10
+ /** Formats a Matter epoch-s instant as a local time, prefixed with the date when it isn't today. */
11
+ export function formatEpochTime(matterEpochSeconds: number, relativeTo: Date = new Date()): string {
12
+ const date = new Date((matterEpochSeconds + MATTER_EPOCH_OFFSET_SECONDS) * 1000);
13
+ const time = date.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });
14
+ if (date.toDateString() === relativeTo.toDateString()) return time;
15
+ const tomorrow = new Date(relativeTo);
16
+ tomorrow.setDate(tomorrow.getDate() + 1);
17
+ if (date.toDateString() === tomorrow.toDateString()) return `tomorrow ${time}`;
18
+ const dateOptions: Intl.DateTimeFormatOptions =
19
+ date.getFullYear() === relativeTo.getFullYear()
20
+ ? { month: "2-digit", day: "2-digit" }
21
+ : { year: "numeric", month: "2-digit", day: "2-digit" };
22
+ return `${date.toLocaleDateString(undefined, dateOptions)} ${time}`;
23
+ }