@matter-server/dashboard 1.5.2 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/client/models/descriptions.d.ts.map +1 -1
- package/dist/esm/client/models/descriptions.js +380 -0
- package/dist/esm/client/models/descriptions.js.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.d.ts +27 -0
- package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.d.ts.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.js +428 -7
- package/dist/esm/pages/cluster-commands/clusters/thermostat-commands.js.map +1 -1
- package/dist/esm/util/thermostat-preset-edit.d.ts +68 -0
- package/dist/esm/util/thermostat-preset-edit.d.ts.map +1 -0
- package/dist/esm/util/thermostat-preset-edit.js +174 -0
- package/dist/esm/util/thermostat-preset-edit.js.map +6 -0
- package/dist/esm/util/thermostat-schedule.d.ts +4 -0
- package/dist/esm/util/thermostat-schedule.d.ts.map +1 -1
- package/dist/esm/util/thermostat-schedule.js +5 -1
- package/dist/esm/util/thermostat-schedule.js.map +1 -1
- package/dist/web/js/{attribute-write-dialog-BYIrK0s9.js → attribute-write-dialog-C-KBqyuJ.js} +1 -1
- package/dist/web/js/{command-invoke-dialog-sgrlMSYh.js → command-invoke-dialog-C4HMf49Q.js} +1 -1
- package/dist/web/js/{commission-node-dialog-C7n9Vdcz.js → commission-node-dialog-Driu7kGn.js} +5 -5
- package/dist/web/js/{commission-node-existing-DfTkRkfm.js → commission-node-existing-Dth2CY1e.js} +1 -1
- package/dist/web/js/{commission-node-thread-B4_kOd4o.js → commission-node-thread-CnixX2gX.js} +1 -1
- package/dist/web/js/{commission-node-wifi-B37hLRjk.js → commission-node-wifi-8im5zNEv.js} +1 -1
- package/dist/web/js/{dialog-box-CRK6qCOH.js → dialog-box-Daj8_--D.js} +1 -1
- package/dist/web/js/{fabric-label-dialog-CtRCSYxX.js → fabric-label-dialog-Bk6lPNvk.js} +1 -1
- package/dist/web/js/main.js +1 -1
- package/dist/web/js/{matter-dashboard-app-DkWZ4ibd.js → matter-dashboard-app-BdO9wWRC.js} +907 -18
- package/dist/web/js/{node-acl-add-dialog-BSKJrvir.js → node-acl-add-dialog-OeLLubXq.js} +1 -1
- package/dist/web/js/{node-binding-dialog-DmhjB76G.js → node-binding-dialog-DQ9R0KrP.js} +1 -1
- package/dist/web/js/{node-label-dialog-DmrPo80W.js → node-label-dialog-IVEQrmsg.js} +1 -1
- package/dist/web/js/{settings-dialog-DxeXrD5U.js → settings-dialog-gcsO83Jl.js} +1 -1
- package/package.json +3 -3
- package/src/client/models/descriptions.ts +380 -0
- package/src/pages/cluster-commands/clusters/thermostat-commands.ts +486 -7
- package/src/util/thermostat-preset-edit.ts +289 -0
- package/src/util/thermostat-schedule.ts +6 -2
|
@@ -15,23 +15,50 @@ declare class ThermostatClusterCommands extends BaseClusterCommands {
|
|
|
15
15
|
private _addPresetHandle;
|
|
16
16
|
private _addExpirationMinutes;
|
|
17
17
|
private _addExpirationInput;
|
|
18
|
+
private _editingPresetHandle;
|
|
19
|
+
private _editName;
|
|
20
|
+
private _editHeating;
|
|
21
|
+
private _editCooling;
|
|
22
|
+
private _creatingPreset;
|
|
23
|
+
private _newPresetScenario;
|
|
24
|
+
private _newPresetName;
|
|
25
|
+
private _newPresetHeating;
|
|
26
|
+
private _newPresetCooling;
|
|
18
27
|
/**
|
|
19
28
|
* In-flight invokes, identified by operation id rather than a boolean: the panel is reused across
|
|
20
29
|
* navigations, so a settling promise must only clear the flag it set itself.
|
|
21
30
|
*/
|
|
22
31
|
private _addOperation;
|
|
23
32
|
private _removeOperations;
|
|
33
|
+
private _presetWriteOperation;
|
|
34
|
+
private _activateOperation;
|
|
24
35
|
private _operationCounter;
|
|
25
36
|
willUpdate(changedProperties: Map<string, unknown>): void;
|
|
26
37
|
render(): typeof nothing | TemplateResult<1>;
|
|
27
38
|
private _renderSchedulePanel;
|
|
28
39
|
private _renderPresetsPanel;
|
|
29
40
|
private _renderPresetRow;
|
|
41
|
+
private _renderPresetEditRow;
|
|
42
|
+
private _renderAddPresetForm;
|
|
30
43
|
private _renderSuggestionsPanel;
|
|
31
44
|
private _renderSuggestionRow;
|
|
32
45
|
private _renderAddSuggestionForm;
|
|
33
46
|
private _handleAddSuggestion;
|
|
34
47
|
private _handleRemoveSuggestion;
|
|
48
|
+
private _startEditPreset;
|
|
49
|
+
private _cancelEditPreset;
|
|
50
|
+
private _openAddPresetForm;
|
|
51
|
+
private _cancelAddPreset;
|
|
52
|
+
private _newPresetNameFor;
|
|
53
|
+
private _handleSavePreset;
|
|
54
|
+
private _handleAddPreset;
|
|
55
|
+
private _handleDeletePreset;
|
|
56
|
+
/**
|
|
57
|
+
* Runs one Presets replacement for the shown node. `buildNext` gets the list as the device reports it; `onSuccess`
|
|
58
|
+
* runs only while the panel still shows this operation.
|
|
59
|
+
*/
|
|
60
|
+
private _runPresetWrite;
|
|
61
|
+
private _handleSetActivePreset;
|
|
35
62
|
/** Only alerts while the panel still shows the node the invoke was sent to; the dialog names no device. */
|
|
36
63
|
private _reportInvokeFailure;
|
|
37
64
|
/** A value the device did not report for this transition comes from its preset, so it is marked as derived. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thermostat-commands.d.ts","sourceRoot":"","sources":["../../../../../src/pages/cluster-commands/clusters/thermostat-commands.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,sCAAsC,CAAC;AAC9C,OAAO,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"thermostat-commands.d.ts","sourceRoot":"","sources":["../../../../../src/pages/cluster-commands/clusters/thermostat-commands.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,sCAAsC,CAAC;AAC9C,OAAO,+CAA+C,CAAC;AAevD,OAAO,EAAO,KAAK,cAAc,EAAQ,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAGnF,OAAO,oCAAoC,CAAC;AAwD5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAWlE,cACM,yBAA0B,SAAQ,mBAAmB;IAC9C,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,UAAU,CAA6B;IACxD,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAEzB,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,qBAAqB,CAA8B;IAC3D,OAAO,CAAC,mBAAmB,CAAsC;IAEjE,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,YAAY,CAAM;IAE1B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,kBAAkB,CAAuB;IACjD,OAAO,CAAC,cAAc,CAAM;IAC5B,OAAO,CAAC,iBAAiB,CAAM;IAC/B,OAAO,CAAC,iBAAiB,CAAM;IAExC;;;OAGG;IACM,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,iBAAiB,CAA8B;IACvD,OAAO,CAAC,qBAAqB,CAAuB;IACpD,OAAO,CAAC,kBAAkB,CAAuB;IAC1D,OAAO,CAAC,iBAAiB,CAAK;IAErB,UAAU,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,QAsB1D;IAEQ,MAAM,uCAQd;IAED,OAAO,CAAC,oBAAoB;IA4M5B,OAAO,CAAC,mBAAmB;IAgD3B,OAAO,CAAC,gBAAgB;IAgExB,OAAO,CAAC,oBAAoB;IAuF5B,OAAO,CAAC,oBAAoB;IA8H5B,OAAO,CAAC,uBAAuB;IAoE/B,OAAO,CAAC,oBAAoB;IAiC5B,OAAO,CAAC,wBAAwB;YA2DlB,oBAAoB;YAoBpB,uBAAuB;IA2BrC,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,iBAAiB;YAKX,iBAAiB;YAkBjB,gBAAgB;YA4BhB,mBAAmB;IAiBjC;;;OAGG;YACW,eAAe;YAwBf,sBAAsB;IAepC,2GAA2G;IAC3G,OAAO,CAAC,oBAAoB;IAW5B,+GAA+G;IAC/G,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,aAAa;IAarB,OAAgB,MAAM,EAAE,cAAc,CA6VpC;CACL;AAMD,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,6BAA6B,EAAE,yBAAyB,CAAC;KAC5D;CACJ"}
|
|
@@ -17,10 +17,13 @@ import "@material/web/button/outlined-button";
|
|
|
17
17
|
import "@material/web/iconbutton/outlined-icon-button";
|
|
18
18
|
import {
|
|
19
19
|
mdiCheck,
|
|
20
|
+
mdiCheckCircleOutline,
|
|
20
21
|
mdiClockOutline,
|
|
22
|
+
mdiClose,
|
|
21
23
|
mdiFire,
|
|
22
24
|
mdiLightbulbOnOutline,
|
|
23
25
|
mdiPaletteSwatchOutline,
|
|
26
|
+
mdiPencilOutline,
|
|
24
27
|
mdiPlus,
|
|
25
28
|
mdiSnowflake,
|
|
26
29
|
mdiTrashCanOutline
|
|
@@ -29,8 +32,21 @@ import { css, html, nothing } from "lit";
|
|
|
29
32
|
import { customElement, state } from "lit/decorators.js";
|
|
30
33
|
import { live } from "lit/directives/live.js";
|
|
31
34
|
import "../../../components/ha-svg-icon.js";
|
|
32
|
-
import { showAlertDialog } from "../../../components/dialog-box/show-dialog-box.js";
|
|
35
|
+
import { showAlertDialog, showPromptDialog } from "../../../components/dialog-box/show-dialog-box.js";
|
|
33
36
|
import { handleAsync } from "../../../util/async-handler.js";
|
|
37
|
+
import {
|
|
38
|
+
applyPresetEdit,
|
|
39
|
+
formatSetpointInput,
|
|
40
|
+
isPresetUsedBySchedule,
|
|
41
|
+
parseSetpointInput,
|
|
42
|
+
presetNameConflict,
|
|
43
|
+
presetTypeSupportsNames,
|
|
44
|
+
readNumberOfPresets,
|
|
45
|
+
readPresetTypes,
|
|
46
|
+
setActivePreset,
|
|
47
|
+
toPresetEdit,
|
|
48
|
+
writeThermostatPresets
|
|
49
|
+
} from "../../../util/thermostat-preset-edit.js";
|
|
34
50
|
import {
|
|
35
51
|
buildDaySegments,
|
|
36
52
|
compareTransitionsForDisplay,
|
|
@@ -47,6 +63,7 @@ import {
|
|
|
47
63
|
readActiveScheduleHandle,
|
|
48
64
|
readPresets,
|
|
49
65
|
pickSetpointForMode,
|
|
66
|
+
PRESET_SCENARIO_LABELS,
|
|
50
67
|
readSchedules,
|
|
51
68
|
resolveScheduleDefaults,
|
|
52
69
|
resolveTransitionLabel,
|
|
@@ -68,6 +85,8 @@ import { BaseClusterCommands } from "../base-cluster-commands.js";
|
|
|
68
85
|
import { registerClusterCommands } from "../registry.js";
|
|
69
86
|
const HOUR_TICKS = [0, 4, 8, 12, 16, 20, 24];
|
|
70
87
|
const DEFAULT_EXPIRATION_MINUTES = 60;
|
|
88
|
+
const DEFAULT_PRESET_HEATING_SETPOINT = 2e3;
|
|
89
|
+
const DEFAULT_PRESET_COOLING_SETPOINT = 2600;
|
|
71
90
|
let ThermostatClusterCommands = class extends BaseClusterCommands {
|
|
72
91
|
constructor() {
|
|
73
92
|
super(...arguments);
|
|
@@ -76,8 +95,19 @@ let ThermostatClusterCommands = class extends BaseClusterCommands {
|
|
|
76
95
|
this._addPresetHandle = null;
|
|
77
96
|
this._addExpirationMinutes = DEFAULT_EXPIRATION_MINUTES;
|
|
78
97
|
this._addExpirationInput = String(DEFAULT_EXPIRATION_MINUTES);
|
|
98
|
+
this._editingPresetHandle = null;
|
|
99
|
+
this._editName = "";
|
|
100
|
+
this._editHeating = "";
|
|
101
|
+
this._editCooling = "";
|
|
102
|
+
this._creatingPreset = false;
|
|
103
|
+
this._newPresetScenario = null;
|
|
104
|
+
this._newPresetName = "";
|
|
105
|
+
this._newPresetHeating = "";
|
|
106
|
+
this._newPresetCooling = "";
|
|
79
107
|
this._addOperation = null;
|
|
80
108
|
this._removeOperations = {};
|
|
109
|
+
this._presetWriteOperation = null;
|
|
110
|
+
this._activateOperation = null;
|
|
81
111
|
this._operationCounter = 0;
|
|
82
112
|
}
|
|
83
113
|
willUpdate(changedProperties) {
|
|
@@ -92,6 +122,14 @@ let ThermostatClusterCommands = class extends BaseClusterCommands {
|
|
|
92
122
|
this._addExpirationInput = String(DEFAULT_EXPIRATION_MINUTES);
|
|
93
123
|
this._addOperation = null;
|
|
94
124
|
this._removeOperations = {};
|
|
125
|
+
this._editingPresetHandle = null;
|
|
126
|
+
this._creatingPreset = false;
|
|
127
|
+
this._newPresetScenario = null;
|
|
128
|
+
this._newPresetName = "";
|
|
129
|
+
this._newPresetHeating = "";
|
|
130
|
+
this._newPresetCooling = "";
|
|
131
|
+
this._presetWriteOperation = null;
|
|
132
|
+
this._activateOperation = null;
|
|
95
133
|
}
|
|
96
134
|
this._scheduleContext = context;
|
|
97
135
|
}
|
|
@@ -262,6 +300,10 @@ let ThermostatClusterCommands = class extends BaseClusterCommands {
|
|
|
262
300
|
_renderPresetsPanel() {
|
|
263
301
|
const presets = readPresets(this.node, this.endpoint);
|
|
264
302
|
const activeHandle = readActivePresetHandle(this.node, this.endpoint);
|
|
303
|
+
const presetTypes = readPresetTypes(this.node, this.endpoint);
|
|
304
|
+
const heatActive = isFeatureActive(this.node, this.endpoint, "HEAT");
|
|
305
|
+
const coolActive = isFeatureActive(this.node, this.endpoint, "COOL");
|
|
306
|
+
const busy = this._presetWriteOperation !== null;
|
|
265
307
|
return html`
|
|
266
308
|
<details class="command-panel" open>
|
|
267
309
|
<summary>
|
|
@@ -272,14 +314,26 @@ let ThermostatClusterCommands = class extends BaseClusterCommands {
|
|
|
272
314
|
<div class="command-content">
|
|
273
315
|
${presets === void 0 ? html`<p class="empty">Presets attribute not available.</p>` : presets.length === 0 ? html`<p class="empty">No presets configured.</p>` : html`
|
|
274
316
|
<ul class="preset-list">
|
|
275
|
-
${presets.map(
|
|
317
|
+
${presets.map(
|
|
318
|
+
(p) => this._editingPresetHandle === p.handle ? this._renderPresetEditRow(
|
|
319
|
+
p,
|
|
320
|
+
presets,
|
|
321
|
+
presetTypes ?? [],
|
|
322
|
+
heatActive,
|
|
323
|
+
coolActive,
|
|
324
|
+
busy
|
|
325
|
+
) : this._renderPresetRow(p, p.handle === activeHandle, busy)
|
|
326
|
+
)}
|
|
276
327
|
</ul>
|
|
277
328
|
`}
|
|
329
|
+
${presets === void 0 ? nothing : this._renderAddPresetForm(presets, presetTypes, heatActive, coolActive, busy)}
|
|
278
330
|
</div>
|
|
279
331
|
</details>
|
|
280
332
|
`;
|
|
281
333
|
}
|
|
282
|
-
_renderPresetRow(preset, isActive) {
|
|
334
|
+
_renderPresetRow(preset, isActive, busy) {
|
|
335
|
+
const activating = this._activateOperation !== null;
|
|
336
|
+
const removeBlockedReason = preset.builtIn ? "Built-in presets cannot be removed" : isActive ? "The active preset cannot be removed" : isPresetUsedBySchedule(readSchedules(this.node, this.endpoint) ?? [], preset.handle) ? "A schedule uses this preset" : null;
|
|
283
337
|
return html`
|
|
284
338
|
<li class="preset-row">
|
|
285
339
|
<span class="preset-label">${formatPresetLabel(preset)}</span>
|
|
@@ -288,13 +342,205 @@ let ThermostatClusterCommands = class extends BaseClusterCommands {
|
|
|
288
342
|
${this._setpointCell(mdiSnowflake, preset.coolingSetpoint, preset.coolingSetpoint)}
|
|
289
343
|
</span>
|
|
290
344
|
${preset.builtIn ? html`<span class="chip-handle">Built-in</span>` : nothing}
|
|
291
|
-
${isActive ? html
|
|
292
|
-
<
|
|
293
|
-
|
|
294
|
-
|
|
345
|
+
${isActive ? html`
|
|
346
|
+
<span class="active-badge">
|
|
347
|
+
<ha-svg-icon .path=${mdiCheck}></ha-svg-icon>
|
|
348
|
+
Active
|
|
349
|
+
</span>
|
|
350
|
+
<md-outlined-icon-button
|
|
351
|
+
title="Clear active preset"
|
|
352
|
+
aria-label="Clear active preset"
|
|
353
|
+
?disabled=${activating || busy}
|
|
354
|
+
@click=${handleAsync(() => this._handleSetActivePreset(null))}
|
|
355
|
+
>
|
|
356
|
+
<ha-svg-icon .path=${mdiClose}></ha-svg-icon>
|
|
357
|
+
</md-outlined-icon-button>
|
|
358
|
+
` : html`
|
|
359
|
+
<md-outlined-icon-button
|
|
360
|
+
title="Set as active preset"
|
|
361
|
+
aria-label="Set as active preset"
|
|
362
|
+
?disabled=${activating || busy}
|
|
363
|
+
@click=${handleAsync(() => this._handleSetActivePreset(preset.handle))}
|
|
364
|
+
>
|
|
365
|
+
<ha-svg-icon .path=${mdiCheckCircleOutline}></ha-svg-icon>
|
|
366
|
+
</md-outlined-icon-button>
|
|
367
|
+
`}
|
|
368
|
+
<md-outlined-icon-button
|
|
369
|
+
title="Edit preset"
|
|
370
|
+
aria-label="Edit preset"
|
|
371
|
+
?disabled=${busy}
|
|
372
|
+
@click=${() => this._startEditPreset(preset)}
|
|
373
|
+
>
|
|
374
|
+
<ha-svg-icon .path=${mdiPencilOutline}></ha-svg-icon>
|
|
375
|
+
</md-outlined-icon-button>
|
|
376
|
+
<md-outlined-icon-button
|
|
377
|
+
title=${removeBlockedReason ?? "Remove preset"}
|
|
378
|
+
aria-label="Remove preset"
|
|
379
|
+
?disabled=${busy || activating || removeBlockedReason !== null}
|
|
380
|
+
@click=${handleAsync(() => this._handleDeletePreset(preset))}
|
|
381
|
+
>
|
|
382
|
+
<ha-svg-icon .path=${mdiTrashCanOutline}></ha-svg-icon>
|
|
383
|
+
</md-outlined-icon-button>
|
|
384
|
+
</li>
|
|
385
|
+
`;
|
|
386
|
+
}
|
|
387
|
+
_renderPresetEditRow(preset, presets, presetTypes, heatActive, coolActive, busy) {
|
|
388
|
+
const edited = applyPresetEdit(preset, presetTypes, {
|
|
389
|
+
name: this._editName,
|
|
390
|
+
heating: this._editHeating,
|
|
391
|
+
cooling: this._editCooling
|
|
392
|
+
});
|
|
393
|
+
const nameConflict = presetNameConflict(presets, edited.presetScenario, edited.name, preset.handle);
|
|
394
|
+
const scenarioLabel = PRESET_SCENARIO_LABELS[preset.scenario ?? -1] ?? formatHandleShort(preset.handle);
|
|
395
|
+
return html`
|
|
396
|
+
<li class="preset-row preset-row-editing">
|
|
397
|
+
<span class="preset-label">${scenarioLabel}</span>
|
|
398
|
+
${presetTypeSupportsNames(presetTypes, preset.scenario) ? html`
|
|
399
|
+
<label for="editPresetName">Name:</label>
|
|
400
|
+
<input
|
|
401
|
+
id="editPresetName"
|
|
402
|
+
type="text"
|
|
403
|
+
maxlength="64"
|
|
404
|
+
placeholder="(unnamed)"
|
|
405
|
+
.value=${live(this._editName)}
|
|
406
|
+
@input=${(e) => {
|
|
407
|
+
this._editName = e.target.value;
|
|
408
|
+
}}
|
|
409
|
+
/>
|
|
410
|
+
` : nothing}
|
|
411
|
+
${heatActive ? html`
|
|
412
|
+
<label for="editPresetHeat">Heat:</label>
|
|
413
|
+
<input
|
|
414
|
+
id="editPresetHeat"
|
|
415
|
+
type="number"
|
|
416
|
+
step="0.01"
|
|
417
|
+
.value=${live(this._editHeating)}
|
|
418
|
+
@input=${(e) => {
|
|
419
|
+
this._editHeating = e.target.value;
|
|
420
|
+
}}
|
|
421
|
+
/>
|
|
422
|
+
` : nothing}
|
|
423
|
+
${coolActive ? html`
|
|
424
|
+
<label for="editPresetCool">Cool:</label>
|
|
425
|
+
<input
|
|
426
|
+
id="editPresetCool"
|
|
427
|
+
type="number"
|
|
428
|
+
step="0.01"
|
|
429
|
+
.value=${live(this._editCooling)}
|
|
430
|
+
@input=${(e) => {
|
|
431
|
+
this._editCooling = e.target.value;
|
|
432
|
+
}}
|
|
433
|
+
/>
|
|
434
|
+
` : nothing}
|
|
435
|
+
<md-outlined-icon-button
|
|
436
|
+
title=${nameConflict ?? "Save"}
|
|
437
|
+
aria-label="Save"
|
|
438
|
+
?disabled=${busy || nameConflict !== null}
|
|
439
|
+
@click=${handleAsync(() => this._handleSavePreset(preset.handle))}
|
|
440
|
+
>
|
|
441
|
+
<ha-svg-icon .path=${mdiCheck}></ha-svg-icon>
|
|
442
|
+
</md-outlined-icon-button>
|
|
443
|
+
<md-outlined-icon-button
|
|
444
|
+
title="Cancel"
|
|
445
|
+
aria-label="Cancel"
|
|
446
|
+
?disabled=${busy}
|
|
447
|
+
@click=${() => this._cancelEditPreset()}
|
|
448
|
+
>
|
|
449
|
+
<ha-svg-icon .path=${mdiClose}></ha-svg-icon>
|
|
450
|
+
</md-outlined-icon-button>
|
|
295
451
|
</li>
|
|
296
452
|
`;
|
|
297
453
|
}
|
|
454
|
+
_renderAddPresetForm(presets, presetTypes, heatActive, coolActive, busy) {
|
|
455
|
+
if (!this._creatingPreset) {
|
|
456
|
+
return html`
|
|
457
|
+
<md-outlined-button ?disabled=${busy} @click=${() => this._openAddPresetForm(presetTypes ?? [])}>
|
|
458
|
+
<ha-svg-icon slot="icon" .path=${mdiPlus}></ha-svg-icon>
|
|
459
|
+
Add preset
|
|
460
|
+
</md-outlined-button>
|
|
461
|
+
`;
|
|
462
|
+
}
|
|
463
|
+
const countByScenario = /* @__PURE__ */ new Map();
|
|
464
|
+
for (const p of presets) {
|
|
465
|
+
if (p.scenario !== null) countByScenario.set(p.scenario, (countByScenario.get(p.scenario) ?? 0) + 1);
|
|
466
|
+
}
|
|
467
|
+
const totalLimit = readNumberOfPresets(this.node, this.endpoint);
|
|
468
|
+
const availableTypes = totalLimit !== null && presets.length >= totalLimit ? [] : (presetTypes ?? []).filter(
|
|
469
|
+
(t) => (countByScenario.get(t.scenario) ?? 0) < t.numberOfPresets && (t.supportsNames || presetNameConflict(presets, t.scenario, null, null) === null)
|
|
470
|
+
);
|
|
471
|
+
const selectedType = availableTypes.find((t) => t.scenario === this._newPresetScenario) ?? availableTypes[0] ?? null;
|
|
472
|
+
const nameConflict = selectedType === null ? null : presetNameConflict(presets, selectedType.scenario, this._newPresetNameFor(selectedType), null);
|
|
473
|
+
return html`
|
|
474
|
+
<div class="transitions-header">ADD PRESET</div>
|
|
475
|
+
${presetTypes === void 0 ? html`<p class="empty">PresetTypes attribute not available.</p>` : availableTypes.length === 0 ? html`<p class="empty">The device has no room left for another preset.</p>` : html`
|
|
476
|
+
<div class="command-row">
|
|
477
|
+
<label for="newPresetScenario">Scenario:</label>
|
|
478
|
+
<select
|
|
479
|
+
id="newPresetScenario"
|
|
480
|
+
@change=${(e) => {
|
|
481
|
+
this._newPresetScenario = Number(e.target.value);
|
|
482
|
+
}}
|
|
483
|
+
>
|
|
484
|
+
${availableTypes.map(
|
|
485
|
+
(t) => html`
|
|
486
|
+
<option
|
|
487
|
+
value=${t.scenario}
|
|
488
|
+
.selected=${t.scenario === selectedType?.scenario}
|
|
489
|
+
>
|
|
490
|
+
${PRESET_SCENARIO_LABELS[t.scenario] ?? `Scenario ${t.scenario}`}
|
|
491
|
+
</option>
|
|
492
|
+
`
|
|
493
|
+
)}
|
|
494
|
+
</select>
|
|
495
|
+
${selectedType?.supportsNames ? html`
|
|
496
|
+
<label for="newPresetName">Name:</label>
|
|
497
|
+
<input
|
|
498
|
+
id="newPresetName"
|
|
499
|
+
type="text"
|
|
500
|
+
maxlength="64"
|
|
501
|
+
.value=${live(this._newPresetName)}
|
|
502
|
+
@input=${(e) => {
|
|
503
|
+
this._newPresetName = e.target.value;
|
|
504
|
+
}}
|
|
505
|
+
/>
|
|
506
|
+
` : nothing}
|
|
507
|
+
${heatActive ? html`
|
|
508
|
+
<label for="newPresetHeat">Heat:</label>
|
|
509
|
+
<input
|
|
510
|
+
id="newPresetHeat"
|
|
511
|
+
type="number"
|
|
512
|
+
step="0.01"
|
|
513
|
+
.value=${live(this._newPresetHeating)}
|
|
514
|
+
@input=${(e) => {
|
|
515
|
+
this._newPresetHeating = e.target.value;
|
|
516
|
+
}}
|
|
517
|
+
/>
|
|
518
|
+
` : nothing}
|
|
519
|
+
${coolActive ? html`
|
|
520
|
+
<label for="newPresetCool">Cool:</label>
|
|
521
|
+
<input
|
|
522
|
+
id="newPresetCool"
|
|
523
|
+
type="number"
|
|
524
|
+
step="0.01"
|
|
525
|
+
.value=${live(this._newPresetCooling)}
|
|
526
|
+
@input=${(e) => {
|
|
527
|
+
this._newPresetCooling = e.target.value;
|
|
528
|
+
}}
|
|
529
|
+
/>
|
|
530
|
+
` : nothing}
|
|
531
|
+
<md-outlined-button
|
|
532
|
+
title=${nameConflict ?? nothing}
|
|
533
|
+
?disabled=${busy || selectedType === null || nameConflict !== null}
|
|
534
|
+
@click=${handleAsync(() => this._handleAddPreset(selectedType))}
|
|
535
|
+
>
|
|
536
|
+
<ha-svg-icon slot="icon" .path=${mdiPlus}></ha-svg-icon>
|
|
537
|
+
Add
|
|
538
|
+
</md-outlined-button>
|
|
539
|
+
</div>
|
|
540
|
+
`}
|
|
541
|
+
<md-outlined-button ?disabled=${busy} @click=${() => this._cancelAddPreset()}>Cancel</md-outlined-button>
|
|
542
|
+
`;
|
|
543
|
+
}
|
|
298
544
|
_renderSuggestionsPanel() {
|
|
299
545
|
const maxSuggestions = readMaxThermostatSuggestions(this.node, this.endpoint);
|
|
300
546
|
const suggestions = readThermostatSuggestions(this.node, this.endpoint);
|
|
@@ -465,6 +711,125 @@ let ThermostatClusterCommands = class extends BaseClusterCommands {
|
|
|
465
711
|
}
|
|
466
712
|
}
|
|
467
713
|
}
|
|
714
|
+
_startEditPreset(preset) {
|
|
715
|
+
this._creatingPreset = false;
|
|
716
|
+
this._editingPresetHandle = preset.handle;
|
|
717
|
+
this._editName = preset.name ?? "";
|
|
718
|
+
this._editHeating = formatSetpointInput(preset.heatingSetpoint);
|
|
719
|
+
this._editCooling = formatSetpointInput(preset.coolingSetpoint);
|
|
720
|
+
}
|
|
721
|
+
_cancelEditPreset() {
|
|
722
|
+
this._editingPresetHandle = null;
|
|
723
|
+
}
|
|
724
|
+
_openAddPresetForm(presetTypes) {
|
|
725
|
+
this._editingPresetHandle = null;
|
|
726
|
+
this._creatingPreset = true;
|
|
727
|
+
this._newPresetScenario = presetTypes[0]?.scenario ?? null;
|
|
728
|
+
this._newPresetName = "";
|
|
729
|
+
this._newPresetHeating = formatSetpointInput(DEFAULT_PRESET_HEATING_SETPOINT);
|
|
730
|
+
this._newPresetCooling = formatSetpointInput(DEFAULT_PRESET_COOLING_SETPOINT);
|
|
731
|
+
}
|
|
732
|
+
_cancelAddPreset() {
|
|
733
|
+
this._creatingPreset = false;
|
|
734
|
+
}
|
|
735
|
+
_newPresetNameFor(type) {
|
|
736
|
+
const name = this._newPresetName.trim();
|
|
737
|
+
return type.supportsNames && name.length > 0 ? name : null;
|
|
738
|
+
}
|
|
739
|
+
async _handleSavePreset(presetHandle) {
|
|
740
|
+
const input = { name: this._editName, heating: this._editHeating, cooling: this._editCooling };
|
|
741
|
+
await this._runPresetWrite(
|
|
742
|
+
"Saving preset failed",
|
|
743
|
+
(current, presetTypes) => {
|
|
744
|
+
const preset = current.find((p) => p.handle === presetHandle);
|
|
745
|
+
if (!preset) throw new Error("The preset no longer exists on the device");
|
|
746
|
+
const edited = applyPresetEdit(preset, presetTypes, input);
|
|
747
|
+
const conflict = presetNameConflict(current, edited.presetScenario, edited.name, presetHandle);
|
|
748
|
+
if (conflict !== null) throw new Error(conflict);
|
|
749
|
+
return current.map((p) => p.handle === presetHandle ? edited : toPresetEdit(p));
|
|
750
|
+
},
|
|
751
|
+
() => {
|
|
752
|
+
if (this._editingPresetHandle === presetHandle) this._editingPresetHandle = null;
|
|
753
|
+
}
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
async _handleAddPreset(selectedType) {
|
|
757
|
+
const node = this.node;
|
|
758
|
+
if (!node || selectedType === null) return;
|
|
759
|
+
const added = {
|
|
760
|
+
presetHandle: null,
|
|
761
|
+
presetScenario: selectedType.scenario,
|
|
762
|
+
name: this._newPresetNameFor(selectedType),
|
|
763
|
+
heatingSetpoint: isFeatureActive(node, this.endpoint, "HEAT") ? parseSetpointInput(this._newPresetHeating, DEFAULT_PRESET_HEATING_SETPOINT) : null,
|
|
764
|
+
coolingSetpoint: isFeatureActive(node, this.endpoint, "COOL") ? parseSetpointInput(this._newPresetCooling, DEFAULT_PRESET_COOLING_SETPOINT) : null,
|
|
765
|
+
builtIn: false
|
|
766
|
+
};
|
|
767
|
+
await this._runPresetWrite(
|
|
768
|
+
"Adding preset failed",
|
|
769
|
+
(current) => {
|
|
770
|
+
const conflict = presetNameConflict(current, added.presetScenario, added.name, null);
|
|
771
|
+
if (conflict !== null) throw new Error(conflict);
|
|
772
|
+
return [...current.map(toPresetEdit), added];
|
|
773
|
+
},
|
|
774
|
+
() => {
|
|
775
|
+
this._creatingPreset = false;
|
|
776
|
+
}
|
|
777
|
+
);
|
|
778
|
+
}
|
|
779
|
+
async _handleDeletePreset(preset) {
|
|
780
|
+
const node = this.node;
|
|
781
|
+
const endpoint = this.endpoint;
|
|
782
|
+
if (!node || this._presetWriteOperation !== null) return;
|
|
783
|
+
const confirmed = await showPromptDialog({
|
|
784
|
+
title: "Remove preset",
|
|
785
|
+
text: `Remove "${formatPresetLabel(preset)}"? This cannot be undone.`,
|
|
786
|
+
confirmText: "Remove"
|
|
787
|
+
});
|
|
788
|
+
if (!confirmed || !this.isSameContext(node, endpoint)) return;
|
|
789
|
+
await this._runPresetWrite(
|
|
790
|
+
"Removing preset failed",
|
|
791
|
+
(current) => current.filter((p) => p.handle !== preset.handle).map(toPresetEdit)
|
|
792
|
+
);
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Runs one Presets replacement for the shown node. `buildNext` gets the list as the device reports it; `onSuccess`
|
|
796
|
+
* runs only while the panel still shows this operation.
|
|
797
|
+
*/
|
|
798
|
+
async _runPresetWrite(failureTitle, buildNext, onSuccess) {
|
|
799
|
+
const node = this.node;
|
|
800
|
+
const endpoint = this.endpoint;
|
|
801
|
+
if (!node || this._presetWriteOperation !== null) return;
|
|
802
|
+
const presetTypes = readPresetTypes(node, endpoint) ?? [];
|
|
803
|
+
const operation = ++this._operationCounter;
|
|
804
|
+
this._presetWriteOperation = operation;
|
|
805
|
+
try {
|
|
806
|
+
await writeThermostatPresets(
|
|
807
|
+
this.client,
|
|
808
|
+
node.node_id,
|
|
809
|
+
endpoint,
|
|
810
|
+
(current) => buildNext(current, presetTypes)
|
|
811
|
+
);
|
|
812
|
+
if (this._presetWriteOperation === operation) onSuccess?.();
|
|
813
|
+
} catch (err) {
|
|
814
|
+
this._reportInvokeFailure(failureTitle, err, node, endpoint);
|
|
815
|
+
} finally {
|
|
816
|
+
if (this._presetWriteOperation === operation) this._presetWriteOperation = null;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
async _handleSetActivePreset(presetHandle) {
|
|
820
|
+
const node = this.node;
|
|
821
|
+
const endpoint = this.endpoint;
|
|
822
|
+
if (!node || this._activateOperation !== null) return;
|
|
823
|
+
const operation = ++this._operationCounter;
|
|
824
|
+
this._activateOperation = operation;
|
|
825
|
+
try {
|
|
826
|
+
await setActivePreset(this.client, node.node_id, endpoint, presetHandle);
|
|
827
|
+
} catch (err) {
|
|
828
|
+
this._reportInvokeFailure("Setting active preset failed", err, node, endpoint);
|
|
829
|
+
} finally {
|
|
830
|
+
if (this._activateOperation === operation) this._activateOperation = null;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
468
833
|
/** Only alerts while the panel still shows the node the invoke was sent to; the dialog names no device. */
|
|
469
834
|
_reportInvokeFailure(title, err, node, endpoint) {
|
|
470
835
|
if (!this.isSameContext(node, endpoint)) {
|
|
@@ -778,6 +1143,29 @@ ThermostatClusterCommands.styles = [
|
|
|
778
1143
|
flex-shrink: 0;
|
|
779
1144
|
}
|
|
780
1145
|
|
|
1146
|
+
.preset-row-editing {
|
|
1147
|
+
flex-wrap: wrap;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
.preset-row-editing label {
|
|
1151
|
+
font-size: 0.8rem;
|
|
1152
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
.preset-row-editing input[type="text"],
|
|
1156
|
+
.preset-row-editing input[type="number"] {
|
|
1157
|
+
padding: 6px 8px;
|
|
1158
|
+
border: 1px solid var(--md-sys-color-outline);
|
|
1159
|
+
border-radius: 4px;
|
|
1160
|
+
background: var(--md-sys-color-surface);
|
|
1161
|
+
color: var(--md-sys-color-on-surface);
|
|
1162
|
+
font: inherit;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
.preset-row-editing input[type="number"] {
|
|
1166
|
+
width: 70px;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
781
1169
|
.command-row select {
|
|
782
1170
|
padding: 8px;
|
|
783
1171
|
border: 1px solid var(--md-sys-color-outline);
|
|
@@ -839,12 +1227,45 @@ __decorateClass([
|
|
|
839
1227
|
__decorateClass([
|
|
840
1228
|
state()
|
|
841
1229
|
], ThermostatClusterCommands.prototype, "_addExpirationInput", 2);
|
|
1230
|
+
__decorateClass([
|
|
1231
|
+
state()
|
|
1232
|
+
], ThermostatClusterCommands.prototype, "_editingPresetHandle", 2);
|
|
1233
|
+
__decorateClass([
|
|
1234
|
+
state()
|
|
1235
|
+
], ThermostatClusterCommands.prototype, "_editName", 2);
|
|
1236
|
+
__decorateClass([
|
|
1237
|
+
state()
|
|
1238
|
+
], ThermostatClusterCommands.prototype, "_editHeating", 2);
|
|
1239
|
+
__decorateClass([
|
|
1240
|
+
state()
|
|
1241
|
+
], ThermostatClusterCommands.prototype, "_editCooling", 2);
|
|
1242
|
+
__decorateClass([
|
|
1243
|
+
state()
|
|
1244
|
+
], ThermostatClusterCommands.prototype, "_creatingPreset", 2);
|
|
1245
|
+
__decorateClass([
|
|
1246
|
+
state()
|
|
1247
|
+
], ThermostatClusterCommands.prototype, "_newPresetScenario", 2);
|
|
1248
|
+
__decorateClass([
|
|
1249
|
+
state()
|
|
1250
|
+
], ThermostatClusterCommands.prototype, "_newPresetName", 2);
|
|
1251
|
+
__decorateClass([
|
|
1252
|
+
state()
|
|
1253
|
+
], ThermostatClusterCommands.prototype, "_newPresetHeating", 2);
|
|
1254
|
+
__decorateClass([
|
|
1255
|
+
state()
|
|
1256
|
+
], ThermostatClusterCommands.prototype, "_newPresetCooling", 2);
|
|
842
1257
|
__decorateClass([
|
|
843
1258
|
state()
|
|
844
1259
|
], ThermostatClusterCommands.prototype, "_addOperation", 2);
|
|
845
1260
|
__decorateClass([
|
|
846
1261
|
state()
|
|
847
1262
|
], ThermostatClusterCommands.prototype, "_removeOperations", 2);
|
|
1263
|
+
__decorateClass([
|
|
1264
|
+
state()
|
|
1265
|
+
], ThermostatClusterCommands.prototype, "_presetWriteOperation", 2);
|
|
1266
|
+
__decorateClass([
|
|
1267
|
+
state()
|
|
1268
|
+
], ThermostatClusterCommands.prototype, "_activateOperation", 2);
|
|
848
1269
|
ThermostatClusterCommands = __decorateClass([
|
|
849
1270
|
customElement("thermostat-cluster-commands")
|
|
850
1271
|
], ThermostatClusterCommands);
|