ZWaveJS: Configuration.resetAll is only supported on CC v4+ (#22823)

This commit is contained in:
Petar Petrov 2024-11-15 18:40:38 +02:00 committed by GitHub
parent d47966cdf7
commit cae5540c44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,12 +22,14 @@ import "../../../../../components/buttons/ha-progress-button";
import type { HaProgressButton } from "../../../../../components/buttons/ha-progress-button"; import type { HaProgressButton } from "../../../../../components/buttons/ha-progress-button";
import { computeDeviceName } from "../../../../../data/device_registry"; import { computeDeviceName } from "../../../../../data/device_registry";
import type { import type {
ZWaveJSNodeCapabilities,
ZWaveJSNodeConfigParam, ZWaveJSNodeConfigParam,
ZWaveJSNodeConfigParams, ZWaveJSNodeConfigParams,
ZWaveJSSetConfigParamResult, ZWaveJSSetConfigParamResult,
ZwaveJSNodeMetadata, ZwaveJSNodeMetadata,
} from "../../../../../data/zwave_js"; } from "../../../../../data/zwave_js";
import { import {
fetchZwaveNodeCapabilities,
fetchZwaveNodeConfigParameters, fetchZwaveNodeConfigParameters,
fetchZwaveNodeMetadata, fetchZwaveNodeMetadata,
invokeZWaveCCApi, invokeZWaveCCApi,
@ -68,6 +70,8 @@ class ZWaveJSNodeConfig extends LitElement {
@state() private _config?: ZWaveJSNodeConfigParams; @state() private _config?: ZWaveJSNodeConfigParams;
@state() private _canResetAll = false;
@state() private _results: Record<string, ZWaveJSSetConfigParamResult> = {}; @state() private _results: Record<string, ZWaveJSSetConfigParamResult> = {};
@state() private _error?: string; @state() private _error?: string;
@ -183,7 +187,8 @@ class ZWaveJSNodeConfig extends LitElement {
</ha-card> </ha-card>
</div>` </div>`
)} )}
<div class="reset"> ${this._canResetAll
? html`<div class="reset">
<ha-progress-button <ha-progress-button
.disabled=${this._resetDialogProgress} .disabled=${this._resetDialogProgress}
.progress=${this._resetDialogProgress} .progress=${this._resetDialogProgress}
@ -193,7 +198,8 @@ class ZWaveJSNodeConfig extends LitElement {
"ui.panel.config.zwave_js.node_config.reset_to_default.button_label" "ui.panel.config.zwave_js.node_config.reset_to_default.button_label"
)} )}
</ha-progress-button> </ha-progress-button>
</div> </div>`
: nothing}
<h3> <h3>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.node_config.custom_config" "ui.panel.config.zwave_js.node_config.custom_config"
@ -468,10 +474,19 @@ class ZWaveJSNodeConfig extends LitElement {
return; return;
} }
[this._nodeMetadata, this._config] = await Promise.all([ let capabilities: ZWaveJSNodeCapabilities | undefined;
[this._nodeMetadata, this._config, capabilities] = await Promise.all([
fetchZwaveNodeMetadata(this.hass, device.id), fetchZwaveNodeMetadata(this.hass, device.id),
fetchZwaveNodeConfigParameters(this.hass, device.id), fetchZwaveNodeConfigParameters(this.hass, device.id),
fetchZwaveNodeCapabilities(this.hass, device.id),
]); ]);
this._canResetAll =
capabilities &&
Object.values(capabilities).some((endpoint) =>
endpoint.some(
(capability) => capability.id === 0x70 && capability.version >= 4
)
);
} }
private async _openResetDialog(event: Event) { private async _openResetDialog(event: Event) {